// p4rse, Copyright 2026, Will Hawkins
//
// This file is part of p4rse.
//
// This file is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
import Common
import SwiftTreeSitter
import TreeSitterExtensions
import TreeSitterP4
/*
public protocol CompilableValue {
static func CompileValue(withValue value: String) -> Result
}
*/
public protocol MaybeParsableType {
static func MaybeParseType(
type: SwiftTreeSitter.Node, withContext: CSTCompilerContext
) -> Result
}
public protocol ParsableType {
static func ParseType(
type: SwiftTreeSitter.Node, withContext: CSTCompilerContext
) -> Result
}
public protocol ParsableExpression {
static func ParseExpression(
node: Node, withContext context: CSTCompilerContext
) -> Result
}
public protocol Parsable {
associatedtype C
static func Parse(
node: Node, withContext context: CSTCompilerContext
) -> Result
}
public protocol ParsableStatement {
static func ParseStatement(
node: Node, withContext context: CSTCompilerContext
) -> Result
}
public protocol CSTVisitor {
associatedtype T
// Declarations
func visit(node: CST.Control, driver: CSTVisitorDriver, context: T) -> Result
func visit(node: CST.ExternDeclaration, driver: CSTVisitorDriver, context: T) -> Result
func visit(node: CST.FunctionDeclaration, driver: CSTVisitorDriver, context: T) -> Result
func visit(node: CST.StructDeclaration, driver: CSTVisitorDriver, context: T) -> Result
func visit(node: CST.Parser, driver: CSTVisitorDriver, context: T) -> Result
// Statements
func visit(node: CST.Statements, driver: CSTVisitorDriver, context: T) -> Result
func visit(node: CST.VariableDeclarationStatement, driver: CSTVisitorDriver, context: T) -> Result
func visit(node: CST.ExpressionStatement, driver: CSTVisitorDriver, context: T) -> Result
// Expressions
func visit(node: CST.KeysetExpression, driver: CSTVisitorDriver, context: T) -> Result
func visit(node: CST.SelectCaseExpression, driver: CSTVisitorDriver, context: T) -> Result
func visit(node: CST.SelectExpression, driver: CSTVisitorDriver, context: T) -> Result
func visit(node: CST.BinaryOperatorExpression, driver: CSTVisitorDriver, context: T) -> Result
func visit(node: CST.Literal, driver: CSTVisitorDriver, context: T) -> Result
func visit(node: CST.Identifier, driver: CSTVisitorDriver, context: T) -> Result
// Parser
func visit(
node: CST.ParserStateDirectTransition, driver: CSTVisitorDriver, context: T
) -> Result
func visit(node: CST.ParserStateNoTransition, driver: CSTVisitorDriver, context: T) -> Result
func visit(
node: CST.ParserStateSelectTransition, driver: CSTVisitorDriver, context: T
) -> Result
}