-- xmesa.grammar
-- November 1, 1984 11:42:21 am PST: removed the augmenting production, which by the way, contained a symbol not declared in the previous tables.
-- November 1, 1984 11:46:35 am PST: When I fixed the IF-THEN-ELSE construction some years ago, I introduced new productions which I named, for example, 135a.  My new scanner wants only numbers.  So, replace the letters by 2 digits.
-- November 1, 1984 11:49:03 am PST: also, have to add the new left side names to the declaration tables. (basicStatement, balStatement)
-- November 1, 1984 11:50:51 am PST: remove 223 elsepart, and 226 otherpart from the list of symbols, as they are not used.

||INPUT ||CHAIN ||LISTS 

||TABLE1
  1  id
  2  num
  3  lnum
  4  flnum
  5  string
  6  lstring
  7  char
  8  atom
  9  ,
 10  ;
 11  :
 12  ..
 13  =>
 14  ←
 15  =
 16  #
 17  <
 18  >
 19  <=
 20  >=
 21  ~
 22  +
 23  -
 24  *
 25  /
 26  ↑
 27  .
 28  @
 29  !
 30  '|
 31  INTEGER
 32  CARDINAL
 33  CHARACTER
 34  BOOLEAN
 35  RECORD
 36  POINTER
 37  REF
 38  ARRAY
 39  DESCRIPTOR
 40  PROCEDURE
 41  PROC
 42  PORT
 43  SIGNAL
 44  ERROR
 45  PROCESS
 46  PROGRAM
 47  MONITOR
 48  ZONE
 49  RELATIVE
 50  LONG
 51  TYPE
 52  FRAME
 53  TO
 54  ORDERED
 55  UNCOUNTED
 56  BASE
 57  OF
 58  PACKED
 59  RETURNS
 60  MONITORED
 61  OVERLAID
 62  COMPUTED
 63  MACHINE
 64  DEPENDENT
 65  DIRECTORY
 66  DEFINITIONS
 67  IMPORTS
 68  EXPORTS
 69  SHARES
 70  RESIDENT
 71  LOCKS
 72  USING
 73  PUBLIC
 74  PRIVATE
 75  READONLY
 76  ENTRY
 77  INTERNAL
 78  INLINE
 79  CODE
 80  ABS
 81  ALL
 82  AND
 83  MAX
 84  MIN
 85  MOD
 86  NOT
 87  OR
 88  PRED
 89  LENGTH
 90  NEW
 91  START
 92  SUCC
 93  FORK
 94  JOIN
 95  LOOPHOLE
 96  SIZE
 97  FIRST
 98  LAST
 99  NIL
100  NULL
101  IF
102  THEN
103  ELSE
104  WITH
105  FROM
106  FOR
107  DECREASING
108  IN
109  THROUGH
110  UNTIL
111  WHILE
112  REPEAT
113  FINISHED
114  RETURN
115  EXIT
116  LOOP
117  GOTO
118  GO
119  FREE
120  WAIT
121  RESTART
122  NOTIFY
123  BROADCAST
124  STOP
125  RESUME
126  REJECT
127  CONTINUE
128  RETRY
129  TRANSFER
130  STATE
131  OPEN
132  ENABLE
133  ANY
134  EXITS
135  )
136  ]
137  }
138  END
139  ENDLOOP
140  ENDCASE
141  (
142  [
143  {
144  BEGIN
145  DO
146  SELECT
147  eof


||TABLE2
148  goal
149  unit
150  directory
151  module
152  includelist
153  includeitem
154  using
155  identlist
156  classhead
157  block
158  defhead
159  defbody
160  resident
161  arguments
162  interface
163  public
164  locks
165  definitions
166  imports
167  shares
168  open
169  declist
170  primary
171  typeexp
172  moduleitem
173  declaration
174  readonly
175  entry
176  initialization
177  default
178  optargs
179  procaccess
180  idlist'
181  identlist'
182  position
183  exp
184  optbits
185  bounds
186  interval
187  range
188  typeid
189  typecons
190  length
191  dependent
192  elementlist
193  ident
194  element
195  monitored
196  reclist
197  ordered
198  base
199  pointertype
200  packed
201  indextype
202  transfermode
203  heap
204  pairlist
205  typelist
206  variantpair
207  variantpart
208  pairitem
209  defaultopt
210  vcasehead
211  variantlist
212  tagtype
213  variantitem
214  idlist
215  pointerprefix
216  initvalue
217  inline
218  codelist
219  orderlist
220  statement
221  lhs
222  explist
224  casehead
225  casestmtlist
227  forclause
228  dotest
229  scope
230  doexit
231  transfer
232  free
233  optcatch
234  exits
235  enables
236  statementlist
237  binditem
238  exitlist
239  casestmtitem
240  caselabel
241  caseexpitem
242  catchcase
243  lhslist
244  casetest
245  optrelation
246  controlid
247  direction
248  exititem
249  catchany
250  catchlist
251  catchhead
252  keyitem
253  optexp
254  transferop
255  caseexplist
256  disjunct
257  conjunct
258  negation
259  not
260  relation
261  sum
262  addop
263  product
264  multop
265  factor
266  relationtail
267  relop
268  prefixop
269  new
270  typeop
271  desclist
272  opttype
273  qualifier
274  exports
275  fieldlist
276  modulelist
277  bindlist
278  statementlist'
279  casestmtlist'
280  exitlist'
281  keylist
282  caseexplist'
283  arglist
284  returnlist
286 basicStatement
287 balStatement


||TABLE3
id              tokenID
num             tokenNUM
lnum            tokenLNUM
flnum           tokenFLNUM
string          tokenSTR
lstring         tokenLSTR
char            tokenCHAR
atom            tokenATOM
-               tokenMINUS
.               tokenDOT
..              tokenDOTS
=               tokenEQUAL
=>              tokenARROW
<               tokenLESS
<=              tokenLE
>               tokenGREATER
>=              tokenGE
.               InitialSymbol


||TABLE4


  1     0  goal           ::= . unit . 
  2     0                   | . unit .. 

  3     1  unit           ::= directory module 

  4     2  directory      ::= DIRECTORY includelist ; 
  5   226                   | DIRECTORY ; 
  6   236                   | 

  7     3  includeitem    ::= id : FROM string using 
  8     4                   | id using 

  9     5  using          ::= USING [ ] 
 10   235                   | USING [ idlist ] 
 11   236                   | 

 12     6  module         ::= identlist classhead block 
 13     6                   | identlist defhead defbody 

 14     7  classhead      ::= resident PROGRAM arguments interface = public 
 15     8                   | resident MONITOR arguments locks interface = public 

 16     9  resident       ::= RESIDENT 
 17    10                   | 

 18    11  defhead        ::= definitions locks imports shares = public 

 19    12  definitions    ::= DEFINITIONS 

 20    13  defbody        ::= BEGIN open declist END 
 21    13                   | { open declist } 

 22    14  locks          ::= LOCKS primary 
 23    15                   | LOCKS primary USING id : typeexp 
 24   236                   | 

 25    16  moduleitem     ::= id 
 26    17                   | id : id 

 27    18  declaration    ::= identlist public readonly entry typeexp initialization 
 28    19                   | identlist public TYPE = public typeexp default 
 29    20                   | identlist public TYPE optargs 

 30    21  public         ::= PUBLIC 
 31    22                   | PRIVATE 
 32    23                   | 

 33    22  procaccess     ::= 

 34    24  entry          ::= ENTRY 
 35    25                   | INTERNAL 
 36    26                   | 

 37    27  idlist'        ::= id 
 38    29                   | id , idlist' 

 39    27  identlist'     ::= id : 
 40    28                   | id position : 
 41    29                   | id , identlist' 
 42    30                   | id position , identlist' 

 43    31  position       ::= ( exp optbits ) 

 44    32  optbits        ::= : bounds 
 45   236                   | 

 46    32  interval       ::= [ bounds ] 
 47    33                   | [ bounds ) 
 48    34                   | ( bounds ] 
 49    35                   | ( bounds ) 

 50    36  typeexp        ::= id 
 51   235                   | typeid 
 52   235                   | typecons 

 53    36  range          ::= id 
 54    45                   | id interval 
 55    46                   | typeid interval 
 56   235                   | interval 
 57   235                   | typeid 

 58    37  typeid         ::= INTEGER 
 59    38                   | CARDINAL 
 60    39                   | CHARACTER 
 61    40                   | BOOLEAN 
 62    41                   | id . id 
 63    42                   | id id 
 64    43                   | id typeid 

 65    44  typecons       ::= interval 
 66    45                   | id interval 
 67    46                   | typeid interval 
 68    47                   | id length 
 69    48                   | typeid length 
 70    49                   | dependent { elementlist } 
 71    52                   | dependent monitored RECORD reclist 
 72    53                   | ordered base pointertype 
 73    54                   | REF 
 74    55                   | REF readonly typeexp 
 75    56                   | packed ARRAY indextype OF typeexp 
 76    57                   | DESCRIPTOR FOR readonly typeexp 
 77    58                   | transfermode arguments 
 78    59                   | id RELATIVE typeexp 
 79    60                   | typeid RELATIVE typeexp 
 80    61                   | heap ZONE 
 81    62                   | LONG typeexp 
 82    63                   | FRAME [ id ] 

 83    50  ident          ::= id position : 
 84   200                   | id : 

 85    50  element        ::= id ( exp ) 
 86    51                   | ( exp ) 
 87   200                   | id 

 88    64  monitored      ::= MONITORED 
 89   234                   | 

 90    65  dependent      ::= MACHINE DEPENDENT 
 91    66                   | 

 92    67  reclist        ::= [ ] 
 93    67                   | NULL 
 94    68                   | [ pairlist ] 
 95    68                   | [ typelist ] 
 96    69                   | [ pairlist , variantpair ] 
 97    70                   | [ variantpart ] 
 98   233                   | [ variantpair ] 

 99    71  variantpair    ::= identlist public variantpart default 

100    71  pairitem       ::= identlist public typeexp default 

101    72  defaultopt     ::= 
102    73                   | NULL 
103    74                   | exp '| NULL 
104   235                   | exp 

105    75  variantpart    ::= SELECT vcasehead FROM variantlist ENDCASE 
106    75                   | SELECT vcasehead FROM variantlist , ENDCASE 

107    76  vcasehead      ::= ident public tagtype 
108    77                   | COMPUTED tagtype 
109    78                   | OVERLAID tagtype 

110    79  tagtype        ::= * 
111   235                   | typeexp 

112    80  variantitem    ::= idlist => reclist 

113    81  typelist       ::= typecons 
114    81                   | typeid 
115    82                   | id 
116    83                   | typecons , typelist 
117    83                   | typeid , typelist 
118    84                   | id , typelist 

119    85  pointertype    ::= pointerprefix 
120    86                   | pointerprefix TO readonly typeexp 

121    87  transfermode   ::= PROCEDURE 
122    87                   | PROC 
123    88                   | PORT 
124    89                   | SIGNAL 
125    90                   | ERROR 
126    91                   | PROCESS 
127    92                   | PROGRAM 

128    93  initialization ::= 
129   232                   | ← initvalue 
130   233                   | = initvalue 

131    94  initvalue      ::= procaccess inline block 
132    95                   | CODE 
133    96                   | MACHINE CODE BEGIN codelist END 
134    96                   | MACHINE CODE { codelist } 
135   157                   | NULL 
136   235                   | exp 

137    97  codelist       ::= orderlist 
138    98                   | codelist ; orderlist 

13901  xx  statement ::= basicStatement
13902  xx                    | IF exp THEN statement
13903  xx                    | IF exp THEN balStatement ELSE statement
13904 xx                     | casehead casestmtlist ENDCASE => statement
13905 xx   balStatement ::= basicStatement
13906 xx                     | IF exp THEN balStatement ELSE balStatement
13907 xx                     | casehead casestmtlist ENDCASE => balStatement 
13908   99  basicStatement      ::= lhs 
140   100                   | lhs ← exp 
141   101                   | [ explist ] ← exp 
142   102                   | block 
14401   104                  | casehead casestmtlist ENDCASE 
145   105                   | forclause dotest DO scope doexit ENDLOOP 
146   106                   | EXIT 
147   107                   | LOOP 
148   108                   | GOTO id 
149   109                   | GO TO id 
150   110                   | RETURN optargs 
151   111                   | transfer lhs 
152   112                   | free [ exp optcatch ] 
153   113                   | WAIT lhs 
154   114                   | ERROR 
155   115                   | STOP 
156   116                   | NULL 
157   117                   | RESUME optargs 
158   118                   | REJECT 
159   119                   | CONTINUE 
160   120                   | RETRY 
161   121                   | lhs ← STATE 

162   122  block          ::= BEGIN scope exits END 
163   122                   | { scope exits } 

164   123  scope          ::= open enables declist statementlist 

165   124  binditem       ::= exp 
166   125                   | id : exp 

167   126  exits          ::= EXITS exitlist 
168   234                   | 

169   127  casestmtitem   ::= caselabel => statement 

170   127  caseexpitem    ::= caselabel => exp 

171   127  catchcase      ::= lhslist => statement 

172   128  casetest       ::= optrelation 
173   129                   | exp 

174   130  forclause      ::= FOR controlid ← exp , exp 
175   131                   | FOR controlid direction IN range 
176   133                   | THROUGH range 
177   236                   | 

178   132  controlid      ::= ident typeexp 
179   200                   | id 

180   134  direction      ::= DECREASING 
181   135                   | 

182   136  dotest         ::= UNTIL exp 
183   235                   | WHILE exp 
184   236                   | 

185   137  doexit         ::= 
186   138                   | REPEAT exitlist 
187   139                   | REPEAT exitlist FINISHED => statement 
188   139                   | REPEAT exitlist FINISHED => statement ; 

189   140  exititem       ::= idlist => statement 

190   141  enables        ::= ENABLE catchcase ; 
191   142                   | ENABLE catchany ; 
192   143                   | ENABLE BEGIN catchlist END ; 
193   143                   | ENABLE { catchlist } ; 
194   234                   | 

195   144  catchlist      ::= catchhead 
196   145                   | catchhead catchcase 
197   235                   | catchhead catchany 
198   235                   | catchhead catchany ; 

199   146  transfer       ::= SIGNAL 
200   147                   | ERROR 
201   148                   | RETURN WITH ERROR 
202   149                   | START 
203   150                   | RESTART 
204   151                   | JOIN 
205   152                   | NOTIFY 
206   153                   | BROADCAST 
207   154                   | TRANSFER WITH 
208   155                   | RETURN WITH 

209   156  keyitem        ::= id : optexp 

210   157  optexp         ::= NULL 
211   235                   | exp 
212   236                   | 

213   158  exp            ::= transferop lhs 
214   159                   | IF exp THEN exp ELSE exp 
215   160                   | casehead caseexplist ENDCASE => exp 
216   161                   | lhs ← exp 
217   162                   | [ explist ] ← exp 
218   163                   | ERROR 
219   235                   | disjunct 

220   164  disjunct       ::= disjunct OR conjunct 
221 C 235                   | conjunct 

222   165  conjunct       ::= conjunct AND negation 
223 C 235                   | negation 

224   166  negation       ::= not relation 
225 C 235                   | relation 

226   167  relation       ::= sum optrelation 
227 C 235                   | sum 

228   167  sum            ::= sum addop product 
229 C 235                   | product 

230   167  product        ::= product multop factor 
231 C 235                   | factor 

232   168  optrelation    ::= not relationtail 
233   235                   | relationtail 

234   169  relationtail   ::= IN range 
235   235                   | relop sum 

236   170  relop          ::= = 
237   171                   | # 
238   172                   | < 
239   173                   | <= 
240   174                   | > 
241   175                   | >= 

242   176  addop          ::= + 
243   177                   | - 

244   178  multop         ::= * 
245   179                   | / 
246   180                   | MOD 

247   181  factor         ::= - primary 
248 C 235                   | primary 

249   182  primary        ::= num 
250   183                   | lnum 
251   184                   | flnum 
252   185                   | char 
253   186                   | string 
254   187                   | lstring 
255   188                   | atom 
256   189                   | NIL 
257   190                   | [ explist ] 
258   191                   | prefixop [ orderlist ] 
259   192                   | new [ typeexp initialization optcatch ] 
260   193                   | typeop [ typeexp ] 
261   194                   | SIZE [ typeexp ] 
262   195                   | SIZE [ typeexp , exp ] 
263   196                   | INTEGER [ explist ] 
264   197                   | CARDINAL [ explist ] 
265   198                   | @ lhs 
266   199                   | DESCRIPTOR [ desclist ] 
267 C 235                   | lhs 

268   200  lhs            ::= id 
269   201                   | LOOPHOLE [ exp opttype ] 
270   235                   | ( exp ) 
271   235                   | lhs qualifier 

272   202  qualifier      ::= [ explist optcatch ] 
273   203                   | . id 
274   204                   | ↑ 

275   205  optcatch       ::= ! catchlist 
276   234                   | 

277   206  transferop     ::= SIGNAL 
278   207                   | ERROR 
279   208                   | START 
280   209                   | JOIN 
281   210                   | NEW 
282   211                   | FORK 

283   212  prefixop       ::= LONG 
284   213                   | ABS 
285   214                   | PRED 
286   215                   | SUCC 
287   216                   | MIN 
288   217                   | MAX 
289   218                   | BASE 
290   219                   | LENGTH 
291   220                   | ALL 

292   221  typeop         ::= CODE 
293   222                   | FIRST 
294   223                   | LAST 
295   224                   | NIL 

296   225  desclist       ::= exp , exp opttype 
297   235                   | exp 

298   226  imports        ::= IMPORTS 
299   231                   | IMPORTS modulelist 
300   236                   | 

301   226  pointerprefix  ::= POINTER 
302   235                   | POINTER interval 

303   226  free           ::= FREE 
304   235                   | lhs . FREE 

305   226  new            ::= NEW 
306   235                   | lhs . NEW 

307   226  exports        ::= EXPORTS 
308   231                   | EXPORTS modulelist 
309   236                   | 

310   226  fieldlist      ::= [ ] 
311   231                   | [ pairlist ] 
312   231                   | [ typelist ] 

313   227  declist        ::= 
314   229                   | declist declaration ; 

315   227  casestmtlist   ::= 
316   235                   | casestmtlist' 
317   235                   | casestmtlist' ; 

318   227  statementlist  ::= 
319   235                   | statementlist' 
320   235                   | statementlist' ; 

321   227  exitlist       ::= 
322   235                   | exitlist' 
323   235                   | exitlist' ; 

324   227  catchhead      ::= 
325   229                   | catchhead catchcase ; 

326   227  caseexplist    ::= 
327   235                   | caseexplist' 
328   235                   | caseexplist' , 

329   228  includelist    ::= includeitem 
330   229                   | includelist , includeitem 

331   228  elementlist    ::= element 
332   229                   | elementlist , element 

333   228  pairlist       ::= pairitem 
334   229                   | pairlist , pairitem 

335   228  variantlist    ::= variantitem 
336   229                   | variantlist , variantitem 

337   228  orderlist      ::= optexp 
338   229                   | orderlist , optexp 

339   228  caselabel      ::= casetest 
340   229                   | caselabel , casetest 

341   228  lhslist        ::= lhs 
342   229                   | lhslist , lhs 

343   228  modulelist     ::= moduleitem 
344   229                   | modulelist , moduleitem 

345   228  bindlist       ::= binditem 
346   229                   | bindlist , binditem 

347   228  statementlist' ::= statement 
348   229                   | statementlist' ; statement 

349   228  casestmtlist'  ::= casestmtitem 
350   229                   | casestmtlist' ; casestmtitem 

351   228  exitlist'      ::= exititem 
352   229                   | exitlist' ; exititem 

353   228  keylist        ::= keyitem 
354   229                   | keylist , keyitem 

355   228  caseexplist'   ::= caseexpitem 
356   229                   | caseexplist' , caseexpitem 

357   230  identlist      ::= identlist' 

358   230  idlist         ::= idlist' 

359   230  explist        ::= orderlist 
360   230                   | keylist 

361   231  open           ::= OPEN bindlist ; 
362   236                   | 

363   232  casehead       ::= SELECT exp FROM 
364   233                   | WITH binditem SELECT optexp FROM 

365   233  readonly       ::= READONLY 
366   234                   | 

367   233  ordered        ::= ORDERED 
368   234                   | 

369   233  base           ::= BASE 
370   234                   | 

371   233  packed         ::= PACKED 
372   234                   | 

373   233  heap           ::= UNCOUNTED 
374   234                   | 

375   233  inline         ::= INLINE 
376   234                   | 

377   235  arguments      ::= arglist returnlist 

378   235  interface      ::= imports exports shares 

379   235  shares         ::= SHARES idlist 
380   236                   | 

381   235  default        ::= ← defaultopt 
382   236                   | 

383   235  optargs        ::= [ explist ] 
384   236                   | 

385   235  bounds         ::= exp .. exp 

386   235  length         ::= [ exp ] 

387   235  indextype      ::= typeexp 
38801   236                   | 


39301   235  catchany       ::= ANY => statement 

394   235  not            ::= ~ 
395   235                   | NOT 

396   235  opttype        ::= , typeexp 
397   236                   | 

398   235  arglist        ::= fieldlist 
399   236                   | 

400   235  returnlist     ::= RETURNS fieldlist 
401   236                   |