This commit is contained in:
Terence Parr 2012-10-11 20:22:30 -07:00
parent f20cd82920
commit f73c319e42
1 changed files with 11 additions and 4 deletions

View File

@ -1,5 +1,12 @@
grammar T;
options {tokenVocab=A;}
s : ID ;
ID : 'a'..'z'+ ;
WS : (' '|'\n') {skip();} ;
s : expr[0] ;
expr[int _p]
: ID
( {5 >= $_p}? '*' expr[6]
| {4 >= $_p}? '+' expr[5]
)*
;
ID : [a-zA-Z]+ ; // match identifiers
WS : [ \t\r\n]+ -> skip ; // toss out whitespace