compiler: Refactor Compiler To Remove Ambiguities
There were significant overlaps in the names of data structures between the compiler and the language that made it necessary to litter the code with P4Lang.xxxx. This refactor removes that requirement in most places (Parser is ambiguous wherever TreeSitter is used -- cannot avoid that!) Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -47,7 +47,7 @@ import TreeSitterP4
|
||||
default: false
|
||||
}
|
||||
}
|
||||
let program = try! #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let program = try! #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
#expect(program.TypesWithTypes(x).count == 1)
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ import TreeSitterP4
|
||||
default: false
|
||||
}
|
||||
}
|
||||
let program = try! #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let program = try! #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
#expect(program.TypesWithTypes(filter).count == 2)
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ import TreeSitterP4
|
||||
default: false
|
||||
}
|
||||
}
|
||||
let program = try! #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let program = try! #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
#expect(program.TypesWithTypes(x).count == 1)
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ import TreeSitterP4
|
||||
withMessage:
|
||||
"{54, 63}: Error(s) parsing property list: {91, 26}: Error(s) parsing table actions: Cannot find b in lexical scope."
|
||||
),
|
||||
Program.Compile(simple_parser_declaration))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ import TreeSitterP4
|
||||
withMessage:
|
||||
"{54, 72}: Error(s) parsing property list: {91, 35}: Error(s) parsing table actions: Cannot find b in lexical scope."
|
||||
),
|
||||
Program.Compile(simple_parser_declaration))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ import TreeSitterP4
|
||||
withMessage:
|
||||
"{64, 63}: Error(s) parsing property list: {101, 26}: Error(s) parsing table actions: {101, 26}: a does not name an action"
|
||||
),
|
||||
Program.Compile(simple_parser_declaration))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ import TreeSitterP4
|
||||
}
|
||||
};
|
||||
"""
|
||||
#expect(#RequireOkResult(Program.Compile(simple_parser_declaration)))
|
||||
#expect(#RequireOkResult(SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration)))
|
||||
}
|
||||
|
||||
@Test func test_simple_control_declaration_with_multiple_tables() async throws {
|
||||
@@ -243,7 +243,7 @@ import TreeSitterP4
|
||||
Error(
|
||||
withMessage: "{0, 215}: More than one table in control declaration"
|
||||
),
|
||||
Program.Compile(simple_parser_declaration))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ import TreeSitterP4
|
||||
}
|
||||
};
|
||||
"""
|
||||
#expect(#RequireOkResult(Program.Compile(simple_parser_declaration)))
|
||||
#expect(#RequireOkResult(SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration)))
|
||||
}
|
||||
|
||||
@Test func test_simple_control_declaration_with_action_using_parameter_wrong_type() async throws {
|
||||
@@ -288,7 +288,7 @@ import TreeSitterP4
|
||||
withMessage:
|
||||
"{57, 10}: Failed to parse a statement element: {57, 1}: Cannot assign value with type Boolean to identifier z with type Int (width: Infinite)"
|
||||
),
|
||||
Program.Compile(simple_parser_declaration))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ import TreeSitterP4
|
||||
withMessage:
|
||||
"Could not compile the P4 program"
|
||||
),
|
||||
Program.Compile(simple_parser_declaration))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ import TreeSitterP4
|
||||
default: false
|
||||
}
|
||||
}
|
||||
let program = try! #UseOkResult(Program.Compile(simple_parser_declaration))
|
||||
let program = try! #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
#expect(program.TypesWithTypes(x).count == 1)
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ import TreeSitterP4
|
||||
ErrorWithLocation(
|
||||
sourceLocation: SourceLocation(41, 23),
|
||||
withError: "All parameters with direction must precede directionless parameters"),
|
||||
Program.Compile(simple_parser_declaration))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -397,6 +397,6 @@ import TreeSitterP4
|
||||
ErrorWithLocation(
|
||||
sourceLocation: SourceLocation(41, 38),
|
||||
withError: "All parameters with direction must precede directionless parameters"),
|
||||
Program.Compile(simple_parser_declaration))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user