Refactor P4Compiler to P4Parser
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
// 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
import Common
|
||||
import SwiftTreeSitter
|
||||
import TreeSitterExtensions
|
||||
import TreeSitterP4
|
||||
|
||||
/*
|
||||
public protocol CompilableValue {
|
||||
static func CompileValue(withValue value: String) -> Result<P4DataValue>
|
||||
}
|
||||
*/
|
||||
|
||||
public protocol MaybeParsableType {
|
||||
static func MaybeParseType(
|
||||
type: SwiftTreeSitter.Node, withContext: CSTCompilerContext
|
||||
) -> Result<CST.Tipe?>
|
||||
}
|
||||
|
||||
public protocol ParsableType {
|
||||
static func ParseType(
|
||||
type: SwiftTreeSitter.Node, withContext: CSTCompilerContext
|
||||
) -> Result<CST.Tipe>
|
||||
}
|
||||
public protocol ParsableExpression {
|
||||
static func ParseExpression(
|
||||
node: Node, withContext context: CSTCompilerContext
|
||||
) -> Result<CST.AnExpression>
|
||||
}
|
||||
|
||||
public protocol Parsable<C> {
|
||||
associatedtype C
|
||||
static func Parse(
|
||||
node: Node, withContext context: CSTCompilerContext
|
||||
) -> Result<C>
|
||||
}
|
||||
|
||||
public protocol ParsableStatement {
|
||||
static func ParseStatement(
|
||||
node: Node, withContext context: CSTCompilerContext
|
||||
) -> Result<CST.Statement>
|
||||
}
|
||||
|
||||
public protocol CSTVisitor<T> {
|
||||
associatedtype T
|
||||
func visit(node: CST.BinaryOperatorExpression, driver: CSTVisitorDriver, context: T) -> Result<T>
|
||||
func visit(node: CST.Literal, driver: CSTVisitorDriver, context: T) -> Result<T>
|
||||
func visit(node: CST.Identifier, driver: CSTVisitorDriver, context: T) -> Result<T>
|
||||
|
||||
func visit(node: CST.Parser, driver: CSTVisitorDriver, context: T) -> Result<T>
|
||||
func visit(
|
||||
node: CST.ParserStateDirectTransition, driver: CSTVisitorDriver, context: T
|
||||
) -> Result<T>
|
||||
func visit(node: CST.ParserStateNoTransition, driver: CSTVisitorDriver, context: T) -> Result<T>
|
||||
func visit(
|
||||
node: CST.ParserStateSelectTransition, driver: CSTVisitorDriver, context: T
|
||||
) -> Result<T>
|
||||
}
|
||||
Reference in New Issue
Block a user