1// SPDX-FileCopyrightText: 2025 The Project Pterodactyl Developers 2// 3// SPDX-License-Identifier: MPL-2.0 4 5import Foundation 6 7enum Theory: Grammar { 8 static let kind = SyntaxTreeKind(name: "theory") 9 static let kinds = [kind] 10 11 static func before(_ parser: inout Parser) -> Bool { 12 parser.isAt(kind: .keyword(.theory)) 13 } 14 15 static func inside(_ parser: inout Parser) -> ParseResult { 16 parser.expect(kind: .keyword(.theory), metadata: TokenMetadata(semanticTokenType: .keyword)) 17 parser.eatTrivia() 18 if !TheoryName.tryParse(&parser) { 19 parser.advance(error: "Expected theory name") 20 } 21 22 parser.eatTrivia() 23 24 TheoryBlock.parse(&parser) 25 26 return ParseResult(kind: Self.kind) 27 } 28} 29 30extension SyntaxView<Theory> { 31 var name: SyntaxView<TheoryName>? { matchingSubview() } 32 var block: SyntaxView<TheoryBlock>? { matchingSubview() } 33}