compiler: Refactor Compiler To Remove Ambiguities
Continuous Integration / Grammar Tests (push) Successful in 39s
Continuous Integration / Library Format Tests (push) Successful in 1m51s
Continuous Integration / Library Tests (push) Failing after 4m44s

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:
Will Hawkins
2026-05-27 12:59:29 -04:00
parent 61d8f601e8
commit 294f76acd4
39 changed files with 735 additions and 699 deletions
@@ -41,7 +41,7 @@ import TreeSitterP4
};
"""
let program = try #UseOkResult(Program.Compile(simple))
let program = try #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple))
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
let (state_result, _) = try! #UseOkResult(runtime.run())
@@ -60,7 +60,7 @@ import TreeSitterP4
};
"""
let program = try #UseOkResult(Program.Compile(simple))
let program = try #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple))
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
let (state_result, _) = try! #UseOkResult(runtime.run())
@@ -79,7 +79,7 @@ import TreeSitterP4
};
"""
let program = try #UseOkResult(Program.Compile(simple))
let program = try #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple))
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
let (state_result, _) = try! #UseOkResult(runtime.run())
@@ -98,7 +98,7 @@ import TreeSitterP4
};
"""
let program = try #UseOkResult(Program.Compile(simple))
let program = try #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple))
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
let (state_result, _) = try! #UseOkResult(runtime.run())
@@ -117,7 +117,7 @@ import TreeSitterP4
};
"""
let program = try #UseOkResult(Program.Compile(simple))
let program = try #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple))
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
let (state_result, _) = try! #UseOkResult(runtime.run())
@@ -136,7 +136,7 @@ import TreeSitterP4
};
"""
let program = try #UseOkResult(Program.Compile(simple))
let program = try #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple))
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
let (state_result, _) = try! #UseOkResult(runtime.run())
@@ -155,7 +155,7 @@ import TreeSitterP4
};
"""
let program = try #UseOkResult(Program.Compile(simple))
let program = try #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple))
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
let (state_result, _) = try! #UseOkResult(runtime.run())
@@ -174,7 +174,7 @@ import TreeSitterP4
};
"""
let program = try #UseOkResult(Program.Compile(simple))
let program = try #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple))
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
let (state_result, _) = try! #UseOkResult(runtime.run())
@@ -193,7 +193,7 @@ import TreeSitterP4
};
"""
let program = try #UseOkResult(Program.Compile(simple))
let program = try #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple))
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
let (state_result, _) = try! #UseOkResult(runtime.run())
@@ -212,7 +212,7 @@ import TreeSitterP4
};
"""
let program = try #UseOkResult(Program.Compile(simple))
let program = try #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple))
let runtime = try #UseOkResult(P4Runtime.Runtime<InstantiatedParserState, P4Lang.ParserValue>.create(program: program))
let (state_result, _) = try! #UseOkResult(runtime.run())