expression.g 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. *
  5. * Author: Ceriel J.H. Jacobs
  6. */
  7. /* E X P R E S S I O N S */
  8. /* stripped down version of the one in the Modula-2 compiler */
  9. /* $Header$ */
  10. qualident :
  11. IDENT
  12. [
  13. selector
  14. ]*
  15. ;
  16. selector :
  17. '.' IDENT
  18. ;
  19. ExpList :
  20. expression
  21. [
  22. ',' expression
  23. ]*
  24. ;
  25. ConstExpression :
  26. expression
  27. /*
  28. * Changed rule in new Modula-2.
  29. */
  30. ;
  31. expression :
  32. SimpleExpression
  33. [
  34. /* relation */
  35. [ '=' | '#' | '<' | LESSEQUAL | '>' | GREATEREQUAL | IN ]
  36. SimpleExpression
  37. |
  38. /* empty */
  39. ]
  40. ;
  41. SimpleExpression :
  42. [
  43. '+'
  44. |
  45. '-'
  46. |
  47. /* empty */
  48. ]
  49. term
  50. [
  51. /* AddOperator */
  52. [ '+' | '-' | OR ] term
  53. ]*
  54. ;
  55. term :
  56. factor
  57. [
  58. /* MulOperator */
  59. [ '*' | '/' | DIV | MOD | AND ] factor
  60. ]*
  61. ;
  62. factor :
  63. qualident
  64. [
  65. designator_tail?
  66. [
  67. ActualParameters
  68. |
  69. /* empty */
  70. ]
  71. |
  72. bare_set
  73. ]
  74. |
  75. bare_set
  76. | %default
  77. [ %default
  78. INTEGER
  79. |
  80. REAL
  81. |
  82. STRING
  83. ]
  84. |
  85. '(' expression ')'
  86. |
  87. NOT factor
  88. ;
  89. bare_set :
  90. '{'
  91. [
  92. element
  93. [
  94. ',' element
  95. ]*
  96. |
  97. /* empty */
  98. ]
  99. '}'
  100. ;
  101. ActualParameters :
  102. '(' ExpList? ')'
  103. ;
  104. element :
  105. expression
  106. [
  107. UPTO expression
  108. |
  109. /* empty */
  110. ]
  111. ;
  112. designator :
  113. qualident designator_tail?
  114. ;
  115. designator_tail :
  116. visible_designator_tail
  117. [ %persistent
  118. %default
  119. selector
  120. |
  121. visible_designator_tail
  122. ]*
  123. ;
  124. visible_designator_tail :
  125. '['
  126. expression
  127. [
  128. ',' expression
  129. ]*
  130. ']'
  131. |
  132. '^'
  133. ;