compiler, runtime: Begin Runtime Refactor
Ultimately, the goal is to completely separate the compilation from the runtime to make it possible to have the interpreter/evaluator be "just another" entity that can perform meaningful work when given a parsed GP4 program. Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -95,7 +95,7 @@ import P4Lang
|
||||
let result = try! #require(p.parse(simple))
|
||||
|
||||
#expect(
|
||||
#RequireErrorResult<(EvaluatableStatement, CompilerContext)>(
|
||||
#RequireErrorResult<ParserAssignmentStatement>(
|
||||
ErrorWithLocation(sourceLocation: SourceLocation(2, 154), withError: "Did not find assignment statement"),
|
||||
ParserAssignmentStatement.Compile( // Note: Calling ParserAssignmentStatement compilation directly.
|
||||
node: result.rootNode!, withContext: CompilerContext())))
|
||||
@@ -182,3 +182,16 @@ import P4Lang
|
||||
|
||||
#expect(#RequireOkResult(SpecialCompilers.ProgramCompiler.Compile(simple)))
|
||||
}
|
||||
|
||||
@Test func test_simple_compiler_with_instantiation() async throws {
|
||||
let simple_instantiation_program = """
|
||||
parser MainParser() {
|
||||
state start {
|
||||
transition accept;
|
||||
}
|
||||
};
|
||||
|
||||
MainParser() mp;
|
||||
"""
|
||||
#expect(#RequireOkResult(SpecialCompilers.ProgramCompiler.Compile(simple_instantiation_program)))
|
||||
}
|
||||
Reference in New Issue
Block a user