Refactor Parser States

Refactor the class hierarchy for parser states so that
there is a parser state that acts more like a type and
one that acts more like a value (the latter, then, serves
as the base class for the other instantiated parser states).

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-03-30 05:16:48 -04:00
parent fda9858680
commit 7c9ecc2438
21 changed files with 199 additions and 264 deletions
+5 -5
View File
@@ -147,7 +147,7 @@ import TreeSitterP4
// 5 == 5 == true
// true == true
// true
#expect(state_result == P4Lang.accept)
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
}
@Test func test_expression_in_declaration_initializer2() async throws {
@@ -169,7 +169,7 @@ import TreeSitterP4
// 5 == 5 == true
// true == false
// false
#expect(state_result == P4Lang.reject)
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
}
@Test func test_expression_in_declaration_initializer_false() async throws {
@@ -191,7 +191,7 @@ import TreeSitterP4
// 6 == 5 == true
// false == true
// false
#expect(state_result == P4Lang.reject)
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
}
@Test func test_expression_in_declaration_initializer_false2() async throws {
@@ -213,7 +213,7 @@ import TreeSitterP4
// 6 == 5 == false
// false == false
// true
#expect(state_result == P4Lang.accept)
#expect(AsInstantiatedParserState(state_result) == P4Lang.accept)
}
@Test func test_expression_in_declaration_initializer_invalid_types() async throws {
@@ -237,7 +237,7 @@ import TreeSitterP4
// false == 5 == true
// false == true
// false
#expect(state_result == P4Lang.reject)
#expect(AsInstantiatedParserState(state_result) == P4Lang.reject)
}
@Test func test_expression_in_declaration_initializer_invalid_types2() async throws {