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
+18 -16
View File
@@ -22,12 +22,6 @@ import SwiftTreeSitter
import TreeSitterExtensions
import TreeSitterP4
public protocol CompilableStatement {
static func Compile(
node: Node, withContext context: CompilerContext
) -> Result<(EvaluatableStatement, CompilerContext)>
}
public protocol CompilableValue {
static func CompileValue(withValue value: String) -> Result<P4DataValue>
}
@@ -38,19 +32,27 @@ public protocol CompilableType {
) -> Result<P4Type?>
}
public protocol CompilableDeclaration {
/// Info
///
/// Extensions should update the context with the newly declared item _unless_
/// they are in an extern context (``CompilerContext.extern_context``).
static func Compile(
public protocol CompilableExpression {
static func compile(
node: Node, withContext context: CompilerContext
) -> Result<(Declaration, CompilerContext)?>
) -> Result<P4Expression?>
}
public protocol Compilable<T> {
associatedtype T
public protocol CompilableLValueExpression {
static func compile_as_lvalue(
node: Node, withContext context: CompilerContext
) -> Result<P4LValueExpression?>
}
public protocol Compilable<C> {
associatedtype C
static func Compile(
node: Node, withContext context: CompilerContext
) -> Result<(T, CompilerContext)>
) -> Result<C>
}
public protocol CompilableStatement {
static func CompileStatement(
node: Node, withContext context: CompilerContext
) -> Result<P4Statement>
}