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