Support Calling Parsers With Parameters

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-02 01:28:43 -04:00
parent 7cdbee1999
commit d971aab1fe
12 changed files with 345 additions and 82 deletions
@@ -262,3 +262,20 @@ import TreeSitterP4
),
Program.Compile(simple_parser_declaration, withGlobalInstances: test_types)))
}
@Test func test_simple_compiler_parser_parameters_invalid_types() async throws {
let simple_parser_declaration = """
parser main_parser(bool pmtr, string smtr, int imtr) {
state start {
pmtr = 1;
transition accept;
}
};
"""
#expect(
#RequireErrorResult(
Error(
withMessage: "{85, 9}: Failed to parse a statement element: {85, 4}: Cannot assign value with type Int to identifier pmtr with type Boolean"
),
Program.Compile(simple_parser_declaration)))
}