daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (expression | FLOAT) '(' -> (expression | FLOAT) '*('
  2.    
  3. grammar Test;
  4.  
  5. expression
  6. : //FLOAT '(' -> (FLOAT '*(')+
  7. | add EOF!
  8. ;
  9. term
  10. :  
  11. | '(' add ')'
  12. | FLOAT
  13. | IMULT
  14. ;
  15.  
  16. IMULT
  17. :   (add ('(' add)*) -> (add ('*' add)*)
  18. ;
  19. negation
  20. :   '-'* term
  21. ;
  22.  
  23. unary
  24. :   ('+' | '-')* negation
  25. ;
  26.  
  27. mult
  28. :   unary (('*' | '/') unary)*
  29. ;
  30.  
  31. add
  32. :   mult (('+' | '-') mult)*
  33. ;
  34.  
  35. ID  :   ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
  36. ;
  37.  
  38. FLOAT
  39. :   ('0'..'9')+ '.' ('0'..'9')*// EXPONENT?
  40. |   '.' ('0'..'9')+ //EXPONENT?
  41. |   ('0'..'9')+ //EXPONENT
  42. ;
  43.  
  44. WS  :   ( ' '
  45.     | 't'
  46.     | 'r'
  47.     | 'n'
  48.     ) {$channel=HIDDEN;}
  49. ;
  50.    
  51. imult
  52. : FLOAT '(' -> FLOAT '*('
  53. ;
  54.    
  55. IMULT / imult
  56. : expression '(' -> expression '*'
  57. ;
  58.    
  59. tokens { ABSTRACTTOKEN; }
  60.    
  61. imult
  62. : FLOAT '(' -> ^(ABSTRACTTOKEN FLOAT)
  63. ;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top