-- xcedar.grammar
-- grammar extracted from Pass1T.pgs by PGS, March 29, 1984 6:14:59 pm PST
-- September 14, 1984 10:16:11 am PDT: modified by H Sturgis to be "Augmented"  by adding a new production rule "GOAL ::= goal".  I did not include GOAL in the symbol lists.  Renamed to be xcedar.grammar instead of cedar.grammar
-- November 1, 1984 11:21:29 am PST: The parser generator now automatically augments PGS grammars, and the fact that the above entered GOAL is not in the symbol lists leads to trouble.  So, remove the augmentation.

||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  RECORD
 32  POINTER
 33  REF
 34  VAR
 35  LIST
 36  ARRAY
 37  SEQUENCE
 38  DESCRIPTOR
 39  PROCEDURE
 40  PROC
 41  PORT
 42  SIGNAL
 43  ERROR
 44  PROCESS
 45  PROGRAM
 46  MONITOR
 47  DEFINITIONS
 48  ZONE
 49  RELATIVE
 50  LONG
 51  TYPE
 52  FRAME
 53  TO
 54  ORDERED
 55  UNCOUNTED
 56  PAINTED
 57  BASE
 58  OF
 59  PACKED
 60  RETURNS
 61  SAFE
 62  UNSAFE
 63  MONITORED
 64  OVERLAID
 65  COMPUTED
 66  MACHINE
 67  DEPENDENT
 68  DIRECTORY
 69  IMPORTS
 70  EXPORTS
 71  SHARES
 72  LOCKS
 73  USING
 74  PUBLIC
 75  PRIVATE
 76  CEDAR
 77  CHECKED
 78  TRUSTED
 79  UNCHECKED
 80  ENTRY
 81  INTERNAL
 82  INLINE
 83  READONLY
 84  CODE
 85  ABS
 86  ALL
 87  AND
 88  APPLY
 89  CONS
 90  MAX
 91  MIN
 92  MOD
 93  NOT
 94  OR
 95  ORD
 96  PRED
 97  LENGTH
 98  NEW
 99  START
