forked from jasder/antlr
Add interface build checks for tree types and generated base listeners
This commit is contained in:
parent
28e013e687
commit
7f42bc602b
|
@ -56,6 +56,8 @@ type ParseTreeVisitor interface {
|
|||
|
||||
type BaseParseTreeVisitor struct{}
|
||||
|
||||
var _ ParseTreeVisitor = &BaseParseTreeVisitor{}
|
||||
|
||||
func (v *BaseParseTreeVisitor) Visit(tree ParseTree) interface{} { return nil }
|
||||
func (v *BaseParseTreeVisitor) VisitChildren(node RuleNode) interface{} { return nil }
|
||||
func (v *BaseParseTreeVisitor) VisitTerminal(node TerminalNode) interface{} { return nil }
|
||||
|
@ -91,6 +93,8 @@ type ParseTreeListener interface {
|
|||
|
||||
type BaseParseTreeListener struct{}
|
||||
|
||||
var _ ParseTreeListener = &BaseParseTreeListener{}
|
||||
|
||||
func (l *BaseParseTreeListener) VisitTerminal(node TerminalNode) {}
|
||||
func (l *BaseParseTreeListener) VisitErrorNode(node ErrorNode) {}
|
||||
func (l *BaseParseTreeListener) EnterEveryRule(ctx ParserRuleContext) {}
|
||||
|
@ -102,6 +106,8 @@ type TerminalNodeImpl struct {
|
|||
symbol Token
|
||||
}
|
||||
|
||||
var _ TerminalNode = &TerminalNodeImpl{}
|
||||
|
||||
func NewTerminalNodeImpl(symbol Token) *TerminalNodeImpl {
|
||||
tn := new(TerminalNodeImpl)
|
||||
|
||||
|
@ -181,6 +187,8 @@ type ErrorNodeImpl struct {
|
|||
*TerminalNodeImpl
|
||||
}
|
||||
|
||||
var _ ErrorNode = &ErrorNodeImpl{}
|
||||
|
||||
func NewErrorNodeImpl(token Token) *ErrorNodeImpl {
|
||||
en := new(ErrorNodeImpl)
|
||||
en.TerminalNodeImpl = NewTerminalNodeImpl(token)
|
||||
|
|
|
@ -75,6 +75,8 @@ import "github.com/pboyer/antlr4/runtime/Go/antlr"
|
|||
// Base<file.grammarName>Listener is a complete listener for a parse tree produced by <file.parserName>.
|
||||
type Base<file.grammarName>Listener struct{}
|
||||
|
||||
var _ <file.grammarName>Listener = &Base<file.grammarName>Listener{}
|
||||
|
||||
// VisitTerminal is called when a terminal node is visited.
|
||||
func (s *Base<file.grammarName>Listener) VisitTerminal(node antlr.TerminalNode) {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue