Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grammar try;
- options {output=AST;}
- tokens { MULT; } // imaginary token
- poly: term ('+'^ term)*
- ;
- term: INT ID -> ^(MULT["*"] INT ID)
- | INT exp -> ^(MULT["*"] INT exp)
- | exp
- | INT
- | ID
- ;
- exp : ID '^'^ INT
- ;
- ID : 'a'..'z'+ ;
- INT : '0'..'9'+ ;
- WS : (' '|'t'|'r'|'n')+ {skip();} ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement