Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. grammar Expr;
  2.  
  3. // Need to call recursive rule expr from non-recursive rule
  4. r : expr+ ;
  5.  
  6. // ANTLR4 : Left recursion!
  7. // Operator precedence matches order of definition
  8. expr : '-' expr // Unary minus
  9. | expr ('*' | '/' ) expr
  10. | expr ('+' | '-' ) expr
  11. | '(' expr ')'
  12. | INT
  13. | ID
  14. ;
  15.  
  16. INT : [0-9]+ ;
  17. ID : [a-z]+ ;
  18. WS : [ \t\r\n]+ -> skip;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement