Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.93 KB | None | 0 0
  1. grammar GramaticaEnvolventesExternas;
  2.  
  3. @members {
  4. String stringTemp;
  5.  
  6. int valorElevacaoInferior = 200;
  7. int valorElevacaoSuperior = 400;
  8.  
  9. int valorDiferencaElevacaoInferior = 130;
  10. int valorDiferencaElevacaoSuperior = 350;
  11.  
  12. int valorDistanciaPeInferior = 1;
  13. int valorDistanciaPeSuperior = 4;
  14.  
  15. int valorDistanciaAutomovelInferior = 10;
  16. int valorDistanciaAutomovelSuperior = 85;
  17.  
  18. int valorTempoViagemPeInferior = 10;
  19. int valorTempoViagemPeSuperior = 40;
  20.  
  21. int valorTempoViagemAutomovelInferior = 25;
  22. int valorTempoViagemAutomovelSuperior = 70;
  23. }
  24.  
  25. inicial returns [String return_value] : VALOR_NUMERICO WS tipoOptional {$return_value = $tipoOptional.return_value;};
  26.  
  27. tipoOptional returns [String return_value] : elevacao
  28. {stringTemp = $elevacao.return_value;
  29. if (stringTemp != null) {
  30. $return_value = $elevacao.return_value;
  31. }}
  32. | diferenca_elevacao
  33. {stringTemp = $diferenca_elevacao.return_value;
  34. if (stringTemp != null) {
  35. $return_value = $diferenca_elevacao.return_value;
  36. }}
  37. | distancia_pe
  38. {stringTemp = $distancia_pe.return_value;
  39. if (stringTemp != null) {
  40. $return_value = $distancia_pe.return_value;
  41. }}
  42. | distancia_automovel
  43. {stringTemp = $distancia_automovel.return_value;
  44. if (stringTemp != null) {
  45. $return_value = $distancia_automovel.return_value;
  46. }}
  47. | tempo_viagem_pe
  48. {stringTemp = $tempo_viagem_pe.return_value;
  49. if (stringTemp != null) {
  50. $return_value = $tempo_viagem_pe.return_value;
  51. }}
  52. | tempo_viagem_automovel
  53. {stringTemp = $tempo_viagem_automovel.return_value;
  54. if (stringTemp != null) {
  55. $return_value = $tempo_viagem_automovel.return_value;
  56. }};
  57.  
  58. elevacao returns [String return_value] : 'elevacao' {
  59. if (VALOR_NUMERICO < valorElevacaoInferior) {
  60. $return_value = "Baixo";
  61. } else if (VALOR_NUMERICO > valorElevacaoSuperior) {
  62. $return_value = "Alto";
  63. } else {
  64. $return_value = "Medio";
  65. }
  66. };
  67. diferenca_elevacao returns [String return_value] : 'diferencaElevacao' {
  68. if (VALOR_NUMERICO < valorDiferencaElevacaoInferior) {
  69. $return_value = "Baixo";
  70. } else if (VALOR_NUMERICO > valorDiferencaElevacaoSuperior) {
  71. $return_value = "Alto";
  72. } else {
  73. $return_value = "Medio";
  74. }
  75. };
  76. distancia_pe returns [String return_value] : 'distanciaPe' {
  77. if (VALOR_NUMERICO < valorDistanciaPeInferior) {
  78. ((Distancia_peContext)_localctx).return_value = "Baixo";
  79. } else if (VALOR_NUMERICO > valorDistanciaPeSuperior) {
  80. ((Distancia_peContext)_localctx).return_value = "Alto";
  81. } else {
  82. ((Distancia_peContext)_localctx).return_value = "Medio";
  83. }
  84. };
  85. distancia_automovel returns [String return_value] : 'distanciaAutomovel' {
  86. if (VALOR_NUMERICO < valorDistanciaAutomovelInferior) {
  87. $return_value = "Baixo";
  88. } else if (VALOR_NUMERICO > valorDistanciaAutomovelSuperior) {
  89. $return_value = "Alto";
  90. } else {
  91. $return_value = "Medio";
  92. }
  93. };
  94. tempo_viagem_pe returns [String return_value] : 'tempoViagemPe' {
  95. if (VALOR_NUMERICO < valorTempoViagemPeInferior) {
  96. $return_value = "Baixo";
  97. } else if (VALOR_NUMERICO > valorTempoViagemPeSuperior) {
  98. $return_value = "Alto";
  99. } else {
  100. $return_value = "Medio";
  101. }
  102. };
  103. tempo_viagem_automovel returns [String return_value] : 'tempoViagemAutomovel' {
  104. if (VALOR_NUMERICO < valorTempoViagemAutomovelInferior) {
  105. $return_value = "Baixo";
  106. } else if (VALOR_NUMERICO > valorTempoViagemAutomovelSuperior) {
  107. $return_value = "Alto";
  108. } else {
  109. $return_value = "Medio";
  110. }
  111. };
  112.  
  113. VALOR_NUMERICO : [0-9]+'.'[0-9]+ | [0-9]+;
  114.  
  115. WS: (' ' | '\t')+;
  116. NL: '\r'? '\n';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement