this repo has no description
www.jonmsterling.com/01HC/
1// SPDX-FileCopyrightText: 2025 The Project Pterodactyl Developers
2//
3// SPDX-License-Identifier: MPL-2.0
4
5import Foundation
6import PterodactylSyntax
7import llbuild2fx
8import Logging
9
10extension Keys.Blob {
11 public struct ParseDocument: BuildKey {
12 public let blobId: LLBDataID
13 public init(blobId: LLBDataID) {
14 self.blobId = blobId
15 }
16
17 public struct ValueType: Codable, FXValue {
18 public let tree: PterodactylSyntax.SyntaxTree
19 public let diagnostics: [Diagnostic]
20 }
21
22 public static let versionDependencies: [any FXVersioning.Type] = [ReadContents.self, Tokenise.self]
23
24 public func computeValue(_ ctx: BuildContext<Self>) async throws -> ValueType {
25 let code = try await ctx.request(ReadContents(blobId: blobId))
26 let tokens = try await ctx.request(Tokenise(blobId: blobId))
27 var parser = Parser(source: code, tokens: tokens)
28 PterodactylSyntax.Document.parse(&parser, recovery: [])
29 return ValueType(tree: parser.builder.tree, diagnostics: parser.diagnostics)
30 }
31 }
32}