100  SUCC
101  VAL
102  FORK
103  JOIN
104  LOOPHOLE
105  NARROW
106  ISTYPE
107  SIZE
108  FIRST
109  LAST
110  NIL
111  TRASH
112  NULL
113  IF
114  THEN
115  ELSE
116  WITH
117  FROM
118  FOR
119  DECREASING
120  IN
121  THROUGH
122  UNTIL
123  WHILE
124  REPEAT
125  FINISHED
126  RETURN
127  EXIT
128  LOOP
129  GOTO
130  GO
131  FREE
132  WAIT
133  RESTART
134  NOTIFY
135  BROADCAST
136  STOP
137  RESUME
138  REJECT
139  CONTINUE
140  RETRY
141  TRANSFER
142  STATE
143  OPEN
144  ENABLE
145  ANY
146  EXITS
147  )
148  ]
149  }
150  END
151  ENDLOOP
152  ENDCASE
153  (
154  [
155  {
156  BEGIN
157  DO
158  SELECT
159  eof

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


||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
#             tokenNE
~             tokenTILDE
.             initialSymbol


||TABLE4

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

  3     1  module         ::= directory identlist cedar proghead trusted checked block 
  4     2                   | directory identlist cedar defhead defbody 

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

  9     6  cedar          ::= CEDAR 
 10     7                   | 

 11     8  proghead       ::= resident safe class arguments locks interface tilde public 

 12     9  resident       ::= 

 13    10  defhead        ::= definitions locks imports shares tilde public 

 14    11  definitions    ::= DEFINITIONS 

 15    12  defbody        ::= BEGIN open declist END 
 16    12                   | BEGIN open declist ; END 
 17    12                   | { open declist } 
 18    12                   | { open declist ; } 

 19    13  locks          ::= LOCKS primary lambda 
 20   251                   | 

 21    14  lambda         ::= USING ident typeexp 
 22   251                   | 

 23    15  moduleitem     ::= id 
 24    16                   | id : id 

 25    17  declaration    ::= identlist public entry readonly typeexp initialization 
 26    18                   | identlist public TYPE tilde public typeexp default 
 27    19                   | identlist public TYPE optsize 

 28    20  public         ::= PUBLIC 
 29    21                   | PRIVATE 
 30    22                   | 

 31    21  procaccess     ::= 

 32    23  entry          ::= ENTRY 
 33    24                   | INTERNAL 
 34    25                   | 

 35    26  idlist'        ::= id 
 36    28                   | id , idlist' 

 37    26  identlist'     ::= id : 
 38    27                   | id position : 
 39    28                   | id , identlist' 
 40    29                   | id position , identlist' 

 41    30  position       ::= ( exp optbits ) 

 42    31  optbits        ::= : bounds 
 43   251                   | 

 44    31  interval       ::= [ bounds ] 
 45    32                   | [ bounds ) 
 46    33                   | ( bounds ] 
 47    34                   | ( bounds ) 

 48    35  typeexp        ::= id 
 49   250                   | typeid 
 50   250                   | typecons 

 51    35  range          ::= id 
 52    43                   | id interval 
 53    44                   | typeid interval 
 54   250                   | interval 
 55   250                   | typeid 

 56    36  typeid'        ::= id . id 
 57    37                   | typeid' . id 

 58    37  typeappl       ::= typeappl . id 
 59    40                   | id length 
 60    41                   | typeid length 
 61    41                   | typeappl length 

 62    38  typeid         ::= id id 
 63    39                   | id typeid 
 64   250                   | typeid' 

 65    42  typecons       ::= interval 
 66    43                   | id interval 
 67    44                   | typeid interval 
 68    45                   | dependent { elementlist } 
 69    48                   | dependent monitored RECORD reclist 
 70    49                   | ordered base pointertype 
 71    50                   | VAR typeexp 
 72    51                   | REF readonly typeexp 
 73    52                   | REF readonly ANY 
 74    53                   | REF 
 75    54                   | LIST OF readonly typeexp 
 76    55                   | packed ARRAY indextype OF typeexp 
 77    56                   | DESCRIPTOR FOR readonly typeexp 
 78    57                   | safe transfermode arguments 
 79    60                   | id RELATIVE typeexp 
 80    61                   | typeid RELATIVE typeexp 
 81    62                   | heap ZONE 
 82    63                   | LONG typeexp 
 83    64                   | FRAME [ id ] 
 84    65                   | id PAINTED typeexp 
 85    66                   | typeid PAINTED typeexp 
 86   250                   | typeappl 

 87    46  ident          ::= id position : 
 88   206                   | id : 

 89    46  element        ::= id ( exp ) 
 90    47                   | ( exp ) 
 91   206                   | id 

 92    58  safe           ::= 
 93   247                   | UNSAFE 
 94   248                   | SAFE 

 95    59  arglist        ::= ANY 
 96   250                   | fieldlist 
 97   251                   | 

 98    59  returnlist     ::= RETURNS ANY 
 99   250                   | RETURNS fieldlist 
100   251                   | 

101    67  monitored      ::= MONITORED 
102   249                   | 

103    68  dependent      ::= MACHINE DEPENDENT 
104    69                   | 

105    70  reclist        ::= [ ] 
106    70                   | NULL 
107    71                   | [ pairlist ] 
108    71                   | [ typelist ] 
109    72                   | [ pairlist , variantpair ] 
110    73                   | [ variantpart default ] 
111   248                   | [ variantpair ] 

112    74  variantpair    ::= identlist public variantpart default 

113    74  pairitem       ::= identlist public typeexp default 

114    75  variantpart    ::= SELECT vcasehead FROM variantlist ENDCASE 
115    75                   | SELECT vcasehead FROM variantlist , ENDCASE 
116    76                   | packed SEQUENCE vcasehead OF typeexp 

117    77  vcasehead      ::= ident public tagtype 
118    78                   | COMPUTED tagtype 
119    79                   | OVERLAID tagtype 

120    80  tagtype        ::= * 
121   250                   | typeexp 

122    81  variantitem    ::= idlist => reclist 

123    82  typelist       ::= typecons default 
124    82                   | typeid default 
125    83                   | id 
126    84                   | id ← defaultopt 
127    85                   | typecons default , typelist 
128    85                   | typeid default , typelist 
129    86                   | id , typelist 
130    87                   | id ← defaultopt , typelist 

131    88  pointertype    ::= pointerprefix 
132    89                   | pointerprefix TO readonly typeexp 

133    90  transfermode   ::= PROCEDURE 
134    90                   | PROC 
135    91                   | PORT 
136    92                   | SIGNAL 
137    93                   | ERROR 
138    94                   | PROCESS 
139    95                   | PROGRAM 

140    96  initialization ::= 
141   247                   | ← initvalue 
142   248                   | tilde initvalue 

143    97  initvalue      ::= procaccess trusted checked inline block 
144    98                   | CODE 
145    99                   | procaccess trusted checked MACHINE CODE BEGIN codelist END 
146    99                   | procaccess trusted checked MACHINE CODE { codelist } 
147   166                   | trash 
148   250                   | exp 

149   100  trusted        ::= 

150   101  codelist       ::= orderlist 
151   102                   | codelist ; orderlist 

152   103  statement      ::= IF exp THEN statement 
153   104                   | IF exp THEN balstmt ELSE statement 
154   105                   | casehead casestmtlist ENDCASE => statement 
155   250                   | basicstmt 

156   104  balstmt        ::= IF exp THEN balstmt ELSE balstmt 
157   105                   | casehead casestmtlist ENDCASE => balstmt 
158   250                   | basicstmt 

159   106  basicstmt      ::= lhs 
160   107                   | lhs ← exp 
161   108                   | [ explist ] ← exp 
162   109                   | trusted checked block 
163   110                   | casehead casestmtlist ENDCASE 
164   111                   | forclause dotest DO scope doexit ENDLOOP 
165   112                   | EXIT 
166   113                   | LOOP 
167   114                   | GOTO id 
168   115                   | GO TO id 
169   116                   | RETURN optargs 
170   117                   | transfer lhs 
171   118                   | free [ exp optcatch ] 
172   119                   | WAIT lhs 
173   120                   | ERROR 
174   121                   | STOP 
175   122                   | NULL 
176   123                   | RESUME optargs 
177   124                   | REJECT 
178   125                   | CONTINUE 
179   126                   | RETRY 
180   127                   | lhs ← STATE 
181   128                   | STATE ← exp 

182   129  block          ::= BEGIN scope exits END 
183   129                   | { scope exits } 

184   130  scope          ::= open enables statementlist 
185   131                   | open enables declist ; statementlist 

186   132  binditem       ::= exp 
187   133                   | id : exp 
188   133                   | id ~ ~ exp 

189   134  exits          ::= EXITS exitlist 
190   249                   | 

191   135  casestmtitem   ::= caselabel => statement 

192   135  caseexpitem    ::= caselabel => exp 

193   135  exititem       ::= idlist => statement 

194   136  casetest       ::= optrelation 
195   137                   | exp 

196   138  caselabel      ::= ident typeexp 
197   245                   | caselabel' 

198   138  controlid      ::= ident typeexp 
199   206                   | id 

200   139  forclause      ::= FOR controlid ← exp , exp 
201   140                   | FOR controlid direction IN range 
202   141                   | THROUGH range 
203   251                   | 

204   142  direction      ::= DECREASING 
205   143                   | 

206   144  dotest         ::= UNTIL exp 
207   250                   | WHILE exp 
208   251                   | 

209   145  doexit         ::= 
210   146                   | REPEAT exitlist 
211   147                   | REPEAT exitlist FINISHED => statement 
212   147                   | REPEAT exitlist FINISHED => statement ; 

213   148  enables        ::= ENABLE catchcase ; 
214   149                   | ENABLE catchany ; 
215   150                   | ENABLE BEGIN catchlist END ; 
216   150                   | ENABLE { catchlist } ; 
217   249                   | 

218   151  catchlist      ::= catchhead catchcase 
219   240                   | catchhead 
220   250                   | catchhead catchany 
221   250                   | catchhead catchany ; 

222   152  catchcase      ::= lhslist => statement 

223   153  optargs        ::= [ explist ] 
224   154                   | 
225   248                   | lhs 

226   155  transfer       ::= SIGNAL 
227   156                   | ERROR 
228   157                   | RETURN WITH ERROR 
229   158                   | START 
230   159                   | RESTART 
231   160                   | JOIN 
232   161                   | NOTIFY 
233   162                   | BROADCAST 
234   163                   | TRANSFER WITH 
235   164                   | RETURN WITH 

236   165  keyitem        ::= id ~ optexp 
237   165                   | id : optexp 

238   166  defaultopt     ::= trash 
239   167                   | exp '| trash 
240   241                   | 
241   250                   | exp 

242   166  optexp         ::= trash 
243   250                   | exp 
244   251                   | 

245   168  exp            ::= IF exp THEN exp ELSE exp 
246   169                   | casehead caseexplist ENDCASE => exp 
247   170                   | lhs ← exp 
248   171                   | [ explist ] ← exp 
249   172                   | ERROR 
250   199                   | transferop lhs 
251   250                   | disjunct 

252   173  disjunct       ::= disjunct OR conjunct 
253 C 250                   | conjunct 

254   174  conjunct       ::= conjunct AND negation 
255 C 250                   | negation 

256   175  negation       ::= ~ relation 
257   175                   | NOT relation 
258 C 250                   | relation 

259   176  relation       ::= sum optrelation 
260   250                   | sum 

261   176  sum            ::= sum addop product 
262 C 250                   | product 

263   176  product        ::= product multop factor 
264 C 250                   | factor 

265   177  optrelation    ::= NOT relationtail 
266   250                   | relationtail 

267   178  relationtail   ::= IN range 
268   250                   | relop sum 

269   179  relop          ::= = 
270   180                   | # 
271   181                   | < 
272   182                   | <= 
273   183                   | > 
274   184                   | >= 

275   185  addop          ::= + 
276   186                   | - 

277   187  multop         ::= * 
278   188                   | / 
279   189                   | MOD 

280   190  factor         ::= addop primary 
281 C 250                   | primary 

282   191  primary        ::= [ explist ] 
283   192                   | prefixop [ orderlist ] 
284   193                   | VAL [ orderlist ] 
285   194                   | ALL [ orderlist ] 
286   195                   | new [ typeexp initialization optcatch ] 
287   196                   | cons [ explist optcatch ] 
288   197                   | listcons [ explist ] 
289   198                   | NIL 
290   199                   | typeop [ typeexp ] 
291   201                   | SIZE [ typeexp ] 
292   202                   | SIZE [ typeexp , exp ] 
293   203                   | ISTYPE [ exp , typeexp ] 
294   204                   | @ lhs 
295   205                   | DESCRIPTOR [ desclist ] 
296   250                   | lhs 

297   200  qualifier      ::= . prefixop 
298   200                   | . typeop 
299   201                   | . SIZE 
300   216                   | [ explist optcatch ] 
301   217                   | . id 
302   218                   | ↑ 

303   206  lhs            ::= id 
304   207                   | num 
305   207                   | string 
306   208                   | lnum 
307   209                   | flnum 
308   210                   | char 
309   211                   | lstring 
310   212                   | atom 
311   213                   | NARROW [ exp opttype optcatch ] 
312   214                   | LOOPHOLE [ exp opttype ] 
313   215                   | APPLY [ exp , exp optcatch ] 
314   250                   | ( exp ) 
315   250                   | lhs qualifier 

316   219  optcatch       ::= ! catchlist 
317   249                   | 

318   220  transferop     ::= SIGNAL 
319   221                   | ERROR 
320   222                   | START 
321   223                   | JOIN 
322   224                   | NEW 
323   225                   | FORK 

324   226  prefixop       ::= LONG 
325   227                   | ABS 
326   228                   | PRED 
327   229                   | SUCC 
328   230                   | ORD 
329   231                   | MIN 
330   232                   | MAX 
331   233                   | BASE 
332   234                   | LENGTH 

333   235  typeop         ::= CODE 
334   236                   | FIRST 
335   237                   | LAST 
336   238                   | NIL 

337   239  desclist       ::= exp , exp opttype 
338   250                   | exp 

339   240  directory      ::= DIRECTORY ; 
340   246                   | DIRECTORY includelist ; 
341   251                   | 

342   240  imports        ::= IMPORTS 
343   246                   | IMPORTS modulelist 
344   251                   | 

345   240  pointerprefix  ::= POINTER 
346   250                   | POINTER interval 

347   240  free           ::= FREE 
348   250                   | lhs . FREE 

349   240  new            ::= NEW 
350   250                   | lhs . NEW 

351   240  cons           ::= CONS 
352   250                   | lhs . CONS 

353   240  listcons       ::= LIST 
354   250                   | lhs . LIST 

355   240  exports        ::= EXPORTS 
356   246                   | EXPORTS modulelist 
357   251                   | 

358   240  fieldlist      ::= [ ] 
359   246                   | [ pairlist ] 
360   246                   | [ typelist ] 

361   241  using          ::= USING [ ] 
362   250                   | USING [ idlist ] 
363   251                   | 

364   242  elementlist    ::= 
365   250                   | elementlist' 

366   242  casestmtlist   ::= 
367   250                   | casestmtlist' 
368   250                   | casestmtlist' ; 

369   242  statementlist  ::= 
370   250                   | statementlist' 
371   250                   | statementlist' ; 

372   242  exitlist       ::= 
373   250                   | exitlist' 
374   250                   | exitlist' ; 

375   242  catchhead      ::= 
376   244                   | catchhead catchcase ; 

377   242  caseexplist    ::= 
378   250                   | caseexplist' 
379   250                   | caseexplist' , 

380   243  declist        ::= declaration 
381   244                   | declist ; declaration 

382   243  pairlist       ::= pairitem 
383   244                   | pairlist , pairitem 

384   243  variantlist    ::= variantitem 
385   244                   | variantlist , variantitem 

386   243  orderlist      ::= optexp 
387   244                   | orderlist , optexp 

388   243  lhslist        ::= lhs 
389   244                   | lhslist , lhs 

390   243  includelist    ::= includeitem 
391   244                   | includelist , includeitem 

392   243  modulelist     ::= moduleitem 
393   244                   | modulelist , moduleitem 

394   243  elementlist'   ::= element 
395   244                   | elementlist' , element 

396   243  bindlist       ::= binditem 
397   244                   | bindlist , binditem 

398   243  statementlist' ::= statement 
399   244                   | statementlist' ; statement 

400   243  casestmtlist'  ::= casestmtitem 
401   244                   | casestmtlist' ; casestmtitem 

402   243  caselabel'     ::= casetest 
403   244                   | caselabel' , casetest 

404   243  exitlist'      ::= exititem 
405   244                   | exitlist' ; exititem 

406   243  keylist        ::= keyitem 
407   244                   | keylist , keyitem 

408   243  caseexplist'   ::= caseexpitem 
409   244                   | caseexplist' , caseexpitem 

410   245  identlist      ::= identlist' 

411   245  idlist         ::= idlist' 

412   245  explist        ::= orderlist 
413   245                   | keylist 

414   246  open           ::= OPEN bindlist ; 
415   251                   | 

416   247  class          ::= PROGRAM 
417   248                   | MONITOR 

418   247  casehead       ::= SELECT exp FROM 
419   248                   | WITH binditem SELECT optexp FROM 

420   248  readonly       ::= READONLY 
421   249                   | 

422   248  ordered        ::= ORDERED 
423   249                   | 

424   248  base           ::= BASE 
425   249                   | 

426   248  packed         ::= PACKED 
427   249                   | 

428   248  heap           ::= UNCOUNTED 
429   249                   | 

430   248  inline         ::= INLINE 
431   249                   | 

432   250  arguments      ::= arglist returnlist 

433   250  interface      ::= imports exports shares 

434   250  tilde          ::= ~ 
435   250                   | = 

436   250  shares         ::= SHARES idlist 
437   251                   | 

438   250  default        ::= ← defaultopt 
439   251                   | 

440   250  optsize        ::= [ exp ] 
441   251                   | 

442   250  bounds         ::= exp .. exp 

443   250  length         ::= [ exp ] 

444   250  indextype      ::= typeexp 
445   251                   | 

446   250  catchany       ::= ANY => statement 

447   250  trash          ::= TRASH 
448   250                   | NULL 

449   250  opttype        ::= , typeexp 
450   251                   | 

451   252  checked        ::= 
452   253                   | CHECKED 
453   254                   | TRUSTED 
454   255                   | UNCHECKED