forked from jasder/antlr
make T.g same
This commit is contained in:
parent
28ee391c81
commit
102980dffd
|
@ -1,24 +1,9 @@
|
|||
grammar T;
|
||||
@members {
|
||||
public static class LeafListener extends TBaseListener {
|
||||
public void exitCall(TParser.CallContext ctx) {
|
||||
System.out.printf("%s %s",ctx.e().start.getText(),
|
||||
ctx.eList());
|
||||
}
|
||||
} public void exitInt(TParser.IntContext ctx) {
|
||||
System.out.println(ctx.INT().getText());
|
||||
}
|
||||
}
|
||||
s
|
||||
@init {setBuildParseTree(true);}
|
||||
@after { System.out.println($r.ctx.toStringTree(this)); ParseTreeWalker walker = new ParseTreeWalker();
|
||||
walker.walk(new LeafListener(), $r.ctx);}
|
||||
: r=e ;
|
||||
e : e '(' eList ')' -> Call
|
||||
| INT -> Int
|
||||
s : a a a;
|
||||
a : {false}? ID
|
||||
| {true}? ID
|
||||
| INT
|
||||
;
|
||||
eList : e (',' e)* ;
|
||||
MULT: '*' ;
|
||||
ADD : '+' ;
|
||||
INT : [0-9]+ ;
|
||||
WS : [ \t\n]+ -> skip ;
|
||||
ID : 'a'..'z'+ ;
|
||||
INT : '0'..'9'+;
|
||||
WS : (' '|'\n') {skip();} ;
|
||||
|
|
Loading…
Reference in New Issue