2011-06-29 09:51:39 +08:00
|
|
|
grammar T;
|
2011-11-14 03:35:11 +08:00
|
|
|
options {output=AST;}
|
|
|
|
|
2011-09-04 03:52:23 +08:00
|
|
|
s : i=ifstat {System.out.println(_input.toString(0,_input.index()-1));} ;
|
2011-09-10 09:08:13 +08:00
|
|
|
|
2011-10-21 11:12:32 +08:00
|
|
|
ifstat : 'if' '(' expr ')' assign ;
|
|
|
|
assign : ID '=' expr ';' ;
|
|
|
|
expr : INT | ID ;
|
2011-09-06 09:08:26 +08:00
|
|
|
|
2011-08-13 11:51:12 +08:00
|
|
|
EQ : '=' ;
|
2011-08-01 10:14:47 +08:00
|
|
|
INT : '0'..'9'+ ;
|
2011-08-13 11:51:12 +08:00
|
|
|
ID : 'a'..'z'+ ;
|
|
|
|
WS : (' '|'\n')+ {skip();} ;
|