Template.g4 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 Template;
  11. //DEFINICAO DE TOKENS ----------------------------------------------------------
  12. fragment DIGITO : [0-9] ;
  13. fragment CHARACTER : [a-zA-Z_] ;
  14. fragment CHARACTER_UP: [A-Z];
  15. ID : CHARACTER ( CHARACTER | DIGITO )* ;
  16. T_INTEIRO : DIGITO+ ;
  17. R_WS : ('\t'|'\r'|'\n')+ -> skip ;//' '|
  18. init
  19. : (expression | literal)+ EOF
  20. ;
  21. literal
  22. : '\'' any '\''
  23. ;
  24. any
  25. : (ID|T_INTEIRO|','|':'|'='|'-'|'_'|'<'|'>'|' ')+
  26. ;
  27. expression
  28. : '{' part ('|' part)* '}'
  29. ;
  30. part
  31. : pre=literal? '[' stmt ']' pos=literal?
  32. ;
  33. stmt
  34. : arg
  35. | call
  36. ;
  37. call
  38. : ID '(' args? ')'
  39. ;
  40. args
  41. : arg (',' arg)*
  42. ;
  43. arg
  44. : literal
  45. | seletor
  46. | number
  47. | call
  48. ;
  49. seletor
  50. : ID ('.' ID)*
  51. ;
  52. number
  53. : (T_INTEIRO '.')? T_INTEIRO
  54. ;