Home | History | Annotate | Download | only in polydiff
      1 grammar Poly;
      2 options {
      3     output=AST;
      4     language=ObjC;
      5     }
      6 tokens { MULT; } // imaginary token
      7 
      8 poly: term ('+'^ term)*
      9     ;
     10 
     11 term: INT ID  -> ^(MULT[@"*"] INT ID)
     12     | INT exp -> ^(MULT[@"*"] INT exp)
     13     | exp
     14     | INT
     15 	| ID
     16     ;
     17 
     18 exp : ID '^'^ INT
     19     ;
     20     
     21 ID  returns [NSString *value]
     22     : 'a'..'z'+ ;
     23 
     24 INT  returns [NSString *value]
     25     : '0'..'9'+ ;
     26 
     27 WS	: (' '|'\t'|'\r'|'\n')+ { $channel=HIDDEN; } ;
     28