compiler, runtime: Begin Runtime Refactor
Continuous Integration / Grammar Tests (push) Failing after 39s
Continuous Integration / Library Format Tests (push) Successful in 1m46s
Continuous Integration / Library Tests (push) Successful in 4m38s

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:
Will Hawkins
2026-05-29 08:41:49 -04:00
parent 18461a9215
commit 44e93e4cda
30 changed files with 1264 additions and 854 deletions
+21 -1
View File
@@ -18,7 +18,11 @@
import Common
import P4Lang
extension ParserAssignmentStatement: EvaluatableStatement {
extension ParserAssignmentStatement: P4Statement {
public func effect(context: Common.CompilerContext) -> Common.CompilerContext {
return context
}
public func evaluate(execution: ProgramExecution) -> (ControlFlow, ProgramExecution) {
let updated_execution = execution
//let result = self.value.evaluate(execution: updated_execution)
@@ -192,3 +196,19 @@ extension ParserValue: LibraryCallable {
}
}
}
extension ParserState: P4Statement {
public func evaluate(
execution: Common.ProgramExecution
) -> (Common.ControlFlow, Common.ProgramExecution) {
return (
ControlFlow.Error,
execution.setError(error: Error(withMessage: "Cannot evaluate unspecialized parser state"))
)
}
public func effect(context: Common.CompilerContext) -> Common.CompilerContext {
return context.update(
newTypes: context.types.declare(identifier: self.getName(), withValue: self))
}
}