Documentation ¶
Overview ¶
Example ¶
package main import ( "bramp.net/antlr4/cmake" "fmt" "github.com/antlr/antlr4/runtime/Go/antlr" ) type exampleListener struct { *cmake.BaseCMakeListener } 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 := cmake.NewCMakeLexer(is) stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel) // Create the Parser p := cmake.NewCMakeParser(stream) p.BuildParseTrees = true p.AddErrorListener(antlr.NewDiagnosticErrorListener(true)) // Finally walk the tree tree := p.File() antlr.ParseTreeWalkerDefault.Walk(&exampleListener{}, tree) }
Output:
Index ¶
- Constants
- type BaseCMakeListener
- func (s *BaseCMakeListener) EnterCommand_invocation(ctx *Command_invocationContext)
- func (s *BaseCMakeListener) EnterCompound_argument(ctx *Compound_argumentContext)
- func (s *BaseCMakeListener) EnterEveryRule(ctx antlr.ParserRuleContext)
- func (s *BaseCMakeListener) EnterFile(ctx *FileContext)
- func (s *BaseCMakeListener) EnterSingle_argument(ctx *Single_argumentContext)
- func (s *BaseCMakeListener) ExitCommand_invocation(ctx *Command_invocationContext)
- func (s *BaseCMakeListener) ExitCompound_argument(ctx *Compound_argumentContext)
- func (s *BaseCMakeListener) ExitEveryRule(ctx antlr.ParserRuleContext)
- func (s *BaseCMakeListener) ExitFile(ctx *FileContext)
- func (s *BaseCMakeListener) ExitSingle_argument(ctx *Single_argumentContext)
- func (s *BaseCMakeListener) VisitErrorNode(node antlr.ErrorNode)
- func (s *BaseCMakeListener) VisitTerminal(node antlr.TerminalNode)
- type CMakeLexer
- type CMakeListener
- type CMakeParser
- type Command_invocationContext
- func (s *Command_invocationContext) AllCompound_argument() []ICompound_argumentContext
- func (s *Command_invocationContext) AllSingle_argument() []ISingle_argumentContext
- func (s *Command_invocationContext) Compound_argument(i int) ICompound_argumentContext
- func (s *Command_invocationContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *Command_invocationContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *Command_invocationContext) GetParser() antlr.Parser
- func (s *Command_invocationContext) GetRuleContext() antlr.RuleContext
- func (s *Command_invocationContext) Identifier() antlr.TerminalNode
- func (*Command_invocationContext) IsCommand_invocationContext()
- func (s *Command_invocationContext) Single_argument(i int) ISingle_argumentContext
- func (s *Command_invocationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type Compound_argumentContext
- func (s *Compound_argumentContext) AllCompound_argument() []ICompound_argumentContext
- func (s *Compound_argumentContext) AllSingle_argument() []ISingle_argumentContext
- func (s *Compound_argumentContext) Compound_argument(i int) ICompound_argumentContext
- func (s *Compound_argumentContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *Compound_argumentContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *Compound_argumentContext) GetParser() antlr.Parser
- func (s *Compound_argumentContext) GetRuleContext() antlr.RuleContext
- func (*Compound_argumentContext) IsCompound_argumentContext()
- func (s *Compound_argumentContext) Single_argument(i int) ISingle_argumentContext
- func (s *Compound_argumentContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type FileContext
- func (s *FileContext) AllCommand_invocation() []ICommand_invocationContext
- func (s *FileContext) Command_invocation(i int) ICommand_invocationContext
- func (s *FileContext) EOF() antlr.TerminalNode
- func (s *FileContext) EnterRule(listener antlr.ParseTreeListener)
- 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 ICommand_invocationContext
- type ICompound_argumentContext
- type IFileContext
- type ISingle_argumentContext
- type Single_argumentContext
- func (s *Single_argumentContext) Bracket_argument() antlr.TerminalNode
- func (s *Single_argumentContext) EnterRule(listener antlr.ParseTreeListener)
- func (s *Single_argumentContext) ExitRule(listener antlr.ParseTreeListener)
- func (s *Single_argumentContext) GetParser() antlr.Parser
- func (s *Single_argumentContext) GetRuleContext() antlr.RuleContext
- func (s *Single_argumentContext) Identifier() antlr.TerminalNode
- func (*Single_argumentContext) IsSingle_argumentContext()
- func (s *Single_argumentContext) Quoted_argument() antlr.TerminalNode
- func (s *Single_argumentContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- func (s *Single_argumentContext) Unquoted_argument() antlr.TerminalNode
Examples ¶
Constants ¶
const ( CMakeLexerT__0 = 1 CMakeLexerT__1 = 2 CMakeLexerIdentifier = 3 CMakeLexerUnquoted_argument = 4 CMakeLexerEscape_sequence = 5 CMakeLexerQuoted_argument = 6 CMakeLexerBracket_argument = 7 CMakeLexerBracket_comment = 8 CMakeLexerLine_comment = 9 CMakeLexerNewline = 10 CMakeLexerSpace = 11 )
CMakeLexer tokens.
const ( CMakeParserEOF = antlr.TokenEOF CMakeParserT__0 = 1 CMakeParserT__1 = 2 CMakeParserIdentifier = 3 CMakeParserUnquoted_argument = 4 CMakeParserEscape_sequence = 5 CMakeParserQuoted_argument = 6 CMakeParserBracket_argument = 7 CMakeParserBracket_comment = 8 CMakeParserLine_comment = 9 CMakeParserNewline = 10 CMakeParserSpace = 11 )
CMakeParser tokens.
const ( CMakeParserRULE_file = 0 CMakeParserRULE_command_invocation = 1 CMakeParserRULE_single_argument = 2 CMakeParserRULE_compound_argument = 3 )
CMakeParser rules.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseCMakeListener ¶
type BaseCMakeListener struct{}
BaseCMakeListener is a complete listener for a parse tree produced by CMakeParser.
func (*BaseCMakeListener) EnterCommand_invocation ¶
func (s *BaseCMakeListener) EnterCommand_invocation(ctx *Command_invocationContext)
EnterCommand_invocation is called when production command_invocation is entered.
func (*BaseCMakeListener) EnterCompound_argument ¶
func (s *BaseCMakeListener) EnterCompound_argument(ctx *Compound_argumentContext)
EnterCompound_argument is called when production compound_argument is entered.
func (*BaseCMakeListener) EnterEveryRule ¶
func (s *BaseCMakeListener) EnterEveryRule(ctx antlr.ParserRuleContext)
EnterEveryRule is called when any rule is entered.
func (*BaseCMakeListener) EnterFile ¶
func (s *BaseCMakeListener) EnterFile(ctx *FileContext)
EnterFile is called when production file is entered.
func (*BaseCMakeListener) EnterSingle_argument ¶
func (s *BaseCMakeListener) EnterSingle_argument(ctx *Single_argumentContext)
EnterSingle_argument is called when production single_argument is entered.
func (*BaseCMakeListener) ExitCommand_invocation ¶
func (s *BaseCMakeListener) ExitCommand_invocation(ctx *Command_invocationContext)
ExitCommand_invocation is called when production command_invocation is exited.
func (*BaseCMakeListener) ExitCompound_argument ¶
func (s *BaseCMakeListener) ExitCompound_argument(ctx *Compound_argumentContext)
ExitCompound_argument is called when production compound_argument is exited.
func (*BaseCMakeListener) ExitEveryRule ¶
func (s *BaseCMakeListener) ExitEveryRule(ctx antlr.ParserRuleContext)
ExitEveryRule is called when any rule is exited.
func (*BaseCMakeListener) ExitFile ¶
func (s *BaseCMakeListener) ExitFile(ctx *FileContext)
ExitFile is called when production file is exited.
func (*BaseCMakeListener) ExitSingle_argument ¶
func (s *BaseCMakeListener) ExitSingle_argument(ctx *Single_argumentContext)
ExitSingle_argument is called when production single_argument is exited.
func (*BaseCMakeListener) VisitErrorNode ¶
func (s *BaseCMakeListener) VisitErrorNode(node antlr.ErrorNode)
VisitErrorNode is called when an error node is visited.
func (*BaseCMakeListener) VisitTerminal ¶
func (s *BaseCMakeListener) VisitTerminal(node antlr.TerminalNode)
VisitTerminal is called when a terminal node is visited.
type CMakeLexer ¶
func NewCMakeLexer ¶
func NewCMakeLexer(input antlr.CharStream) *CMakeLexer
type CMakeListener ¶
type CMakeListener interface { antlr.ParseTreeListener // EnterFile is called when entering the file production. EnterFile(c *FileContext) // EnterCommand_invocation is called when entering the command_invocation production. EnterCommand_invocation(c *Command_invocationContext) // EnterSingle_argument is called when entering the single_argument production. EnterSingle_argument(c *Single_argumentContext) // EnterCompound_argument is called when entering the compound_argument production. EnterCompound_argument(c *Compound_argumentContext) // ExitFile is called when exiting the file production. ExitFile(c *FileContext) // ExitCommand_invocation is called when exiting the command_invocation production. ExitCommand_invocation(c *Command_invocationContext) // ExitSingle_argument is called when exiting the single_argument production. ExitSingle_argument(c *Single_argumentContext) // ExitCompound_argument is called when exiting the compound_argument production. ExitCompound_argument(c *Compound_argumentContext) }
CMakeListener is a complete listener for a parse tree produced by CMakeParser.
type CMakeParser ¶
type CMakeParser struct {
*antlr.BaseParser
}
func NewCMakeParser ¶
func NewCMakeParser(input antlr.TokenStream) *CMakeParser
func (*CMakeParser) Command_invocation ¶
func (p *CMakeParser) Command_invocation() (localctx ICommand_invocationContext)
func (*CMakeParser) Compound_argument ¶
func (p *CMakeParser) Compound_argument() (localctx ICompound_argumentContext)
func (*CMakeParser) File ¶
func (p *CMakeParser) File() (localctx IFileContext)
func (*CMakeParser) Single_argument ¶
func (p *CMakeParser) Single_argument() (localctx ISingle_argumentContext)
type Command_invocationContext ¶
type Command_invocationContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewCommand_invocationContext ¶
func NewCommand_invocationContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Command_invocationContext
func NewEmptyCommand_invocationContext ¶
func NewEmptyCommand_invocationContext() *Command_invocationContext
func (*Command_invocationContext) AllCompound_argument ¶
func (s *Command_invocationContext) AllCompound_argument() []ICompound_argumentContext
func (*Command_invocationContext) AllSingle_argument ¶
func (s *Command_invocationContext) AllSingle_argument() []ISingle_argumentContext
func (*Command_invocationContext) Compound_argument ¶
func (s *Command_invocationContext) Compound_argument(i int) ICompound_argumentContext
func (*Command_invocationContext) EnterRule ¶
func (s *Command_invocationContext) EnterRule(listener antlr.ParseTreeListener)
func (*Command_invocationContext) ExitRule ¶
func (s *Command_invocationContext) ExitRule(listener antlr.ParseTreeListener)
func (*Command_invocationContext) GetParser ¶
func (s *Command_invocationContext) GetParser() antlr.Parser
func (*Command_invocationContext) GetRuleContext ¶
func (s *Command_invocationContext) GetRuleContext() antlr.RuleContext
func (*Command_invocationContext) Identifier ¶
func (s *Command_invocationContext) Identifier() antlr.TerminalNode
func (*Command_invocationContext) IsCommand_invocationContext ¶
func (*Command_invocationContext) IsCommand_invocationContext()
func (*Command_invocationContext) Single_argument ¶
func (s *Command_invocationContext) Single_argument(i int) ISingle_argumentContext
func (*Command_invocationContext) ToStringTree ¶
func (s *Command_invocationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type Compound_argumentContext ¶
type Compound_argumentContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewCompound_argumentContext ¶
func NewCompound_argumentContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Compound_argumentContext
func NewEmptyCompound_argumentContext ¶
func NewEmptyCompound_argumentContext() *Compound_argumentContext
func (*Compound_argumentContext) AllCompound_argument ¶
func (s *Compound_argumentContext) AllCompound_argument() []ICompound_argumentContext
func (*Compound_argumentContext) AllSingle_argument ¶
func (s *Compound_argumentContext) AllSingle_argument() []ISingle_argumentContext
func (*Compound_argumentContext) Compound_argument ¶
func (s *Compound_argumentContext) Compound_argument(i int) ICompound_argumentContext
func (*Compound_argumentContext) EnterRule ¶
func (s *Compound_argumentContext) EnterRule(listener antlr.ParseTreeListener)
func (*Compound_argumentContext) ExitRule ¶
func (s *Compound_argumentContext) ExitRule(listener antlr.ParseTreeListener)
func (*Compound_argumentContext) GetParser ¶
func (s *Compound_argumentContext) GetParser() antlr.Parser
func (*Compound_argumentContext) GetRuleContext ¶
func (s *Compound_argumentContext) GetRuleContext() antlr.RuleContext
func (*Compound_argumentContext) IsCompound_argumentContext ¶
func (*Compound_argumentContext) IsCompound_argumentContext()
func (*Compound_argumentContext) Single_argument ¶
func (s *Compound_argumentContext) Single_argument(i int) ISingle_argumentContext
func (*Compound_argumentContext) ToStringTree ¶
func (s *Compound_argumentContext) 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) AllCommand_invocation ¶
func (s *FileContext) AllCommand_invocation() []ICommand_invocationContext
func (*FileContext) Command_invocation ¶
func (s *FileContext) Command_invocation(i int) ICommand_invocationContext
func (*FileContext) EOF ¶
func (s *FileContext) EOF() antlr.TerminalNode
func (*FileContext) EnterRule ¶
func (s *FileContext) EnterRule(listener antlr.ParseTreeListener)
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 ICommand_invocationContext ¶
type ICommand_invocationContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsCommand_invocationContext differentiates from other interfaces. IsCommand_invocationContext() }
ICommand_invocationContext is an interface to support dynamic dispatch.
type ICompound_argumentContext ¶
type ICompound_argumentContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsCompound_argumentContext differentiates from other interfaces. IsCompound_argumentContext() }
ICompound_argumentContext 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 ISingle_argumentContext ¶
type ISingle_argumentContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsSingle_argumentContext differentiates from other interfaces. IsSingle_argumentContext() }
ISingle_argumentContext is an interface to support dynamic dispatch.
type Single_argumentContext ¶
type Single_argumentContext struct { *antlr.BaseParserRuleContext // contains filtered or unexported fields }
func NewEmptySingle_argumentContext ¶
func NewEmptySingle_argumentContext() *Single_argumentContext
func NewSingle_argumentContext ¶
func NewSingle_argumentContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Single_argumentContext
func (*Single_argumentContext) Bracket_argument ¶
func (s *Single_argumentContext) Bracket_argument() antlr.TerminalNode
func (*Single_argumentContext) EnterRule ¶
func (s *Single_argumentContext) EnterRule(listener antlr.ParseTreeListener)
func (*Single_argumentContext) ExitRule ¶
func (s *Single_argumentContext) ExitRule(listener antlr.ParseTreeListener)
func (*Single_argumentContext) GetParser ¶
func (s *Single_argumentContext) GetParser() antlr.Parser
func (*Single_argumentContext) GetRuleContext ¶
func (s *Single_argumentContext) GetRuleContext() antlr.RuleContext
func (*Single_argumentContext) Identifier ¶
func (s *Single_argumentContext) Identifier() antlr.TerminalNode
func (*Single_argumentContext) IsSingle_argumentContext ¶
func (*Single_argumentContext) IsSingle_argumentContext()
func (*Single_argumentContext) Quoted_argument ¶
func (s *Single_argumentContext) Quoted_argument() antlr.TerminalNode
func (*Single_argumentContext) ToStringTree ¶
func (s *Single_argumentContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
func (*Single_argumentContext) Unquoted_argument ¶
func (s *Single_argumentContext) Unquoted_argument() antlr.TerminalNode