Reputation: 14044
I'm currently investigating ANTLR4 , and I'm struggling a bit to find information on how the visitors are used. The following page: http://www.antlr.org/wiki/display/ANTLR4/Parser+Rules and reading though the ANTLR generaged files in my little dummy project, leaves me with the following questions
how do I access the fields of the parser in the listener? For example, if i use @members {int mynumber = 0;}
in the grammer, how can I access this within a method of the listener implementation?
Can anybody point me to a small example, targeted at somebody fairly new to antlr which uses visitors?
Upvotes: 2
Views: 3401
Reputation: 1151
This example by Bart Kiers really helped me: If/else statements in ANTLR using listeners
There's more info if you grab the example source files: https://github.com/bkiers/Mu
Upvotes: 3