Documentation
¶
Index ¶
- func BasicLit(this any) *ast.BasicLit
- func BinaryExpr(recursive bool, in []any) ast.Expr
- func BinaryExprNR(in []any) ast.Expr
- func BinaryExprR(in []any) ast.Expr
- func BinaryOp(recursive bool, in []any, fn func(op *Token, x, y any) any) any
- func BinaryOpNR(in []any, fn func(op *Token, x, y any) any) any
- func BinaryOpR(in []any, fn func(op *Token, x, y any) any) any
- func Dump(result any, omitSemi ...bool)
- func Fdump(w io.Writer, ret any, prefix, indent string, omitSemi bool)
- func Ident(this any) *ast.Ident
- func List(in []any) []any
- func ListOp[T any](in []any, fn func(v any) T) []T
- func Panic(pos token.Pos, msg string)
- func RangeOp(in []any, fn func(v any))
- func Relocate(err error, filename string, line, col int) error
- func ShowConflict(f bool) int
- func UnaryExpr(in []any) ast.Expr
- type Compiler
- func (p *Compiler) Match(filename string, src any, conf *Config) (ms MatchState, result any, err error)
- func (p *Compiler) Parse(filename string, src any, conf *Config) (result any, err error)
- func (p *Compiler) ParseExpr(x string, conf *Config) (result any, err error)
- func (p *Compiler) ParseExprFrom(filename string, src any, conf *Config) (result any, err error)
- type Config
- type Error
- type MatchState
- type Scanner
- type Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicLit ¶ added in v1.3.7
BasicLit converts the matching result of a basic literal to an ast.BasicLit expression.
func BinaryExpr ¶ added in v1.3.7
BinaryExpr converts the matching result of (X % op) to a binary expression. X % op means X *(op X)
func BinaryExprNR ¶ added in v1.3.7
func BinaryExprR ¶ added in v1.3.7
func Ident ¶ added in v1.3.7
Ident converts the matching result of an identifier to an ast.Ident expression.
func List ¶ added in v1.3.7
List converts the matching result of (R % ",") to a flat list. R % "," means R *("," R)
func ListOp ¶ added in v1.3.9
ListOp converts the matching result of (R % ",") to a flat list. R % "," means R *("," R)
func RangeOp ¶ added in v1.3.7
RangeOp travels the matching result of (R % ",") and call fn(result of R). R % "," means R *("," R)
func ShowConflict ¶ added in v1.3.8
ShowConflict sets the flag to show or hide conflicts.
Types ¶
type Compiler ¶
Compiler represents a TPL compiler.
func FromFile ¶
func FromFile(fset *token.FileSet, filename string, src any, conf *cl.Config) (ret Compiler, err error)
FromFile creates a new TPL compiler from a file. fset can be nil.
func NewEx ¶ added in v1.3.8
NewEx creates a new TPL compiler. params: ruleName1, retProc1, ..., ruleNameN, retProcN
func (*Compiler) Match ¶
func (p *Compiler) Match(filename string, src any, conf *Config) (ms MatchState, result any, err error)
Match matches a source file.
type Config ¶
type Config struct {
Scanner Scanner
ScanErrorHandler scanner.ErrorHandler
ScanMode scanner.Mode
Fset *token.FileSet
}
Config represents a parsing configuration of Compiler.Parse.
type MatchState ¶ added in v1.3.7
MatchState represents a matching state.
func (*MatchState) Next ¶ added in v1.3.7
func (p *MatchState) Next() *Token
Next returns the next token.