Documentation ¶
Overview ¶
Example ¶
package main import ( "bramp.net/antlr4/useragent" "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" ) type exampleListener struct { *useragent.BaseuseragentListener } 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 := useragent.NewuseragentLexer(is) stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel) // Create the Parser p := useragent.NewuseragentParser(stream) p.BuildParseTrees = true p.AddErrorListener(antlr.NewDiagnosticErrorListener(true)) // Finally walk the tree tree := p.Prog() antlr.ParseTreeWalkerDefault.Walk(&exampleListener{}, tree) }
Output:
Index ¶
- func NewuseragentLexer(input antlr.CharStream) *useragentLexer
- func NewuseragentParser(input antlr.TokenStream) *useragentParser
- type BaseuseragentListener
- func (s *BaseuseragentListener) EnterComment(ctx *CommentContext)
- func (s *BaseuseragentListener) EnterEveryRule(ctx antlr.ParserRuleContext)
- func (s *BaseuseragentListener) EnterName(ctx *NameContext)
- func (s *BaseuseragentListener) EnterProduct(ctx *ProductContext)
- func (s *BaseuseragentListener) EnterProg(ctx *ProgContext)
- func (s *BaseuseragentListener) EnterVersion(ctx *VersionContext)
- func (s *BaseuseragentListener) ExitComment(ctx *CommentContext)
- func (s *BaseuseragentListener) ExitEveryRule(ctx antlr.ParserRuleContext)
- func (s *BaseuseragentListener) ExitName(ctx *NameContext)
- func (s *BaseuseragentListener) ExitProduct(ctx *ProductContext)
- func (s *BaseuseragentListener) ExitProg(ctx *ProgContext)
- func (s *BaseuseragentListener) ExitVersion(ctx *VersionContext)
- func (s *BaseuseragentListener) VisitErrorNode(node antlr.ErrorNode)
- func (s *BaseuseragentListener) VisitTerminal(node antlr.TerminalNode)
- type CommentContext
- func (s *CommentContext) COMMENT() antlr.TerminalNode
- func (s *CommentContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *CommentContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *CommentContext) GetParser() antlr.Parser
- func (s *CommentContext) GetRuleContext() antlr.RuleContext
- func (*CommentContext) IsCommentContext()
- func (s *CommentContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type ICommentContext
- type INameContext
- type IProductContext
- type IProgContext
- type IVersionContext
- type NameContext
- func (s *NameContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *NameContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *NameContext) GetParser() antlr.Parser
- func (s *NameContext) GetRuleContext() antlr.RuleContext
- func (*NameContext) IsNameContext()
- func (s *NameContext) STRING() antlr.TerminalNode
- func (s *NameContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type ProductContext
- func (s *ProductContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *ProductContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *ProductContext) GetParser() antlr.Parser
- func (s *ProductContext) GetRuleContext() antlr.RuleContext
- func (*ProductContext) IsProductContext()
- func (s *ProductContext) Name() INameContext
- func (s *ProductContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- func (s *ProductContext) Version() IVersionContext
- type ProgContext
- func (s *ProgContext) AllComment() []ICommentContext
- func (s *ProgContext) AllProduct() []IProductContext
- func (s *ProgContext) Comment(i int) ICommentContext
- func (s *ProgContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *ProgContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *ProgContext) GetParser() antlr.Parser
- func (s *ProgContext) GetRuleContext() antlr.RuleContext
- func (*ProgContext) IsProgContext()
- func (s *ProgContext) Product(i int) IProductContext
- func (s *ProgContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type VersionContext
- func (s *VersionContext) AllSTRING() []antlr.TerminalNode
- func (s *VersionContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *VersionContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *VersionContext) GetParser() antlr.Parser
- func (s *VersionContext) GetRuleContext() antlr.RuleContext
- func (*VersionContext) IsVersionContext()
- func (s *VersionContext) STRING(i int) antlr.TerminalNode
- func (s *VersionContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewuseragentLexer ¶
func NewuseragentLexer(input antlr.CharStream) *useragentLexer
func NewuseragentParser ¶
func NewuseragentParser(input antlr.TokenStream) *useragentParser
Types ¶
type BaseuseragentListener ¶
type BaseuseragentListener struct{}
BaseuseragentListener is a complete listener for a parse tree produced by useragentParser.
func (*BaseuseragentListener) EnterComment ¶
func (s *BaseuseragentListener) EnterComment(ctx *CommentContext)
EnterComment is called when production comment is entered.
func (*BaseuseragentListener) EnterEveryRule ¶
func (s *BaseuseragentListener) EnterEveryRule(ctx antlr.ParserRuleContext)
EnterEveryRule is called when any rule is entered.
func (*BaseuseragentListener) EnterName ¶
func (s *BaseuseragentListener) EnterName(ctx *NameContext)
EnterName is called when production name is entered.
func (*BaseuseragentListener) EnterProduct ¶
func (s *BaseuseragentListener) EnterProduct(ctx *ProductContext)
EnterProduct is called when production product is entered.
func (*BaseuseragentListener) EnterProg ¶
func (s *BaseuseragentListener) EnterProg(ctx *ProgContext)
EnterProg is called when production prog is entered.
func (*BaseuseragentListener) EnterVersion ¶
func (s *BaseuseragentListener) EnterVersion(ctx *VersionContext)
EnterVersion is called when production version is entered.
func (*BaseuseragentListener) ExitComment ¶
func (s *BaseuseragentListener) ExitComment(ctx *CommentContext)
ExitComment is called when production comment is exited.
func (*BaseuseragentListener) ExitEveryRule ¶
func (s *BaseuseragentListener) ExitEveryRule(ctx antlr.ParserRuleContext)
ExitEveryRule is called when any rule is exited.
func (*BaseuseragentListener) ExitName ¶
func (s *BaseuseragentListener) ExitName(ctx *NameContext)
ExitName is called when production name is exited.
func (*BaseuseragentListener) ExitProduct ¶
func (s *BaseuseragentListener) ExitProduct(ctx *ProductContext)
ExitProduct is called when production product is exited.
func (*BaseuseragentListener) ExitProg ¶
func (s *BaseuseragentListener) ExitProg(ctx *ProgContext)
ExitProg is called when production prog is exited.
func (*BaseuseragentListener) ExitVersion ¶
func (s *BaseuseragentListener) ExitVersion(ctx *VersionContext)
ExitVersion is called when production version is exited.
func (*BaseuseragentListener) VisitErrorNode ¶
func (s *BaseuseragentListener) VisitErrorNode(node antlr.ErrorNode)
VisitErrorNode is called when an error node is visited.
func (*BaseuseragentListener) VisitTerminal ¶
func (s *BaseuseragentListener) VisitTerminal(node antlr.TerminalNode)
VisitTerminal is called when a terminal node is visited.
type CommentContext ¶
type CommentContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewCommentContext ¶
func NewCommentContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CommentContext
func NewEmptyCommentContext ¶
func NewEmptyCommentContext() *CommentContext
func (*CommentContext) COMMENT ¶
func (s *CommentContext) COMMENT() antlr.TerminalNode
func (*CommentContext) EnterRule ¶
func (s *CommentContext) EnterRule(listener antlr.ParseTreeListener)
func (*CommentContext) ExitRule ¶
func (s *CommentContext) ExitRule(listener antlr.ParseTreeListener)
func (*CommentContext) GetParser ¶
func (s *CommentContext) GetParser() antlr.Parser
func (*CommentContext) GetRuleContext ¶
func (s *CommentContext) GetRuleContext() antlr.RuleContext
func (*CommentContext) IsCommentContext ¶
func (*CommentContext) IsCommentContext()
func (*CommentContext) ToStringTree ¶
func (s *CommentContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type ICommentContext ¶
type ICommentContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsCommentContext differentiates from other interfaces. IsCommentContext() }
ICommentContext is an interface to support dynamic dispatch.
type INameContext ¶
type INameContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsNameContext differentiates from other interfaces. IsNameContext() }
INameContext is an interface to support dynamic dispatch.
type IProductContext ¶
type IProductContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsProductContext differentiates from other interfaces. IsProductContext() }
IProductContext is an interface to support dynamic dispatch.
type IProgContext ¶
type IProgContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsProgContext differentiates from other interfaces. IsProgContext() }
IProgContext is an interface to support dynamic dispatch.
type IVersionContext ¶
type IVersionContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsVersionContext differentiates from other interfaces. IsVersionContext() }
IVersionContext is an interface to support dynamic dispatch.
type NameContext ¶
type NameContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptyNameContext ¶
func NewEmptyNameContext() *NameContext
func NewNameContext ¶
func NewNameContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *NameContext
func (*NameContext) EnterRule ¶
func (s *NameContext) EnterRule(listener antlr.ParseTreeListener)
func (*NameContext) ExitRule ¶
func (s *NameContext) ExitRule(listener antlr.ParseTreeListener)
func (*NameContext) GetParser ¶
func (s *NameContext) GetParser() antlr.Parser
func (*NameContext) GetRuleContext ¶
func (s *NameContext) GetRuleContext() antlr.RuleContext
func (*NameContext) IsNameContext ¶
func (*NameContext) IsNameContext()
func (*NameContext) STRING ¶
func (s *NameContext) STRING() antlr.TerminalNode
func (*NameContext) ToStringTree ¶
func (s *NameContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type ProductContext ¶
type ProductContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptyProductContext ¶
func NewEmptyProductContext() *ProductContext
func NewProductContext ¶
func NewProductContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ProductContext
func (*ProductContext) EnterRule ¶
func (s *ProductContext) EnterRule(listener antlr.ParseTreeListener)
func (*ProductContext) ExitRule ¶
func (s *ProductContext) ExitRule(listener antlr.ParseTreeListener)
func (*ProductContext) GetParser ¶
func (s *ProductContext) GetParser() antlr.Parser
func (*ProductContext) GetRuleContext ¶
func (s *ProductContext) GetRuleContext() antlr.RuleContext
func (*ProductContext) IsProductContext ¶
func (*ProductContext) IsProductContext()
func (*ProductContext) Name ¶
func (s *ProductContext) Name() INameContext
func (*ProductContext) ToStringTree ¶
func (s *ProductContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
func (*ProductContext) Version ¶
func (s *ProductContext) Version() IVersionContext
type ProgContext ¶
type ProgContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptyProgContext ¶
func NewEmptyProgContext() *ProgContext
func NewProgContext ¶
func NewProgContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ProgContext
func (*ProgContext) AllComment ¶
func (s *ProgContext) AllComment() []ICommentContext
func (*ProgContext) AllProduct ¶
func (s *ProgContext) AllProduct() []IProductContext
func (*ProgContext) Comment ¶
func (s *ProgContext) Comment(i int) ICommentContext
func (*ProgContext) EnterRule ¶
func (s *ProgContext) EnterRule(listener antlr.ParseTreeListener)
func (*ProgContext) ExitRule ¶
func (s *ProgContext) ExitRule(listener antlr.ParseTreeListener)
func (*ProgContext) GetParser ¶
func (s *ProgContext) GetParser() antlr.Parser
func (*ProgContext) GetRuleContext ¶
func (s *ProgContext) GetRuleContext() antlr.RuleContext
func (*ProgContext) IsProgContext ¶
func (*ProgContext) IsProgContext()
func (*ProgContext) Product ¶
func (s *ProgContext) Product(i int) IProductContext
func (*ProgContext) ToStringTree ¶
func (s *ProgContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type VersionContext ¶
type VersionContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptyVersionContext ¶
func NewEmptyVersionContext() *VersionContext
func NewVersionContext ¶
func NewVersionContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *VersionContext
func (*VersionContext) AllSTRING ¶
func (s *VersionContext) AllSTRING() []antlr.TerminalNode
func (*VersionContext) EnterRule ¶
func (s *VersionContext) EnterRule(listener antlr.ParseTreeListener)
func (*VersionContext) ExitRule ¶
func (s *VersionContext) ExitRule(listener antlr.ParseTreeListener)
func (*VersionContext) GetParser ¶
func (s *VersionContext) GetParser() antlr.Parser
func (*VersionContext) GetRuleContext ¶
func (s *VersionContext) GetRuleContext() antlr.RuleContext
func (*VersionContext) IsVersionContext ¶
func (*VersionContext) IsVersionContext()
func (*VersionContext) STRING ¶
func (s *VersionContext) STRING(i int) antlr.TerminalNode
func (*VersionContext) ToStringTree ¶
func (s *VersionContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string