Update Compiler To Use Macros

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-03-06 08:02:35 -05:00
parent 8ca03cdca5
commit c3b3be77eb
6 changed files with 105 additions and 104 deletions
+23
View File
@@ -23,6 +23,7 @@ import SwiftTreeSitter
import Testing
import TreeSitter
import TreeSitterP4
import P4Lang
@testable import P4Compiler
@@ -93,3 +94,25 @@ import TreeSitterP4
#expect(compilation_error.msg.contains("asde"))
#expect(compilation_error.msg.contains("asdf"))
}
@Test func test_simple_parser_macro_nodetype_test() async throws {
let simple = """
parser main_parser() {
state start {
transition select (false) {
asdf: reject;
asde: reject;
};
}
};
"""
let p = try! #UseOkResult(ConfigureP4Parser())
let result = try! #require(p.parse(simple))
#expect(
#RequireErrorResult<(EvaluatableStatement, LexicalScopes)>(
Error(withMessage: "{2, 154}: Did not find assignment statement"),
ParserAssignmentStatement.Compile(
node: result.rootNode!, inTree: result, withScopes: LexicalScopes())))
}