Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. grammar try;
  2. options {output=AST;}
  3. tokens { MULT; } // imaginary token
  4.  
  5. poly: term ('+'^ term)*
  6. ;
  7.  
  8. term: INT ID -> ^(MULT["*"] INT ID)
  9. | INT exp -> ^(MULT["*"] INT exp)
  10. | exp
  11. | INT
  12. | ID
  13. ;
  14. exp : ID '^'^ INT
  15. ;
  16.  
  17. ID : 'a'..'z'+ ;
  18. INT : '0'..'9'+ ;
  19. WS : (' '|'t'|'r'|'n')+ {skip();} ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement