Documentation ¶
Overview ¶
Example ¶
package main import ( "bramp.net/antlr4/postalcode" "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" ) type exampleListener struct { *postalcode.BasepostalcodeListener } 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 := postalcode.NewpostalcodeLexer(is) stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel) // Create the Parser p := postalcode.NewpostalcodeParser(stream) p.BuildParseTrees = true p.AddErrorListener(antlr.NewDiagnosticErrorListener(true)) // Finally walk the tree tree := p.Postalcode() antlr.ParseTreeWalkerDefault.Walk(&exampleListener{}, tree) }
Output:
Index ¶
- func NewpostalcodeLexer(input antlr.CharStream) *postalcodeLexer
- func NewpostalcodeParser(input antlr.TokenStream) *postalcodeParser
- type BasepostalcodeListener
- func (s *BasepostalcodeListener) EnterEveryRule(ctx antlr.ParserRuleContext)
- func (s *BasepostalcodeListener) EnterPostalcode(ctx *PostalcodeContext)
- func (s *BasepostalcodeListener) ExitEveryRule(ctx antlr.ParserRuleContext)
- func (s *BasepostalcodeListener) ExitPostalcode(ctx *PostalcodeContext)
- func (s *BasepostalcodeListener) VisitErrorNode(node antlr.ErrorNode)
- func (s *BasepostalcodeListener) VisitTerminal(node antlr.TerminalNode)
- type IPostalcodeContext
- type PostalcodeContext
- func (s *PostalcodeContext) AllDIGIT() []antlr.TerminalNode
- func (s *PostalcodeContext) AllLETTER() []antlr.TerminalNode
- func (s *PostalcodeContext) DIGIT(i int) antlr.TerminalNode
- func (s *PostalcodeContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *PostalcodeContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *PostalcodeContext) GetParser() antlr.Parser
- func (s *PostalcodeContext) GetRuleContext() antlr.RuleContext
- func (*PostalcodeContext) IsPostalcodeContext()
- func (s *PostalcodeContext) LETTER(i int) antlr.TerminalNode
- func (s *PostalcodeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewpostalcodeLexer ¶
func NewpostalcodeLexer(input antlr.CharStream) *postalcodeLexer
func NewpostalcodeParser ¶
func NewpostalcodeParser(input antlr.TokenStream) *postalcodeParser
Types ¶
type BasepostalcodeListener ¶
type BasepostalcodeListener struct{}
BasepostalcodeListener is a complete listener for a parse tree produced by postalcodeParser.
func (*BasepostalcodeListener) EnterEveryRule ¶
func (s *BasepostalcodeListener) EnterEveryRule(ctx antlr.ParserRuleContext)
EnterEveryRule is called when any rule is entered.
func (*BasepostalcodeListener) EnterPostalcode ¶
func (s *BasepostalcodeListener) EnterPostalcode(ctx *PostalcodeContext)
EnterPostalcode is called when production postalcode is entered.
func (*BasepostalcodeListener) ExitEveryRule ¶
func (s *BasepostalcodeListener) ExitEveryRule(ctx antlr.ParserRuleContext)
ExitEveryRule is called when any rule is exited.
func (*BasepostalcodeListener) ExitPostalcode ¶
func (s *BasepostalcodeListener) ExitPostalcode(ctx *PostalcodeContext)
ExitPostalcode is called when production postalcode is exited.
func (*BasepostalcodeListener) VisitErrorNode ¶
func (s *BasepostalcodeListener) VisitErrorNode(node antlr.ErrorNode)
VisitErrorNode is called when an error node is visited.
func (*BasepostalcodeListener) VisitTerminal ¶
func (s *BasepostalcodeListener) VisitTerminal(node antlr.TerminalNode)
VisitTerminal is called when a terminal node is visited.
type IPostalcodeContext ¶
type IPostalcodeContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsPostalcodeContext differentiates from other interfaces. IsPostalcodeContext() }
IPostalcodeContext is an interface to support dynamic dispatch.
type PostalcodeContext ¶
type PostalcodeContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptyPostalcodeContext ¶
func NewEmptyPostalcodeContext() *PostalcodeContext
func NewPostalcodeContext ¶
func NewPostalcodeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PostalcodeContext
func (*PostalcodeContext) AllDIGIT ¶
func (s *PostalcodeContext) AllDIGIT() []antlr.TerminalNode
func (*PostalcodeContext) AllLETTER ¶
func (s *PostalcodeContext) AllLETTER() []antlr.TerminalNode
func (*PostalcodeContext) DIGIT ¶
func (s *PostalcodeContext) DIGIT(i int) antlr.TerminalNode
func (*PostalcodeContext) EnterRule ¶
func (s *PostalcodeContext) EnterRule(listener antlr.ParseTreeListener)
func (*PostalcodeContext) ExitRule ¶
func (s *PostalcodeContext) ExitRule(listener antlr.ParseTreeListener)
func (*PostalcodeContext) GetParser ¶
func (s *PostalcodeContext) GetParser() antlr.Parser
func (*PostalcodeContext) GetRuleContext ¶
func (s *PostalcodeContext) GetRuleContext() antlr.RuleContext
func (*PostalcodeContext) IsPostalcodeContext ¶
func (*PostalcodeContext) IsPostalcodeContext()
func (*PostalcodeContext) LETTER ¶
func (s *PostalcodeContext) LETTER(i int) antlr.TerminalNode
func (*PostalcodeContext) ToStringTree ¶
func (s *PostalcodeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
Click to show internal directories.
Click to hide internal directories.