Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. grammar oskarLab1;
  2.  
  3. plik : (expr {System.out.println ("Result: " + $expr.text )}
  4. ;
  5.  
  6. expr returns [integer wy]
  7.  
  8. : term ((PLUS term | MINUS term))* NL;
  9.  
  10. term : atom (MUL atom| DIV atom)*;
  11.  
  12. atom : INT | (LP expr RP);
  13.  
  14.  
  15. ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
  16. ;
  17.  
  18. INT : '0'..'9'+
  19. ;
  20.  
  21. COMMENT
  22. : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
  23. | '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
  24. ;
  25.  
  26. WS : ( ' '
  27. | '\t'
  28. | '\r'
  29. ) {$channel=HIDDEN;}
  30. ;
  31.  
  32. LP :'(';
  33. RP :')';
  34. PLUS : '+';
  35. MINUS: '-' ;
  36. MUL : '*' ;
  37. DIV : '/' ;
  38. NL : '\n' ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement