Documentation ¶
Overview ¶
Example ¶
package main import ( "bramp.net/antlr4/arithmetic" "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" ) type exampleListener struct { *arithmetic.BasearithmeticListener } func (l *exampleListener) EnterEveryRule(ctx antlr.ParserRuleContext) { fmt.Println(ctx.GetText()) } func main() { // Setup the input is := antlr.NewInputStream("...some text to parse...") // Create the Lexer lexer := arithmetic.NewarithmeticLexer(is) stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel) // Create the Parser p := arithmetic.NewarithmeticParser(stream) p.BuildParseTrees = true p.AddErrorListener(antlr.NewDiagnosticErrorListener(true)) // Finally walk the tree tree := p.Equation() antlr.ParseTreeWalkerDefault.Walk(&exampleListener{}, tree) }
Output:
Index ¶
- func NewarithmeticLexer(input antlr.CharStream) *arithmeticLexer
- func NewarithmeticParser(input antlr.TokenStream) *arithmeticParser
- type AtomContext
- func (s *AtomContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *AtomContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *AtomContext) GetParser() antlr.Parser
- func (s *AtomContext) GetRuleContext() antlr.RuleContext
- func (*AtomContext) IsAtomContext()
- func (s *AtomContext) Scientific() IScientificContext
- func (s *AtomContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- func (s *AtomContext) Variable() IVariableContext
- type BasearithmeticListener
- func (s *BasearithmeticListener) EnterAtom(ctx *AtomContext)
- func (s *BasearithmeticListener) EnterEquation(ctx *EquationContext)
- func (s *BasearithmeticListener) EnterEveryRule(ctx antlr.ParserRuleContext)
- func (s *BasearithmeticListener) EnterExpression(ctx *ExpressionContext)
- func (s *BasearithmeticListener) EnterFile(ctx *FileContext)
- func (s *BasearithmeticListener) EnterRelop(ctx *RelopContext)
- func (s *BasearithmeticListener) EnterScientific(ctx *ScientificContext)
- func (s *BasearithmeticListener) EnterVariable(ctx *VariableContext)
- func (s *BasearithmeticListener) ExitAtom(ctx *AtomContext)
- func (s *BasearithmeticListener) ExitEquation(ctx *EquationContext)
- func (s *BasearithmeticListener) ExitEveryRule(ctx antlr.ParserRuleContext)
- func (s *BasearithmeticListener) ExitExpression(ctx *ExpressionContext)
- func (s *BasearithmeticListener) ExitFile(ctx *FileContext)
- func (s *BasearithmeticListener) ExitRelop(ctx *RelopContext)
- func (s *BasearithmeticListener) ExitScientific(ctx *ScientificContext)
- func (s *BasearithmeticListener) ExitVariable(ctx *VariableContext)
- func (s *BasearithmeticListener) VisitErrorNode(node antlr.ErrorNode)
- func (s *BasearithmeticListener) VisitTerminal(node antlr.TerminalNode)
- type EquationContext
- func (s *EquationContext) AllExpression() []IExpressionContext
- func (s *EquationContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *EquationContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *EquationContext) Expression(i int) IExpressionContext
- func (s *EquationContext) GetParser() antlr.Parser
- func (s *EquationContext) GetRuleContext() antlr.RuleContext
- func (*EquationContext) IsEquationContext()
- func (s *EquationContext) Relop() IRelopContext
- func (s *EquationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type ExpressionContext
- func (s *ExpressionContext) AllExpression() []IExpressionContext
- func (s *ExpressionContext) AllMINUS() []antlr.TerminalNode
- func (s *ExpressionContext) AllPLUS() []antlr.TerminalNode
- func (s *ExpressionContext) Atom() IAtomContext
- func (s *ExpressionContext) DIV() antlr.TerminalNode
- func (s *ExpressionContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *ExpressionContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *ExpressionContext) Expression(i int) IExpressionContext
- func (s *ExpressionContext) GetParser() antlr.Parser
- func (s *ExpressionContext) GetRuleContext() antlr.RuleContext
- func (*ExpressionContext) IsExpressionContext()
- func (s *ExpressionContext) LPAREN() antlr.TerminalNode
- func (s *ExpressionContext) MINUS(i int) antlr.TerminalNode
- func (s *ExpressionContext) PLUS(i int) antlr.TerminalNode
- func (s *ExpressionContext) POW() antlr.TerminalNode
- func (s *ExpressionContext) RPAREN() antlr.TerminalNode
- func (s *ExpressionContext) TIMES() antlr.TerminalNode
- func (s *ExpressionContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type FileContext
- func (s *FileContext) AllEquation() []IEquationContext
- func (s *FileContext) EOF() antlr.TerminalNode
- func (s *FileContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *FileContext) Equation(i int) IEquationContext
- func (s *FileContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *FileContext) GetParser() antlr.Parser
- func (s *FileContext) GetRuleContext() antlr.RuleContext
- func (*FileContext) IsFileContext()
- func (s *FileContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type IAtomContext
- type IEquationContext
- type IExpressionContext
- type IFileContext
- type IRelopContext
- type IScientificContext
- type IVariableContext
- type RelopContext
- func (s *RelopContext) EQ() antlr.TerminalNode
- func (s *RelopContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *RelopContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *RelopContext) GT() antlr.TerminalNode
- func (s *RelopContext) GetParser() antlr.Parser
- func (s *RelopContext) GetRuleContext() antlr.RuleContext
- func (*RelopContext) IsRelopContext()
- func (s *RelopContext) LT() antlr.TerminalNode
- func (s *RelopContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type ScientificContext
- func (s *ScientificContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *ScientificContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *ScientificContext) GetParser() antlr.Parser
- func (s *ScientificContext) GetRuleContext() antlr.RuleContext
- func (*ScientificContext) IsScientificContext()
- func (s *ScientificContext) SCIENTIFIC_NUMBER() antlr.TerminalNode
- func (s *ScientificContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type VariableContext
- func (s *VariableContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *VariableContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *VariableContext) GetParser() antlr.Parser
- func (s *VariableContext) GetRuleContext() antlr.RuleContext
- func (*VariableContext) IsVariableContext()
- func (s *VariableContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- func (s *VariableContext) VARIABLE() antlr.TerminalNode
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewarithmeticLexer ¶
func NewarithmeticLexer(input antlr.CharStream) *arithmeticLexer
func NewarithmeticParser ¶
func NewarithmeticParser(input antlr.TokenStream) *arithmeticParser
Types ¶
type AtomContext ¶
type AtomContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewAtomContext ¶
func NewAtomContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtomContext
func NewEmptyAtomContext ¶
func NewEmptyAtomContext() *AtomContext
func (*AtomContext) EnterRule ¶
func (s *AtomContext) EnterRule(listener antlr.ParseTreeListener)
func (*AtomContext) ExitRule ¶
func (s *AtomContext) ExitRule(listener antlr.ParseTreeListener)
func (*AtomContext) GetParser ¶
func (s *AtomContext) GetParser() antlr.Parser
func (*AtomContext) GetRuleContext ¶
func (s *AtomContext) GetRuleContext() antlr.RuleContext
func (*AtomContext) IsAtomContext ¶
func (*AtomContext) IsAtomContext()
func (*AtomContext) Scientific ¶
func (s *AtomContext) Scientific() IScientificContext
func (*AtomContext) ToStringTree ¶
func (s *AtomContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
func (*AtomContext) Variable ¶
func (s *AtomContext) Variable() IVariableContext
type BasearithmeticListener ¶
type BasearithmeticListener struct{}
BasearithmeticListener is a complete listener for a parse tree produced by arithmeticParser.
func (*BasearithmeticListener) EnterAtom ¶
func (s *BasearithmeticListener) EnterAtom(ctx *AtomContext)
EnterAtom is called when production atom is entered.
func (*BasearithmeticListener) EnterEquation ¶
func (s *BasearithmeticListener) EnterEquation(ctx *EquationContext)
EnterEquation is called when production equation is entered.
func (*BasearithmeticListener) EnterEveryRule ¶
func (s *BasearithmeticListener) EnterEveryRule(ctx antlr.ParserRuleContext)
EnterEveryRule is called when any rule is entered.
func (*BasearithmeticListener) EnterExpression ¶
func (s *BasearithmeticListener) EnterExpression(ctx *ExpressionContext)
EnterExpression is called when production expression is entered.
func (*BasearithmeticListener) EnterFile ¶
func (s *BasearithmeticListener) EnterFile(ctx *FileContext)
EnterFile is called when production file is entered.
func (*BasearithmeticListener) EnterRelop ¶
func (s *BasearithmeticListener) EnterRelop(ctx *RelopContext)
EnterRelop is called when production relop is entered.
func (*BasearithmeticListener) EnterScientific ¶
func (s *BasearithmeticListener) EnterScientific(ctx *ScientificContext)
EnterScientific is called when production scientific is entered.
func (*BasearithmeticListener) EnterVariable ¶
func (s *BasearithmeticListener) EnterVariable(ctx *VariableContext)
EnterVariable is called when production variable is entered.
func (*BasearithmeticListener) ExitAtom ¶
func (s *BasearithmeticListener) ExitAtom(ctx *AtomContext)
ExitAtom is called when production atom is exited.
func (*BasearithmeticListener) ExitEquation ¶
func (s *BasearithmeticListener) ExitEquation(ctx *EquationContext)
ExitEquation is called when production equation is exited.
func (*BasearithmeticListener) ExitEveryRule ¶
func (s *BasearithmeticListener) ExitEveryRule(ctx antlr.ParserRuleContext)
ExitEveryRule is called when any rule is exited.
func (*BasearithmeticListener) ExitExpression ¶
func (s *BasearithmeticListener) ExitExpression(ctx *ExpressionContext)
ExitExpression is called when production expression is exited.
func (*BasearithmeticListener) ExitFile ¶
func (s *BasearithmeticListener) ExitFile(ctx *FileContext)
ExitFile is called when production file is exited.
func (*BasearithmeticListener) ExitRelop ¶
func (s *BasearithmeticListener) ExitRelop(ctx *RelopContext)
ExitRelop is called when production relop is exited.
func (*BasearithmeticListener) ExitScientific ¶
func (s *BasearithmeticListener) ExitScientific(ctx *ScientificContext)
ExitScientific is called when production scientific is exited.
func (*BasearithmeticListener) ExitVariable ¶
func (s *BasearithmeticListener) ExitVariable(ctx *VariableContext)
ExitVariable is called when production variable is exited.
func (*BasearithmeticListener) VisitErrorNode ¶
func (s *BasearithmeticListener) VisitErrorNode(node antlr.ErrorNode)
VisitErrorNode is called when an error node is visited.
func (*BasearithmeticListener) VisitTerminal ¶
func (s *BasearithmeticListener) VisitTerminal(node antlr.TerminalNode)
VisitTerminal is called when a terminal node is visited.
type EquationContext ¶
type EquationContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptyEquationContext ¶
func NewEmptyEquationContext() *EquationContext
func NewEquationContext ¶
func NewEquationContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *EquationContext
func (*EquationContext) AllExpression ¶
func (s *EquationContext) AllExpression() []IExpressionContext
func (*EquationContext) EnterRule ¶
func (s *EquationContext) EnterRule(listener antlr.ParseTreeListener)
func (*EquationContext) ExitRule ¶
func (s *EquationContext) ExitRule(listener antlr.ParseTreeListener)
func (*EquationContext) Expression ¶
func (s *EquationContext) Expression(i int) IExpressionContext
func (*EquationContext) GetParser ¶
func (s *EquationContext) GetParser() antlr.Parser
func (*EquationContext) GetRuleContext ¶
func (s *EquationContext) GetRuleContext() antlr.RuleContext
func (*EquationContext) IsEquationContext ¶
func (*EquationContext) IsEquationContext()
func (*EquationContext) Relop ¶
func (s *EquationContext) Relop() IRelopContext
func (*EquationContext) ToStringTree ¶
func (s *EquationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type ExpressionContext ¶
type ExpressionContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptyExpressionContext ¶
func NewEmptyExpressionContext() *ExpressionContext
func NewExpressionContext ¶
func NewExpressionContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExpressionContext
func (*ExpressionContext) AllExpression ¶
func (s *ExpressionContext) AllExpression() []IExpressionContext
func (*ExpressionContext) AllMINUS ¶
func (s *ExpressionContext) AllMINUS() []antlr.TerminalNode
func (*ExpressionContext) AllPLUS ¶
func (s *ExpressionContext) AllPLUS() []antlr.TerminalNode
func (*ExpressionContext) Atom ¶
func (s *ExpressionContext) Atom() IAtomContext
func (*ExpressionContext) DIV ¶
func (s *ExpressionContext) DIV() antlr.TerminalNode
func (*ExpressionContext) EnterRule ¶
func (s *ExpressionContext) EnterRule(listener antlr.ParseTreeListener)
func (*ExpressionContext) ExitRule ¶
func (s *ExpressionContext) ExitRule(listener antlr.ParseTreeListener)
func (*ExpressionContext) Expression ¶
func (s *ExpressionContext) Expression(i int) IExpressionContext
func (*ExpressionContext) GetParser ¶
func (s *ExpressionContext) GetParser() antlr.Parser
func (*ExpressionContext) GetRuleContext ¶
func (s *ExpressionContext) GetRuleContext() antlr.RuleContext
func (*ExpressionContext) IsExpressionContext ¶
func (*ExpressionContext) IsExpressionContext()
func (*ExpressionContext) LPAREN ¶
func (s *ExpressionContext) LPAREN() antlr.TerminalNode
func (*ExpressionContext) MINUS ¶
func (s *ExpressionContext) MINUS(i int) antlr.TerminalNode
func (*ExpressionContext) PLUS ¶
func (s *ExpressionContext) PLUS(i int) antlr.TerminalNode
func (*ExpressionContext) POW ¶
func (s *ExpressionContext) POW() antlr.TerminalNode
func (*ExpressionContext) RPAREN ¶
func (s *ExpressionContext) RPAREN() antlr.TerminalNode
func (*ExpressionContext) TIMES ¶
func (s *ExpressionContext) TIMES() antlr.TerminalNode
func (*ExpressionContext) ToStringTree ¶
func (s *ExpressionContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type FileContext ¶
type FileContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptyFileContext ¶
func NewEmptyFileContext() *FileContext
func NewFileContext ¶
func NewFileContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FileContext
func (*FileContext) AllEquation ¶
func (s *FileContext) AllEquation() []IEquationContext
func (*FileContext) EOF ¶
func (s *FileContext) EOF() antlr.TerminalNode
func (*FileContext) EnterRule ¶
func (s *FileContext) EnterRule(listener antlr.ParseTreeListener)
func (*FileContext) Equation ¶
func (s *FileContext) Equation(i int) IEquationContext
func (*FileContext) ExitRule ¶
func (s *FileContext) ExitRule(listener antlr.ParseTreeListener)
func (*FileContext) GetParser ¶
func (s *FileContext) GetParser() antlr.Parser
func (*FileContext) GetRuleContext ¶
func (s *FileContext) GetRuleContext() antlr.RuleContext
func (*FileContext) IsFileContext ¶
func (*FileContext) IsFileContext()
func (*FileContext) ToStringTree ¶
func (s *FileContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type IAtomContext ¶
type IAtomContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsAtomContext differentiates from other interfaces. IsAtomContext() }
IAtomContext is an interface to support dynamic dispatch.
type IEquationContext ¶
type IEquationContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsEquationContext differentiates from other interfaces. IsEquationContext() }
IEquationContext is an interface to support dynamic dispatch.
type IExpressionContext ¶
type IExpressionContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsExpressionContext differentiates from other interfaces. IsExpressionContext() }
IExpressionContext is an interface to support dynamic dispatch.
type IFileContext ¶
type IFileContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsFileContext differentiates from other interfaces. IsFileContext() }
IFileContext is an interface to support dynamic dispatch.
type IRelopContext ¶
type IRelopContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsRelopContext differentiates from other interfaces. IsRelopContext() }
IRelopContext is an interface to support dynamic dispatch.
type IScientificContext ¶
type IScientificContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsScientificContext differentiates from other interfaces. IsScientificContext() }
IScientificContext is an interface to support dynamic dispatch.
type IVariableContext ¶
type IVariableContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsVariableContext differentiates from other interfaces. IsVariableContext() }
IVariableContext is an interface to support dynamic dispatch.
type RelopContext ¶
type RelopContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptyRelopContext ¶
func NewEmptyRelopContext() *RelopContext
func NewRelopContext ¶
func NewRelopContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RelopContext
func (*RelopContext) EQ ¶
func (s *RelopContext) EQ() antlr.TerminalNode
func (*RelopContext) EnterRule ¶
func (s *RelopContext) EnterRule(listener antlr.ParseTreeListener)
func (*RelopContext) ExitRule ¶
func (s *RelopContext) ExitRule(listener antlr.ParseTreeListener)
func (*RelopContext) GT ¶
func (s *RelopContext) GT() antlr.TerminalNode
func (*RelopContext) GetParser ¶
func (s *RelopContext) GetParser() antlr.Parser
func (*RelopContext) GetRuleContext ¶
func (s *RelopContext) GetRuleContext() antlr.RuleContext
func (*RelopContext) IsRelopContext ¶
func (*RelopContext) IsRelopContext()
func (*RelopContext) LT ¶
func (s *RelopContext) LT() antlr.TerminalNode
func (*RelopContext) ToStringTree ¶
func (s *RelopContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type ScientificContext ¶
type ScientificContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptyScientificContext ¶
func NewEmptyScientificContext() *ScientificContext
func NewScientificContext ¶
func NewScientificContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ScientificContext
func (*ScientificContext) EnterRule ¶
func (s *ScientificContext) EnterRule(listener antlr.ParseTreeListener)
func (*ScientificContext) ExitRule ¶
func (s *ScientificContext) ExitRule(listener antlr.ParseTreeListener)
func (*ScientificContext) GetParser ¶
func (s *ScientificContext) GetParser() antlr.Parser
func (*ScientificContext) GetRuleContext ¶
func (s *ScientificContext) GetRuleContext() antlr.RuleContext
func (*ScientificContext) IsScientificContext ¶
func (*ScientificContext) IsScientificContext()
func (*ScientificContext) SCIENTIFIC_NUMBER ¶
func (s *ScientificContext) SCIENTIFIC_NUMBER() antlr.TerminalNode
func (*ScientificContext) ToStringTree ¶
func (s *ScientificContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type VariableContext ¶
type VariableContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptyVariableContext ¶
func NewEmptyVariableContext() *VariableContext
func NewVariableContext ¶
func NewVariableContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *VariableContext
func (*VariableContext) EnterRule ¶
func (s *VariableContext) EnterRule(listener antlr.ParseTreeListener)
func (*VariableContext) ExitRule ¶
func (s *VariableContext) ExitRule(listener antlr.ParseTreeListener)
func (*VariableContext) GetParser ¶
func (s *VariableContext) GetParser() antlr.Parser
func (*VariableContext) GetRuleContext ¶
func (s *VariableContext) GetRuleContext() antlr.RuleContext
func (*VariableContext) IsVariableContext ¶
func (*VariableContext) IsVariableContext()
func (*VariableContext) ToStringTree ¶
func (s *VariableContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
func (*VariableContext) VARIABLE ¶
func (s *VariableContext) VARIABLE() antlr.TerminalNode