GrammarAddress.g4 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. /**
  7. TODO:
  8. SwitchCASE incompleto
  9. */
  10. grammar GrammarAddress;
  11. assing
  12. : expression EOF
  13. ;
  14. expression
  15. : R_PAR_E expression R_PAR_D #expr_par
  16. | expression op=R_OP_MULT expression #expr_arit_md
  17. | expression op=R_OP_ADD expression #expr_arit_as
  18. | T_INTEIRO #expr_integer
  19. | variable #expr_id
  20. ;
  21. variable
  22. : modificator? ID
  23. ;
  24. modificator
  25. : '.' //type
  26. | '_' //variable
  27. ;
  28. //DEFINICAO DE TOKENS ----------------------------------------------------------
  29. R_PAR_E : '(';
  30. R_PAR_D : ')';
  31. R_CHA_E : '[';
  32. R_CHA_D : ']';
  33. R_OP_ADD : '+';
  34. R_OP_MULT : '*';
  35. fragment DIGITO : [0-9] ;
  36. fragment CHARACTER : [a-zA-Z_] ;
  37. fragment CHARACTER_UP: [A-Z];
  38. ID : CHARACTER ( CHARACTER | DIGITO )* ;
  39. T_INTEIRO : DIGITO+ ;
  40. R_LINE_COMMENT : '//' .*? '\r'? '\n' -> skip ; // Match "#" stuff '\n'
  41. R_WS : (' '|'\t'|'\r'|'\n')+ -> skip ;
  42. R_COMMENT : '/*' .*? '*/' -> skip ; // Match "/*" stuff "*/"