[antlr-interest] updates to visitor/listener naming stuff
Terence Parr
parrt at cs.usfca.edu
Sat Feb 18 12:41:43 PST 2012
Changes:
* names changed. visit() -> visitX(). enter/exit() -> enter/exitX()
* capitalizing automatically now. rule s -> SContext not sContext
* no enter/exit method in generic rule context object if rule has alt labels, nor in interfaces.
* dup labels allowed in same rule
* label X or x illegal if rule x exists
Pushed to parrt/antlr4/master at github.
Ter
Example:
s : e ;
e : e '*' e -> Mult
| e '+' e -> Add
| INT -> primary
| ID -> primary
| '(' e ')' -> Parens
;
public interface AVisitor<T> {
T visitMult(AParser.MultContext ctx);
T visitParens(AParser.ParensContext ctx);
T visitS(AParser.SContext ctx);
T visitPrimary(AParser.PrimaryContext ctx);
T visitAdd(AParser.AddContext ctx);
}
public interface AListener extends ParseTreeListener<Token> {
void enterMult(AParser.MultContext ctx);
void exitMult(AParser.MultContext ctx);
void enterParens(AParser.ParensContext ctx);
void exitParens(AParser.ParensContext ctx);
void enterS(AParser.SContext ctx);
void exitS(AParser.SContext ctx);
void enterPrimary(AParser.PrimaryContext ctx);
void exitPrimary(AParser.PrimaryContext ctx);
void enterAdd(AParser.AddContext ctx);
void exitAdd(AParser.AddContext ctx);
}
More information about the antlr-interest
mailing list