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:
@@ -60,7 +60,7 @@ import TreeSitterP4
|
||||
])))
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(
|
||||
P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(
|
||||
program: program, withGlobalValues: test_values))
|
||||
@@ -91,7 +91,7 @@ import TreeSitterP4
|
||||
test_types = test_types.declare(identifier: Identifier(name: "Testing"), withValue: struct_type)
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(
|
||||
SpecialCompilers.ProgramCompiler.Compile(
|
||||
simple_parser_declaration, withGlobalInstances: .none, withGlobalTypes: test_types))
|
||||
let runtime = try #UseOkResult(
|
||||
P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
|
||||
@@ -124,7 +124,7 @@ import TreeSitterP4
|
||||
identifier: Identifier(name: "Testing"), withValue: struct_type)
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: .none, withGlobalTypes: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: .none, withGlobalTypes: test_declarations))
|
||||
|
||||
let runtime = try #UseOkResult(
|
||||
P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
|
||||
@@ -165,7 +165,7 @@ import TreeSitterP4
|
||||
])))
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(
|
||||
P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(
|
||||
program: program, withGlobalValues: test_values))
|
||||
@@ -205,7 +205,7 @@ import TreeSitterP4
|
||||
])))
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(
|
||||
P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(
|
||||
program: program, withGlobalValues: test_values))
|
||||
@@ -245,7 +245,7 @@ import TreeSitterP4
|
||||
])))
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(
|
||||
P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(
|
||||
program: program, withGlobalValues: test_values))
|
||||
@@ -298,7 +298,7 @@ import TreeSitterP4
|
||||
]))
|
||||
])))
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(
|
||||
P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(
|
||||
program: program, withGlobalValues: test_values))
|
||||
@@ -340,7 +340,7 @@ import TreeSitterP4
|
||||
])))
|
||||
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(
|
||||
P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(
|
||||
program: program, withGlobalValues: test_values))
|
||||
@@ -372,7 +372,7 @@ import TreeSitterP4
|
||||
withMessage:
|
||||
"{49, 13}: Failed to parse a statement element: {49, 8}: Cannot assign value of type Int (width: Infinite) to field yesno of type Boolean"
|
||||
),
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ import TreeSitterP4
|
||||
]))
|
||||
])))
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(
|
||||
P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(
|
||||
program: program, withGlobalValues: test_values))
|
||||
@@ -477,7 +477,7 @@ import TreeSitterP4
|
||||
]))
|
||||
])))
|
||||
let program = try #UseOkResult(
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
let runtime = try #UseOkResult(
|
||||
P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(
|
||||
program: program, withGlobalValues: test_values))
|
||||
@@ -520,7 +520,7 @@ import TreeSitterP4
|
||||
withMessage:
|
||||
"{49, 20}: Failed to parse a statement element: {49, 11}: Cannot assign value of type Boolean to field count of type Int (width: Infinite)"
|
||||
),
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
)
|
||||
|
||||
}
|
||||
@@ -551,6 +551,6 @@ import TreeSitterP4
|
||||
withMessage:
|
||||
"{68, 21}: Could not parse transition select expression selector expression: Types of values used with binary expression are not the same"
|
||||
),
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user