Using Antlr4 Golang runtime with visitor

910 views
Skip to first unread message

std...@gmail.com

unread,
Mar 19, 2017, 11:30:59 AM3/19/17
to antlr-discussion
Im relative new to Antlr, and I want to make a project using antlr with go runtime but I dont find examples on how to use the visitor generated in this language.

Gary Miller

unread,
Apr 30, 2017, 7:25:26 AM4/30/17
to antlr-discussion
Getting visitors into the Go target is currently being worked on.
The code isn't stable yet, but should be soon.

You can follow the github issue if you're interested.

Eugene Dzhurinsky

unread,
Jul 9, 2017, 11:44:04 AM7/9/17
to antlr-discussion
Any updates on that? I am trying to experiment with the visitors for Golang, but so far looks like the generated code is something like:

type BaseHOCONVisitor struct {
 
*antlr.BaseParseTreeVisitor
}


func
(v *BaseHOCONVisitor) VisitHocon(ctx *HoconContext) interface{} {
 
return v.VisitChildren(ctx)
}


func
(v *BaseHOCONVisitor) VisitObj(ctx *ObjContext) interface{} {
 
return v.VisitChildren(ctx)
}

and in turn

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 }
func
(v *BaseParseTreeVisitor) VisitErrorNode(node ErrorNode) interface{}   { return nil }


Am I missing something? Because from this generated code it looks like the tree visitor visits nothing.

ANTLR Parser Generator  Version 4.7
Reply all
Reply to author
Forward
0 new messages