@@ -16,8 +16,6 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import Common
|
||||
import P4Lang
|
||||
import P4Runtime
|
||||
import SwiftTreeSitter
|
||||
import TreeSitterExtensions
|
||||
import TreeSitterP4
|
||||
@@ -26,33 +24,44 @@ public protocol CompilableValue {
|
||||
static func CompileValue(withValue value: String) -> Result<P4DataValue>
|
||||
}
|
||||
|
||||
public protocol MaybeCompilableType {
|
||||
static func MaybeCompileType(
|
||||
type: SwiftTreeSitter.Node, withContext: ASTCompilerContext
|
||||
) -> Result<AST.Tipe?>
|
||||
}
|
||||
|
||||
public protocol CompilableType {
|
||||
static func CompileType(
|
||||
type: SwiftTreeSitter.Node, withContext: CompilerContext
|
||||
) -> Result<P4Type?>
|
||||
type: SwiftTreeSitter.Node, withContext: ASTCompilerContext
|
||||
) -> Result<AST.Tipe>
|
||||
}
|
||||
|
||||
public protocol CompilableExpression {
|
||||
static func compile(
|
||||
node: Node, withContext context: CompilerContext
|
||||
) -> Result<P4Expression?>
|
||||
}
|
||||
|
||||
public protocol CompilableLValueExpression {
|
||||
static func compile_as_lvalue(
|
||||
node: Node, withContext context: CompilerContext
|
||||
) -> Result<P4LValueExpression?>
|
||||
static func CompileExpression(
|
||||
node: Node, withContext context: ASTCompilerContext
|
||||
) -> Result<AST.AnExpression>
|
||||
}
|
||||
|
||||
public protocol Compilable<C> {
|
||||
associatedtype C
|
||||
static func Compile(
|
||||
node: Node, withContext context: CompilerContext
|
||||
node: Node, withContext context: ASTCompilerContext
|
||||
) -> Result<C>
|
||||
}
|
||||
|
||||
public protocol CompilableStatement {
|
||||
static func CompileStatement(
|
||||
node: Node, withContext context: CompilerContext
|
||||
) -> Result<P4Statement>
|
||||
node: Node, withContext context: ASTCompilerContext
|
||||
) -> Result<AST.AnStatement>
|
||||
}
|
||||
|
||||
public protocol ASTVisitor<T> {
|
||||
associatedtype T
|
||||
func visit(node: AST.BinaryOperatorExpression, driver: ASTVisitorDriver, context: T) -> Result<T>
|
||||
func visit(node: AST.Literal, driver: ASTVisitorDriver, context: T) -> Result<T>
|
||||
func visit(node: AST.Identifier, driver: ASTVisitorDriver, context: T) -> Result<T>
|
||||
|
||||
func visit(node: AST.Parser, driver: ASTVisitorDriver, context: T) -> Result<T>
|
||||
func visit(node: AST.ParserStateDirectTransition, driver: ASTVisitorDriver, context: T) -> Result<T>
|
||||
func visit(node: AST.ParserStateNoTransition, driver: ASTVisitorDriver, context: T) -> Result<T>
|
||||
func visit(node: AST.ParserStateSelectTransition, driver: ASTVisitorDriver, context: T) -> Result<T>
|
||||
}
|
||||
Reference in New Issue
Block a user