Versions in this module Expand all Collapse all v0 v0.6.0 Nov 9, 2022 Changes in this version + const NodeTypeError + const NodeTypeNonTerminal + const NodeTypeTerminal + func GenParser(cgram *spec.CompiledGrammar, pkgName string) ([]byte, error) + func GenSemanticAction(pkgName string) ([]byte, error) + func NewGrammar(g *spec.CompiledGrammar) *grammarImpl + func PrintTree(w io.Writer, node *Node) + type DefaulSyntaxTreeBuilder struct + func NewDefaultSyntaxTreeBuilder() *DefaulSyntaxTreeBuilder + func (b *DefaulSyntaxTreeBuilder) Accept(f SyntaxTreeNode) + func (b *DefaulSyntaxTreeBuilder) Reduce(kindName string, children []SyntaxTreeNode) SyntaxTreeNode + func (b *DefaulSyntaxTreeBuilder) Shift(kindName string, text string, row, col int) SyntaxTreeNode + func (b *DefaulSyntaxTreeBuilder) ShiftError(kindName string) SyntaxTreeNode + func (b *DefaulSyntaxTreeBuilder) Tree() *Node + type Grammar interface + ASTAction func(prod int) []int + Action func(state int, terminal int) int + AlternativeSymbolCount func(prod int) int + EOF func() int + Error func() int + ErrorTrapperState func(state int) bool + GoTo func(state int, lhs int) int + InitialState func() int + LHS func(prod int) int + NonTerminal func(nonTerminal int) string + RecoverProduction func(prod int) bool + SkipTerminal func(terminal int) bool + StartProduction func() int + Terminal func(terminal int) string + TerminalCount func() int + type Node struct + Children []*Node + Col int + KindName string + Row int + Text string + Type NodeType + func (n *Node) ChildCount() int + func (n *Node) ExpandChildren() []SyntaxTreeNode + func (n *Node) MarshalJSON() ([]byte, error) + type NodeType int + type Parser struct + func NewParser(toks TokenStream, gram Grammar, opts ...ParserOption) (*Parser, error) + func (p *Parser) Parse() error + func (p *Parser) SyntaxErrors() []*SyntaxError + type ParserOption func(p *Parser) error + func DisableLAC() ParserOption + func SemanticAction(semAct SemanticActionSet) ParserOption + type SemanticActionSet interface + Accept func() + MissError func(cause VToken) + Reduce func(prodNum int, recovered bool) + Shift func(tok VToken, recovered bool) + TrapAndShiftError func(cause VToken, popped int) + type SyntaxError struct + Col int + ExpectedTerminals []string + Message string + Row int + Token VToken + type SyntaxTreeActionSet struct + func NewASTActionSet(gram Grammar, builder SyntaxTreeBuilder) *SyntaxTreeActionSet + func NewCSTActionSet(gram Grammar, builder SyntaxTreeBuilder) *SyntaxTreeActionSet + func (a *SyntaxTreeActionSet) Accept() + func (a *SyntaxTreeActionSet) MissError(cause VToken) + func (a *SyntaxTreeActionSet) Reduce(prodNum int, recovered bool) + func (a *SyntaxTreeActionSet) Shift(tok VToken, recovered bool) + func (a *SyntaxTreeActionSet) TrapAndShiftError(cause VToken, popped int) + type SyntaxTreeBuilder interface + Accept func(f SyntaxTreeNode) + Reduce func(kindName string, children []SyntaxTreeNode) SyntaxTreeNode + Shift func(kindName string, text string, row, col int) SyntaxTreeNode + ShiftError func(kindName string) SyntaxTreeNode + type SyntaxTreeNode interface + ChildCount func() int + ExpandChildren func() []SyntaxTreeNode + type TokenStream interface + Next func() (VToken, error) + func NewTokenStream(g *spec.CompiledGrammar, src io.Reader) (TokenStream, error) + type VToken interface + EOF func() bool + Invalid func() bool + Lexeme func() []byte + Position func() (int, int) + TerminalID func() int