1 /*
2  * A n t l r  T r a n s l a t i o n  H e a d e r
3  *
4  * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
5  * Purdue University Electrical Engineering
6  * With AHPCRC, University of Minnesota
7  * ANTLR Version 1.33MR33
8  *
9  *   ..\bin\antlr -gh antlr.g
10  *
11  */
12 
13 #define ANTLR_VERSION	13333
14 #include "pcctscfg.h"
15 #include "pccts_stdio.h"
16 
17 #include "pcctscfg.h"
18 #include "set.h"
19 #include <ctype.h>
20 #include "syn.h"
21 #include "hash.h"
22 #include "generic.h"
23 #define zzcr_attr(attr,tok,t)
24 #define zzSET_SIZE 20
25 #include "antlr.h"
26 #include "tokens.h"
27 #include "dlgdef.h"
28 #include "mode.h"
29 
30 /* MR23 In order to remove calls to PURIFY use the antlr -nopurify option */
31 
32 #ifndef PCCTS_PURIFY
33 #define PCCTS_PURIFY(r,s) memset((char *) &(r),'\0',(s));
34 #endif
35 
36 ANTLR_INFO
37 
38 
39 /* MR20 G. Hobbelt For Borland C++ 4.x & 5.x compiling with ALL warnings enabled */
40 #if defined(__TURBOC__)
41 #pragma warn -aus  /* unused assignment of 'xxx' */
42 #endif
43 
44 
45 #ifdef __USE_PROTOS
46 static void chkToken(char *, char *, char *, int);
47 #else
48 static void chkToken();
49 #endif
50 
51 #ifdef __USE_PROTOS
52 static int isDLGmaxToken(char *Token);				     /* MR3 */
53 #else
54 static int isDLGmaxToken();				                             /* MR3 */
55 #endif
56 
57 static int class_nest_level = 0;
58 
59 /* MR20 G. Hobbelt extern definitions moved to antlr.h */
60 
61 
62 
63 void
64 #ifdef __USE_PROTOS
grammar(void)65 grammar(void)
66 #else
67 grammar()
68 #endif
69 {
70   zzRULE;
71   zzBLOCK(zztasp1);
72   zzMake0;
73   {
74   Graph g;
75   {
76     zzBLOCK(zztasp2);
77     zzMake0;
78     {
79     for (;;) {
80       if ( !((setwd1[LA(1)]&0x1))) break;
81       if ( (LA(1)==94) ) {
82         zzmatch(94); zzCONSUME;
83         zzmatch(Action);
84 
85         if ( HdrAction==NULL ) {
86           HdrAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
87           require(HdrAction!=NULL, "rule grammar: cannot allocate header action");
88           strcpy(HdrAction, LATEXT(1));
89         }
90         else warn("additional #header statement ignored");
91  zzCONSUME;
92 
93       }
94       else {
95         if ( (LA(1)==95) ) {
96           zzmatch(95); zzCONSUME;
97           zzmatch(Action);
98 
99           if ( FirstAction==NULL ) {
100             FirstAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
101             require(FirstAction!=NULL, "rule grammar: cannot allocate #first action");
102             strcpy(FirstAction, LATEXT(1));
103           } else {
104             warn("additional #first statement ignored");
105           };
106  zzCONSUME;
107 
108         }
109         else {
110           if ( (LA(1)==96) ) {
111             zzmatch(96); zzCONSUME;
112             zzmatch(QuotedTerm);
113 
114             if ( GenCC ) {
115               warn("#parser meta-op incompatible with -CC; ignored");
116             }
117             else {
118               if ( strcmp(ParserName,"zzparser")==0 ) {
119                 ParserName=StripQuotes(mystrdup(LATEXT(1)));
120                 if ( RulePrefix[0]!='\0' )
121                 {
122                   warn("#parser meta-op incompatible with '-gp prefix'; '-gp' ignored");
123                   RulePrefix[0]='\0';
124                 }
125               }
126               else warn("additional #parser statement ignored");
127             }
128  zzCONSUME;
129 
130           }
131           else {
132             if ( (LA(1)==97) ) {
133               zzmatch(97); zzCONSUME;
134               zzmatch(QuotedTerm);
135               {
136                 char *fname;
137                 zzantlr_state st; FILE *f; struct zzdlg_state dst;
138                 UserTokenDefsFile = mystrdup(LATEXT(1));
139                 zzsave_antlr_state(&st);
140                 zzsave_dlg_state(&dst);
141                 fname = mystrdup(LATEXT(1));
142                 f = fopen(StripQuotes(fname), "r");
143                 if ( f==NULL ) {warn(eMsg1("cannot open token defs file '%s'", fname+1));}
144                 else {
145                   ANTLRm(enum_file(fname+1), f, PARSE_ENUM_FILE);
146                   UserDefdTokens = 1;
147                 }
148                 zzrestore_antlr_state(&st);
149                 zzrestore_dlg_state(&dst);
150               }
151  zzCONSUME;
152 
153             }
154             else break; /* MR6 code for exiting loop "for sure" */
155           }
156         }
157       }
158       zzLOOP(zztasp2);
159     }
160     zzEXIT(zztasp2);
161     }
162   }
163   {
164     zzBLOCK(zztasp2);
165     zzMake0;
166     {
167     for (;;) {
168       if ( !((setwd1[LA(1)]&0x2))) break;
169       if ( (LA(1)==Action) ) {
170         zzmatch(Action);
171         {
172           UserAction *ua = newUserAction(LATEXT(1));
173           ua->file = action_file; ua->line = action_line;
174           if ( class_nest_level>0 ) list_add(&class_before_actions, ua);
175           else list_add(&BeforeActions, ua);
176         }
177  zzCONSUME;
178 
179       }
180       else {
181         if ( (LA(1)==108) ) {
182           laction();
183         }
184         else {
185           if ( (LA(1)==109) ) {
186             lmember();
187           }
188           else {
189             if ( (LA(1)==110) ) {
190               lprefix();
191             }
192             else {
193               if ( (LA(1)==116) ) {
194                 aLexclass();
195               }
196               else {
197                 if ( (LA(1)==120) ) {
198                   token();
199                 }
200                 else {
201                   if ( (LA(1)==117) ) {
202                     error();
203                   }
204                   else {
205                     if ( (LA(1)==118) ) {
206                       tclass();
207                     }
208                     else {
209                       if ( (LA(1)==111) ) {
210                         aPred();
211                       }
212                       else {
213                         if ( (LA(1)==133) ) {
214                           default_exception_handler();
215                         }
216                         else {
217                           if ( (LA(1)==99) ) {
218                             class_def();
219                           }
220                           else {
221                             if ( (LA(1)==98) ) {
222                               zzmatch(98);
223 
224                               if ( class_nest_level==0 )
225                               warn("missing class definition for trailing '}'");
226                               class_nest_level--;
227  zzCONSUME;
228 
229                             }
230                             else break; /* MR6 code for exiting loop "for sure" */
231                           }
232                         }
233                       }
234                     }
235                   }
236                 }
237               }
238             }
239           }
240         }
241       }
242       zzLOOP(zztasp2);
243     }
244     zzEXIT(zztasp2);
245     }
246   }
247   rule();
248   g=zzaArg(zztasp1,3); SynDiag = (Junction *) zzaArg(zztasp1,3 ).left;
249   {
250     zzBLOCK(zztasp2);
251     zzMake0;
252     {
253     for (;;) {
254       if ( !((setwd1[LA(1)]&0x4))) break;
255       if ( (LA(1)==NonTerminal) ) {
256         rule();
257         if ( zzaArg(zztasp2,1 ).left!=NULL ) {
258           g.right = NULL;
259 
260 /* MR21a */             /*  Avoid use of a malformed graph when CannotContinue */
261           /* MR21a */             /*  is already set                                     */
262           /* MR21a */
263           /* MR21a */             if (! (CannotContinue && g.left == NULL)) {
264             /* MR21a */               g = Or(g, zzaArg(zztasp2,1));
265             /* MR21a */             }
266           /* MR21a */		      }
267       }
268       else {
269         if ( (LA(1)==116) ) {
270           aLexclass();
271         }
272         else {
273           if ( (LA(1)==120) ) {
274             token();
275           }
276           else {
277             if ( (LA(1)==117) ) {
278               error();
279             }
280             else {
281               if ( (LA(1)==118) ) {
282                 tclass();
283               }
284               else {
285                 if ( (LA(1)==111) ) {
286                   aPred();
287                 }
288                 else {
289                   if ( (LA(1)==99) ) {
290                     class_def();
291                   }
292                   else {
293                     if ( (LA(1)==98) ) {
294                       zzmatch(98);
295 
296                       if ( class_nest_level==0 )
297                       warn("missing class definition for trailing '}'");
298                       class_nest_level--;
299  zzCONSUME;
300 
301                     }
302                     else break; /* MR6 code for exiting loop "for sure" */
303                   }
304                 }
305               }
306             }
307           }
308         }
309       }
310       zzLOOP(zztasp2);
311     }
312     zzEXIT(zztasp2);
313     }
314   }
315   {
316     zzBLOCK(zztasp2);
317     zzMake0;
318     {
319     for (;;) {
320       if ( !((setwd1[LA(1)]&0x8))) break;
321       if ( (LA(1)==Action) ) {
322         zzmatch(Action);
323         {
324           UserAction *ua = newUserAction(LATEXT(1));
325           ua->file = action_file; ua->line = action_line;
326           if ( class_nest_level>0 ) list_add(&class_after_actions, ua);
327           else list_add(&AfterActions, ua);
328         }
329  zzCONSUME;
330 
331       }
332       else {
333         if ( (LA(1)==108) ) {
334           laction();
335         }
336         else {
337           if ( (LA(1)==109) ) {
338             lmember();
339           }
340           else {
341             if ( (LA(1)==110) ) {
342               lprefix();
343             }
344             else {
345               if ( (LA(1)==117) ) {
346                 error();
347               }
348               else {
349                 if ( (LA(1)==118) ) {
350                   tclass();
351                 }
352                 else {
353                   if ( (LA(1)==99) ) {
354                     class_def();
355                   }
356                   else {
357                     if ( (LA(1)==111) ) {
358                       aPred();
359                     }
360                     else {
361                       if ( (LA(1)==98) ) {
362                         zzmatch(98);
363 
364                         if ( class_nest_level==0 )
365                         warn("missing class definition for trailing '}'");
366                         class_nest_level--;
367  zzCONSUME;
368 
369                       }
370                       else break; /* MR6 code for exiting loop "for sure" */
371                     }
372                   }
373                 }
374               }
375             }
376           }
377         }
378       }
379       zzLOOP(zztasp2);
380     }
381     zzEXIT(zztasp2);
382     }
383   }
384   zzmatch(Eof); zzCONSUME;
385   zzEXIT(zztasp1);
386   return;
387 fail:
388   zzEXIT(zztasp1);
389   CannotContinue=TRUE;
390   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
391   zzresynch(setwd1, 0x10);
392   }
393 }
394 
395 void
396 #ifdef __USE_PROTOS
class_def(void)397 class_def(void)
398 #else
399 class_def()
400 #endif
401 {
402   zzRULE;
403   zzBLOCK(zztasp1);
404   zzMake0;
405   {
406   int go=1; char name[MaxRuleName+1];
407   zzmatch(99); zzCONSUME;
408   {
409     zzBLOCK(zztasp2);
410     zzMake0;
411     {
412     if ( (LA(1)==NonTerminal) ) {
413       zzmatch(NonTerminal);
414       if(go) strncpy(name,LATEXT(1),MaxRuleName);
415  zzCONSUME;
416 
417     }
418     else {
419       if ( (LA(1)==TokenTerm) ) {
420         zzmatch(TokenTerm);
421         if(go) strncpy(name,LATEXT(1),MaxRuleName);
422  zzCONSUME;
423 
424       }
425       else {zzFAIL(1,zzerr1,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
426     }
427     zzEXIT(zztasp2);
428     }
429   }
430 
431   if ( CurrentClassName[0]!='\0' && strcmp(CurrentClassName,name)!=0
432   && GenCC ) {
433     err("only one grammar class allowed in this release");
434     go = 0;
435   }
436   else strcpy(CurrentClassName, name);
437   if ( !GenCC ) { err("class meta-op used without C++ option"); }
438   {
439     zzBLOCK(zztasp2);
440     zzMake0;
441     {
442     while ( (setwd1[LA(1)]&0x20) ) {
443       zzsetmatch(zzerr2, zzerr3);
444       if (ClassDeclStuff == NULL) {
445         /* MR10 */                   ClassDeclStuff=(char *)calloc(MaxClassDeclStuff+1,sizeof(char));
446         /* MR10 */              };
447       /* MR10 */              strncat(ClassDeclStuff," ",MaxClassDeclStuff);
448       /* MR10 */              strncat(ClassDeclStuff,LATEXT(1),MaxClassDeclStuff);
449       /* MR22 */              do {
450         /* MR22 */                if (0 == strcmp(LATEXT(1),"public")) break;
451         /* MR22 */                if (0 == strcmp(LATEXT(1),"private")) break;
452         /* MR22 */                if (0 == strcmp(LATEXT(1),"protected")) break;
453         /* MR22 */                if (0 == strcmp(LATEXT(1),"virtual")) break;
454         /* MR22 */                if (0 == strcmp(LATEXT(1),",")) break;
455         /* MR22 */                if (0 == strcmp(LATEXT(1),":")) break;
456         /* MR22 */                if (BaseClassName != NULL) break;
457         /* MR22 */                BaseClassName=(char *)calloc(strlen(LATEXT(1))+1,sizeof(char));
458         /* MR22 */                require(BaseClassName!=NULL, "rule grammar: cannot allocate base class name");
459         /* MR22 */				  strcpy(BaseClassName,LATEXT(1));
460         /* MR22 */              } while (0);
461       /* MR10 */
462  zzCONSUME;
463 
464       zzLOOP(zztasp2);
465     }
466     zzEXIT(zztasp2);
467     }
468   }
469   zzmatch(102);
470 
471   no_classes_found = 0;
472   if ( class_nest_level>=1 ) {warn("cannot have nested classes");}
473   else class_nest_level++;
474  zzCONSUME;
475 
476   zzEXIT(zztasp1);
477   return;
478 fail:
479   zzEXIT(zztasp1);
480   CannotContinue=TRUE;
481   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
482   zzresynch(setwd1, 0x40);
483   }
484 }
485 
486 void
487 #ifdef __USE_PROTOS
rule(void)488 rule(void)
489 #else
490 rule()
491 #endif
492 {
493   zzRULE;
494   zzBLOCK(zztasp1);
495   zzMake0;
496   {
497 
498 
499 			ExceptionGroup *eg;
500   RuleEntry *q; Junction *p; Graph r; int f, l; ECnode *e;
501   set toksrefd, rulesrefd;
502   char *pdecl=NULL, *ret=NULL, *a; CurRetDef = CurParmDef = NULL;
503   CurExGroups = NULL;
504   CurElementLabels = NULL;
505   CurAstLabelsInActions = NULL; /* MR27 */
506   /* We want a new element label hash table for each rule */
507   if ( Elabel!=NULL ) killHashTable(Elabel);
508   Elabel = newHashTable();
509   attribsRefdFromAction = empty;
510   zzmatch(NonTerminal);
511   q=NULL;
512   if ( hash_get(Rname, LATEXT(1))!=NULL ) {
513     err(eMsg1("duplicate rule definition: '%s'",LATEXT(1)));
514     CannotContinue=TRUE;
515   }
516   else
517   {
518     q = (RuleEntry *)hash_add(Rname,
519     LATEXT(1),
520     (Entry *)newRuleEntry(LATEXT(1)));
521     CurRule = q->str;
522   }
523   CurRuleNode = q;
524   f = CurFile; l = zzline;
525   NumRules++;
526  zzCONSUME;
527 
528   {
529     zzBLOCK(zztasp2);
530     zzMake0;
531     {
532     if ( (LA(1)==103) ) {
533       zzmatch(103);
534       if ( q!=NULL ) q->noAST = TRUE;
535  zzCONSUME;
536 
537     }
538     else {
539       if ( (setwd1[LA(1)]&0x80) ) {
540       }
541       else {zzFAIL(1,zzerr4,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
542     }
543     zzEXIT(zztasp2);
544     }
545   }
546   {
547     zzBLOCK(zztasp2);
548     zzMake0;
549     {
550     ;
551     if ( (setwd2[LA(1)]&0x1) ) {
552       {
553         zzBLOCK(zztasp3);
554         zzMake0;
555         {
556         if ( (LA(1)==104) ) {
557           zzmatch(104); zzCONSUME;
558         }
559         else {
560           if ( (LA(1)==PassAction) ) {
561           }
562           else {zzFAIL(1,zzerr5,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
563         }
564         zzEXIT(zztasp3);
565         }
566       }
567       zzmatch(PassAction);
568       pdecl = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
569       require(pdecl!=NULL, "rule rule: cannot allocate param decl");
570       strcpy(pdecl, LATEXT(1));
571       CurParmDef = pdecl;
572  zzCONSUME;
573 
574     }
575     else {
576       if ( (setwd2[LA(1)]&0x2) ) {
577       }
578       else {zzFAIL(1,zzerr6,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
579     }
580     zzEXIT(zztasp2);
581     }
582   }
583   {
584     zzBLOCK(zztasp2);
585     zzMake0;
586     {
587     if ( (LA(1)==105) ) {
588       zzmatch(105); zzCONSUME;
589       zzmatch(PassAction);
590       ret = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
591       require(ret!=NULL, "rule rule: cannot allocate ret type");
592       strcpy(ret, LATEXT(1));
593       CurRetDef = ret;
594  zzCONSUME;
595 
596     }
597     else {
598       if ( (setwd2[LA(1)]&0x4) ) {
599       }
600       else {zzFAIL(1,zzerr7,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
601     }
602     zzEXIT(zztasp2);
603     }
604   }
605   {
606     zzBLOCK(zztasp2);
607     zzMake0;
608     {
609     if ( (LA(1)==QuotedTerm) ) {
610       zzmatch(QuotedTerm);
611       if ( q!=NULL ) q->egroup=mystrdup(LATEXT(1));
612  zzCONSUME;
613 
614     }
615     else {
616       if ( (LA(1)==106) ) {
617       }
618       else {zzFAIL(1,zzerr8,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
619     }
620     zzEXIT(zztasp2);
621     }
622   }
623 
624   if ( GenEClasseForRules && q!=NULL ) {
625     e = newECnode;
626     require(e!=NULL, "cannot allocate error class node");
627     if ( q->egroup == NULL ) {a = q->str; a[0] = (char)toupper(a[0]);}
628     else a = q->egroup;
629     if ( Tnum( a ) == 0 )
630     {
631       e->tok = addTname( a );
632       list_add(&eclasses, (char *)e);
633       if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);
634       /* refers to itself */
635       list_add(&(e->elist), mystrdup(q->str));
636     }
637     else {
638       warn(eMsg1("default errclass for '%s' would conflict with token/errclass/tokclass",a));
639       if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);
640       free((char *)e);
641     }
642   }
643   BlkLevel++;
644   if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");
645   /* MR23 */    CurBlockID_array[BlkLevel] = CurBlockID;
646   /* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;
647   zzmatch(106);
648   inAlt=1;
649  zzCONSUME;
650 
651   block( &toksrefd, &rulesrefd );
652   r = makeBlk(zzaArg(zztasp1,7),0, NULL /* pFirstSetSymbol */ );
653   CurRuleBlk = (Junction *)r.left;
654   CurRuleBlk->blockid = CurBlockID;
655   CurRuleBlk->jtype = RuleBlk;
656   if ( q!=NULL ) CurRuleBlk->rname = q->str;
657   CurRuleBlk->file = f;
658   CurRuleBlk->line = l;
659   CurRuleBlk->pdecl = pdecl;
660   CurRuleBlk->ret = ret;
661   CurRuleBlk->lock = makelocks();
662   CurRuleBlk->pred_lock = makelocks();
663   CurRuleBlk->tokrefs = toksrefd;
664   CurRuleBlk->rulerefs = rulesrefd;
665   p = newJunction();	/* add EndRule Node */
666   ((Junction *)r.right)->p1 = (Node *)p;
667   r.right = (Node *) p;
668   p->jtype = EndRule;
669   p->lock = makelocks();
670   p->pred_lock = makelocks();
671   CurRuleBlk->end = p;
672   if ( q!=NULL ) q->rulenum = NumRules;
673   zzaArg(zztasp1,7) = r;
674 
675   /* MR23 */      CurBlockID_array[BlkLevel] = (-1);
676   /* MR23 */      CurAltNum_array[BlkLevel] = (-1);
677   --BlkLevel;
678   altFixup();leFixup();egFixup();
679   zzmatch(107);
680   inAlt=0;
681  zzCONSUME;
682 
683   {
684     zzBLOCK(zztasp2);
685     zzMake0;
686     {
687     if ( (LA(1)==Action) ) {
688       zzmatch(Action);
689       a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
690       require(a!=NULL, "rule rule: cannot allocate error action");
691       strcpy(a, LATEXT(1));
692       CurRuleBlk->erraction = a;
693  zzCONSUME;
694 
695     }
696     else {
697       if ( (setwd2[LA(1)]&0x8) ) {
698       }
699       else {zzFAIL(1,zzerr9,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
700     }
701     zzEXIT(zztasp2);
702     }
703   }
704   {
705     zzBLOCK(zztasp2);
706     zzMake0;
707     {
708     while ( (LA(1)==133) ) {
709        eg  = exception_group();
710 
711       if ( eg!=NULL ) {
712         list_add(&CurExGroups, (void *)eg);
713         if (eg->label == NULL || *eg->label=='\0' ) q->has_rule_exception = 1;
714       }
715       zzLOOP(zztasp2);
716     }
717     zzEXIT(zztasp2);
718     }
719   }
720   if ( q==NULL ) zzaArg(zztasp1,0 ).left = NULL; else zzaArg(zztasp1,0) = zzaArg(zztasp1,7);
721   CurRuleBlk->exceptions = CurExGroups;
722   CurRuleBlk->el_labels = CurElementLabels;
723   CurRuleNode->ast_labels_in_actions = CurAstLabelsInActions;
724   CurRuleNode = NULL;
725   zzEXIT(zztasp1);
726   return;
727 fail:
728   zzEXIT(zztasp1);
729   CannotContinue=TRUE;
730   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
731   zzresynch(setwd2, 0x10);
732   }
733 }
734 
735 void
736 #ifdef __USE_PROTOS
laction(void)737 laction(void)
738 #else
739 laction()
740 #endif
741 {
742   zzRULE;
743   zzBLOCK(zztasp1);
744   zzMake0;
745   {
746   char *a;
747   zzmatch(108); zzCONSUME;
748   zzmatch(Action);
749 
750   a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
751   require(a!=NULL, "rule laction: cannot allocate action");
752   strcpy(a, LATEXT(1));
753   list_add(&LexActions, a);
754  zzCONSUME;
755 
756   zzEXIT(zztasp1);
757   return;
758 fail:
759   zzEXIT(zztasp1);
760   CannotContinue=TRUE;
761   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
762   zzresynch(setwd2, 0x20);
763   }
764 }
765 
766 void
767 #ifdef __USE_PROTOS
lmember(void)768 lmember(void)
769 #else
770 lmember()
771 #endif
772 {
773   zzRULE;
774   zzBLOCK(zztasp1);
775   zzMake0;
776   {
777   char *a;
778   zzmatch(109); zzCONSUME;
779   zzmatch(Action);
780 
781   /* MR1 */		if (! GenCC) {
782     /* MR1 */		  err("Use #lexmember only in C++ mode (to insert code in DLG class header");
783     /* MR1 */	        } else {
784     /* MR1 */		  a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
785     /* MR1 */		  require(a!=NULL, "rule lmember: cannot allocate action");
786     /* MR1 */		  strcpy(a, LATEXT(1));
787     /* MR1 */		  list_add(&LexMemberActions, a);
788     /* MR1 */		};
789   /* MR1 */
790  zzCONSUME;
791 
792   zzEXIT(zztasp1);
793   return;
794 fail:
795   zzEXIT(zztasp1);
796   CannotContinue=TRUE;
797   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
798   zzresynch(setwd2, 0x40);
799   }
800 }
801 
802 void
803 #ifdef __USE_PROTOS
lprefix(void)804 lprefix(void)
805 #else
806 lprefix()
807 #endif
808 {
809   zzRULE;
810   zzBLOCK(zztasp1);
811   zzMake0;
812   {
813   char *a;
814   zzmatch(110); zzCONSUME;
815   zzmatch(Action);
816 
817   /* MR1 */		if (! GenCC) {
818     /* MR1 */		  err("Use #lexprefix only in C++ mode (to insert code in DLG class header");
819     /* MR1 */	        } else {
820     /* MR1 */		  a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
821     /* MR1 */		  require(a!=NULL, "rule lprefix: cannot allocate action");
822     /* MR1 */		  strcpy(a, LATEXT(1));
823     /* MR1 */		  list_add(&LexPrefixActions, a);
824     /* MR1 */		};
825   /* MR1 */
826  zzCONSUME;
827 
828   zzEXIT(zztasp1);
829   return;
830 fail:
831   zzEXIT(zztasp1);
832   CannotContinue=TRUE;
833   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
834   zzresynch(setwd2, 0x80);
835   }
836 }
837 
838 void
839 #ifdef __USE_PROTOS
aPred(void)840 aPred(void)
841 #else
842 aPred()
843 #endif
844 {
845   zzRULE;
846   zzBLOCK(zztasp1);
847   zzMake0;
848   {
849   PredEntry     *predEntry=NULL;
850   char          *name=NULL;
851   Predicate     *predExpr=NULL;
852   char          *predLiteral=NULL;
853   int           save_file;
854   int           save_line;
855   int           predExprPresent=0;
856   zzmatch(111);
857 
858   MR_usingPredNames=1;      /* will need to use -mrhoist version of genPredTree */
859  zzCONSUME;
860 
861   zzmatch(TokenTerm);
862   name=mystrdup(LATEXT(1));
863  zzCONSUME;
864 
865 
866   /* don't free - referenced in predicates */
867 
868             CurPredName=(char *)calloc(1,strlen(name) + 10);
869   strcat(CurPredName,"#pred ");
870   strcat(CurPredName,name);
871 
872             predEntry=(PredEntry *) hash_get(Pname,name);
873   if (predEntry != NULL) {
874   warnFL(eMsg1("#pred %s previously defined - ignored",name),
875   FileStr[action_file],action_line);
876   name=NULL;
877 };
878   {
879     zzBLOCK(zztasp2);
880     zzMake0;
881     {
882     if ( (LA(1)==Pred) ) {
883       zzmatch(Pred);
884       predLiteral=mystrdup(LATEXT(1));
885       save_line=action_line;
886       save_file=action_file;
887  zzCONSUME;
888 
889       {
890         zzBLOCK(zztasp3);
891         zzMake0;
892         {
893         if ( (setwd3[LA(1)]&0x1) ) {
894            predExpr  = predOrExpr();
895 
896           predExprPresent=1;
897         }
898         else {
899           if ( (setwd3[LA(1)]&0x2) ) {
900           }
901           else {zzFAIL(1,zzerr10,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
902         }
903         zzEXIT(zztasp3);
904         }
905       }
906       if (predLiteral != NULL && name != NULL) {
907 
908                       /*
909         *  predExpr may be NULL due to syntax errors
910         *    or simply omitted by the user
911         */
912 
913                       predEntry=newPredEntry(name);
914         predEntry->file=save_file;
915         predEntry->line=save_line;
916         predExpr=MR_predFlatten(predExpr);
917         predEntry->predLiteral=predLiteral;
918         if (! predExprPresent || predExpr == NULL) {
919           predExpr=new_pred();
920           predExpr->expr=predLiteral;
921           predExpr->source=newActionNode();
922           predExpr->source->action=predExpr->expr;
923           predExpr->source->rname=CurPredName;
924           predExpr->source->line=action_line;
925           predExpr->source->file=action_file;
926           predExpr->source->is_predicate=1;
927           predExpr->k=predicateLookaheadDepth(predExpr->source);
928         };
929         predEntry->pred=predExpr;
930         hash_add(Pname,name,(Entry *)predEntry);
931         predExpr=NULL;
932       };
933       predicate_free(predExpr);
934     }
935     else {
936       if ( (setwd3[LA(1)]&0x4) ) {
937         save_line=zzline; save_file=CurFile;
938          predExpr  = predOrExpr();
939 
940         if (predExpr != NULL && name != NULL) {
941           predEntry=newPredEntry(name);
942           predEntry->file=CurFile;
943           predEntry->line=zzline;
944           predExpr=MR_predFlatten(predExpr);
945           predEntry->pred=predExpr;
946           hash_add(Pname,name,(Entry *)predEntry);
947           predExpr=NULL;
948         };
949         predicate_free(predExpr);
950       }
951       else {zzFAIL(1,zzerr11,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
952     }
953     zzEXIT(zztasp2);
954     }
955   }
956   {
957     zzBLOCK(zztasp2);
958     zzMake0;
959     {
960     if ( (LA(1)==107) ) {
961       zzmatch(107); zzCONSUME;
962     }
963     else {
964       if ( (setwd3[LA(1)]&0x8) ) {
965       }
966       else {zzFAIL(1,zzerr12,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
967     }
968     zzEXIT(zztasp2);
969     }
970   }
971   zzEXIT(zztasp1);
972   return;
973 fail:
974   zzEXIT(zztasp1);
975   predicate_free(predExpr);
976   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
977   zzresynch(setwd3, 0x10);
978   }
979 }
980 
981 Predicate *
982 #ifdef __USE_PROTOS
predOrExpr(void)983 predOrExpr(void)
984 #else
985 predOrExpr()
986 #endif
987 {
988   Predicate *   _retv;
989   zzRULE;
990   zzBLOCK(zztasp1);
991   PCCTS_PURIFY(_retv,sizeof(Predicate *  ))
992   zzMake0;
993   {
994   Predicate     *ORnode;
995   Predicate     *predExpr;
996   Predicate     **tail=NULL;
997    predExpr  = predAndExpr();
998 
999 
1000   ORnode=new_pred();
1001   ORnode->expr=PRED_OR_LIST;
1002   if (predExpr != NULL) {
1003     ORnode->down=predExpr;
1004     tail=&predExpr->right;
1005   };
1006   {
1007     zzBLOCK(zztasp2);
1008     zzMake0;
1009     {
1010     while ( (LA(1)==112) ) {
1011       zzmatch(112); zzCONSUME;
1012        predExpr  = predAndExpr();
1013 
1014 
1015       if (predExpr != NULL) {
1016         *tail=predExpr;
1017         tail=&predExpr->right;
1018       };
1019       zzLOOP(zztasp2);
1020     }
1021     zzEXIT(zztasp2);
1022     }
1023   }
1024 
1025   _retv=ORnode;
1026   ORnode=NULL;
1027   zzEXIT(zztasp1);
1028   return _retv;
1029 fail:
1030   zzEXIT(zztasp1);
1031   predicate_free(ORnode);
1032   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1033   zzresynch(setwd3, 0x20);
1034   return _retv;
1035   }
1036 }
1037 
1038 Predicate *
1039 #ifdef __USE_PROTOS
predAndExpr(void)1040 predAndExpr(void)
1041 #else
1042 predAndExpr()
1043 #endif
1044 {
1045   Predicate *   _retv;
1046   zzRULE;
1047   zzBLOCK(zztasp1);
1048   PCCTS_PURIFY(_retv,sizeof(Predicate *  ))
1049   zzMake0;
1050   {
1051   Predicate     *ANDnode;
1052   Predicate     *predExpr;
1053   Predicate     **tail=NULL;
1054    predExpr  = predPrimary();
1055 
1056 
1057   ANDnode=new_pred();
1058   ANDnode->expr=PRED_AND_LIST;
1059   if (predExpr != NULL) {
1060     ANDnode->down=predExpr;
1061     tail=&predExpr->right;
1062   };
1063   {
1064     zzBLOCK(zztasp2);
1065     zzMake0;
1066     {
1067     while ( (LA(1)==113) ) {
1068       zzmatch(113); zzCONSUME;
1069        predExpr  = predPrimary();
1070 
1071 
1072       if (predExpr != NULL) {
1073         *tail=predExpr;
1074         tail=&predExpr->right;
1075       };
1076       zzLOOP(zztasp2);
1077     }
1078     zzEXIT(zztasp2);
1079     }
1080   }
1081 
1082   _retv=ANDnode;
1083   ANDnode=NULL;
1084   zzEXIT(zztasp1);
1085   return _retv;
1086 fail:
1087   zzEXIT(zztasp1);
1088   predicate_free(ANDnode);
1089   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1090   zzresynch(setwd3, 0x40);
1091   return _retv;
1092   }
1093 }
1094 
1095 Predicate *
1096 #ifdef __USE_PROTOS
predPrimary(void)1097 predPrimary(void)
1098 #else
1099 predPrimary()
1100 #endif
1101 {
1102   Predicate *   _retv;
1103   zzRULE;
1104   zzBLOCK(zztasp1);
1105   PCCTS_PURIFY(_retv,sizeof(Predicate *  ))
1106   zzMake0;
1107   {
1108 
1109   char          *name=NULL;
1110   PredEntry     *predEntry=NULL;
1111   Predicate     *predExpr=NULL;
1112   if ( (LA(1)==TokenTerm) ) {
1113     zzmatch(TokenTerm);
1114     name=mystrdup(LATEXT(1));
1115  zzCONSUME;
1116 
1117 
1118     predEntry=(PredEntry *) hash_get(Pname,name);
1119     if (predEntry == NULL) {
1120       warnFL(eMsg1("no previously defined #pred with name \"%s\"",name),
1121       FileStr[CurFile],zzline);
1122       name=NULL;
1123       _retv=NULL;
1124     } else {
1125       predExpr=predicate_dup(predEntry->pred);
1126       predExpr->predEntry=predEntry;
1127       _retv=predExpr;
1128     };
1129   }
1130   else {
1131     if ( (LA(1)==114) ) {
1132       zzmatch(114); zzCONSUME;
1133        predExpr  = predOrExpr();
1134 
1135       zzmatch(115);
1136 
1137       _retv=predExpr;
1138  zzCONSUME;
1139 
1140     }
1141     else {
1142       if ( (LA(1)==103) ) {
1143         zzmatch(103); zzCONSUME;
1144          predExpr  = predPrimary();
1145 
1146 
1147         predExpr->inverted=!predExpr->inverted;
1148         _retv=predExpr;
1149       }
1150       else {zzFAIL(1,zzerr13,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1151     }
1152   }
1153   zzEXIT(zztasp1);
1154   return _retv;
1155 fail:
1156   zzEXIT(zztasp1);
1157 
1158   predicate_free(predExpr);
1159   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1160   zzresynch(setwd3, 0x80);
1161   return _retv;
1162   }
1163 }
1164 
1165 void
1166 #ifdef __USE_PROTOS
aLexclass(void)1167 aLexclass(void)
1168 #else
1169 aLexclass()
1170 #endif
1171 {
1172   zzRULE;
1173   zzBLOCK(zztasp1);
1174   zzMake0;
1175   {
1176   zzmatch(116); zzCONSUME;
1177   zzmatch(TokenTerm);
1178   lexclass(mystrdup(LATEXT(1)));
1179  zzCONSUME;
1180 
1181   zzEXIT(zztasp1);
1182   return;
1183 fail:
1184   zzEXIT(zztasp1);
1185   CannotContinue=TRUE;
1186   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1187   zzresynch(setwd4, 0x1);
1188   }
1189 }
1190 
1191 void
1192 #ifdef __USE_PROTOS
error(void)1193 error(void)
1194 #else
1195 error()
1196 #endif
1197 {
1198   zzRULE;
1199   zzBLOCK(zztasp1);
1200   zzMake0;
1201   {
1202   char *t=NULL; ECnode *e; int go=1; TermEntry *p;
1203   zzmatch(117); zzCONSUME;
1204   {
1205     zzBLOCK(zztasp2);
1206     zzMake0;
1207     {
1208     ;
1209     if ( (LA(1)==TokenTerm) ) {
1210       zzmatch(TokenTerm);
1211       t=mystrdup(LATEXT(1));
1212  zzCONSUME;
1213 
1214     }
1215     else {
1216       if ( (LA(1)==QuotedTerm) ) {
1217         zzmatch(QuotedTerm);
1218         t=mystrdup(LATEXT(1));
1219  zzCONSUME;
1220 
1221       }
1222       else {zzFAIL(1,zzerr14,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1223     }
1224     zzEXIT(zztasp2);
1225     }
1226   }
1227   e = newECnode;
1228   require(e!=NULL, "cannot allocate error class node");
1229   e->lexclass = CurrentLexClass;
1230   if ( Tnum( (t=StripQuotes(t)) ) == 0 )
1231   {
1232     if ( hash_get(Texpr, t) != NULL )
1233     warn(eMsg1("errclass name conflicts with regular expression  '%s'",t));
1234     e->tok = addTname( t );
1235     set_orel(e->tok, &imag_tokens);
1236     require((p=(TermEntry *)hash_get(Tname, t)) != NULL,
1237     "hash table mechanism is broken");
1238     p->classname = 1;	/* entry is errclass name, not token */
1239     list_add(&eclasses, (char *)e);
1240   }
1241   else
1242   {
1243   warn(eMsg1("redefinition of errclass or conflict w/token or tokclass '%s'; ignored",t));
1244   free( (char *)e );
1245   go=0;
1246 }
1247   zzmatch(102); zzCONSUME;
1248   {
1249     zzBLOCK(zztasp2);
1250     zzMake0;
1251     {
1252     if ( (LA(1)==NonTerminal) ) {
1253       zzmatch(NonTerminal);
1254       if ( go ) t=mystrdup(LATEXT(1));
1255  zzCONSUME;
1256 
1257     }
1258     else {
1259       if ( (LA(1)==TokenTerm) ) {
1260         zzmatch(TokenTerm);
1261         if ( go ) t=mystrdup(LATEXT(1));
1262  zzCONSUME;
1263 
1264       }
1265       else {
1266         if ( (LA(1)==QuotedTerm) ) {
1267           zzmatch(QuotedTerm);
1268           if ( go ) t=mystrdup(LATEXT(1));
1269  zzCONSUME;
1270 
1271         }
1272         else {zzFAIL(1,zzerr15,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1273       }
1274     }
1275     zzEXIT(zztasp2);
1276     }
1277   }
1278   if ( go ) list_add(&(e->elist), t);
1279   {
1280     zzBLOCK(zztasp2);
1281     zzMake0;
1282     {
1283     while ( (setwd4[LA(1)]&0x2) ) {
1284       {
1285         zzBLOCK(zztasp3);
1286         zzMake0;
1287         {
1288         if ( (LA(1)==NonTerminal) ) {
1289           zzmatch(NonTerminal);
1290           if ( go ) t=mystrdup(LATEXT(1));
1291  zzCONSUME;
1292 
1293         }
1294         else {
1295           if ( (LA(1)==TokenTerm) ) {
1296             zzmatch(TokenTerm);
1297             if ( go ) t=mystrdup(LATEXT(1));
1298  zzCONSUME;
1299 
1300           }
1301           else {
1302             if ( (LA(1)==QuotedTerm) ) {
1303               zzmatch(QuotedTerm);
1304               if ( go ) t=mystrdup(LATEXT(1));
1305  zzCONSUME;
1306 
1307             }
1308             else {zzFAIL(1,zzerr16,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1309           }
1310         }
1311         zzEXIT(zztasp3);
1312         }
1313       }
1314       if ( go ) list_add(&(e->elist), t);
1315       zzLOOP(zztasp2);
1316     }
1317     zzEXIT(zztasp2);
1318     }
1319   }
1320   zzmatch(98); zzCONSUME;
1321   zzEXIT(zztasp1);
1322   return;
1323 fail:
1324   zzEXIT(zztasp1);
1325   CannotContinue=TRUE;
1326   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1327   zzresynch(setwd4, 0x4);
1328   }
1329 }
1330 
1331 void
1332 #ifdef __USE_PROTOS
tclass(void)1333 tclass(void)
1334 #else
1335 tclass()
1336 #endif
1337 {
1338   zzRULE;
1339   zzBLOCK(zztasp1);
1340   zzMake0;
1341   {
1342   char *t=NULL; TCnode *e; int go=1,tok,totok; TermEntry *p, *term, *toterm;
1343   char *akaString=NULL; int save_file; int save_line;
1344   char *totext=NULL;
1345   zzmatch(118); zzCONSUME;
1346   zzmatch(TokenTerm);
1347   t=mystrdup(LATEXT(1));
1348  zzCONSUME;
1349 
1350   e = newTCnode;
1351   require(e!=NULL, "cannot allocate token class node");
1352   e->lexclass = CurrentLexClass;
1353   if ( Tnum( t ) == 0 )
1354   {
1355     e->tok = addTname( t );
1356     set_orel(e->tok, &imag_tokens);
1357     set_orel(e->tok, &tokclasses);
1358     require((p=(TermEntry *)hash_get(Tname, t)) != NULL,
1359     "hash table mechanism is broken");
1360     p->classname = 1;	/* entry is class name, not token */
1361     p->tclass = e;		/* save ptr to this tclass def */
1362     list_add(&tclasses, (char *)e);
1363   }
1364   else
1365   {
1366   warn(eMsg1("redefinition of tokclass or conflict w/token '%s'; ignored",t));
1367   free( (char *)e );
1368   go=0;
1369 }
1370   {
1371     zzBLOCK(zztasp2);
1372     zzMake0;
1373     {
1374     if ( (LA(1)==114) ) {
1375       zzmatch(114); zzCONSUME;
1376       zzmatch(QuotedTerm);
1377       akaString=mystrdup(StripQuotes(LATEXT(1)));
1378       /* MR11 */                   save_file=CurFile;save_line=zzline;
1379       /* MR23 */
1380  zzCONSUME;
1381 
1382       zzmatch(115); zzCONSUME;
1383     }
1384     else {
1385       if ( (LA(1)==102) ) {
1386       }
1387       else {zzFAIL(1,zzerr17,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1388     }
1389     zzEXIT(zztasp2);
1390     }
1391   }
1392 
1393   /* MR23 */         if (p!= NULL && akaString != NULL) {
1394     /* MR23 */           if (p->akaString != NULL) {
1395       /* MR23 */             if (strcmp(p->akaString,akaString) != 0) {
1396         /* MR23 */                warnFL(eMsg2("this #tokclass statment conflicts with a previous #tokclass %s(\"%s\") statement",
1397         /* MR23 */                              t,p->akaString),
1398         /* MR23 */			                    FileStr[save_file],save_line);
1399         /* MR23 */             };
1400       /* MR23 */            } else {
1401       /* MR23 */              p->akaString=akaString;
1402       /* MR23 */            };
1403     /* MR23 */          };
1404   /* MR23 */
1405   zzmatch(102); zzCONSUME;
1406   {
1407     zzBLOCK(zztasp2);
1408     int zzcnt=1;
1409     zzMake0;
1410     {
1411     do {
1412       {
1413         zzBLOCK(zztasp3);
1414         zzMake0;
1415         {
1416         if ( (LA(1)==TokenTerm) ) {
1417           zzmatch(TokenTerm);
1418           if ( go ) {
1419             term = (TermEntry *) hash_get(Tname, LATEXT(1));
1420             if ( term==NULL && UserDefdTokens ) {
1421               err("implicit token definition not allowed with #tokdefs");
1422               go = 0;
1423             }
1424             else {t=mystrdup(LATEXT(1)); tok=addTname(LATEXT(1));}
1425           }
1426  zzCONSUME;
1427 
1428           {
1429             zzBLOCK(zztasp4);
1430             zzMake0;
1431             {
1432             if ( (LA(1)==119) ) {
1433               zzmatch(119); zzCONSUME;
1434               zzmatch(TokenTerm);
1435               if ( go ) {
1436                 toterm = (TermEntry *) hash_get(Tname, LATEXT(1));
1437                 if ( toterm==NULL && UserDefdTokens ) {
1438                   err("implicit token definition not allowed with #tokdefs");
1439                   go = 0;
1440                 } else {
1441                   totext=mystrdup(LATEXT(1)); totok=addTname(LATEXT(1));
1442                 }
1443               }
1444  zzCONSUME;
1445 
1446             }
1447             else {
1448               if ( (setwd4[LA(1)]&0x8) ) {
1449               }
1450               else {zzFAIL(1,zzerr18,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1451             }
1452             zzEXIT(zztasp4);
1453             }
1454           }
1455         }
1456         else {
1457           if ( (LA(1)==QuotedTerm) ) {
1458             zzmatch(QuotedTerm);
1459             if ( go ) {
1460               term = (TermEntry *) hash_get(Texpr, LATEXT(1));
1461               if ( term==NULL && UserDefdTokens ) {
1462                 err("implicit token definition not allowed with #tokdefs");
1463                 go = 0;
1464               }
1465               else {t=mystrdup(LATEXT(1)); tok=addTexpr(LATEXT(1));}
1466             }
1467  zzCONSUME;
1468 
1469           }
1470           else {zzFAIL(1,zzerr19,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1471         }
1472         zzEXIT(zztasp3);
1473         }
1474       }
1475       if ( go ) {
1476         if (totext == NULL) {
1477           list_add(&(e->tlist), t);
1478         } else {
1479           list_add(&(e->tlist),"..");
1480           list_add(&(e->tlist),t);
1481           list_add(&(e->tlist),totext);
1482         }
1483         totext=NULL;
1484       }
1485       zzLOOP(zztasp2);
1486     } while ( (setwd4[LA(1)]&0x10) );
1487     zzEXIT(zztasp2);
1488     }
1489   }
1490   zzmatch(98); zzCONSUME;
1491   zzEXIT(zztasp1);
1492   return;
1493 fail:
1494   zzEXIT(zztasp1);
1495   CannotContinue=TRUE;
1496   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1497   zzresynch(setwd4, 0x20);
1498   }
1499 }
1500 
1501 void
1502 #ifdef __USE_PROTOS
token(void)1503 token(void)
1504 #else
1505 token()
1506 #endif
1507 {
1508   zzRULE;
1509   zzBLOCK(zztasp1);
1510   zzMake0;
1511   {
1512   char *t=NULL, *e=NULL, *a=NULL; int tnum=0;
1513   char *akaString=NULL; TermEntry *te;int save_file=0,save_line=0;
1514   zzmatch(120);
1515   tokenActionActive=1;
1516  zzCONSUME;
1517 
1518   {
1519     zzBLOCK(zztasp2);
1520     zzMake0;
1521     {
1522     if ( (LA(1)==TokenTerm) ) {
1523       zzmatch(TokenTerm);
1524       t=mystrdup(LATEXT(1));
1525  zzCONSUME;
1526 
1527       {
1528         zzBLOCK(zztasp3);
1529         zzMake0;
1530         {
1531         if ( (LA(1)==114) ) {
1532           zzmatch(114); zzCONSUME;
1533           zzmatch(QuotedTerm);
1534           akaString=mystrdup(StripQuotes(LATEXT(1)));
1535           /* MR11 */                   save_file=CurFile;save_line=zzline;
1536           /* MR11 */
1537  zzCONSUME;
1538 
1539           zzmatch(115); zzCONSUME;
1540         }
1541         else {
1542           if ( (setwd4[LA(1)]&0x40) ) {
1543           }
1544           else {zzFAIL(1,zzerr20,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1545         }
1546         zzEXIT(zztasp3);
1547         }
1548       }
1549       {
1550         zzBLOCK(zztasp3);
1551         zzMake0;
1552         {
1553         if ( (LA(1)==121) ) {
1554           zzmatch(121); zzCONSUME;
1555           zzmatch(122);
1556           tnum = atoi(LATEXT(1));
1557  zzCONSUME;
1558 
1559         }
1560         else {
1561           if ( (setwd4[LA(1)]&0x80) ) {
1562           }
1563           else {zzFAIL(1,zzerr21,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1564         }
1565         zzEXIT(zztasp3);
1566         }
1567       }
1568     }
1569     else {
1570       if ( (setwd5[LA(1)]&0x1) ) {
1571       }
1572       else {zzFAIL(1,zzerr22,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1573     }
1574     zzEXIT(zztasp2);
1575     }
1576   }
1577   {
1578     zzBLOCK(zztasp2);
1579     zzMake0;
1580     {
1581     if ( (LA(1)==QuotedTerm) ) {
1582       zzmatch(QuotedTerm);
1583       e=mystrdup(LATEXT(1));
1584  zzCONSUME;
1585 
1586     }
1587     else {
1588       if ( (setwd5[LA(1)]&0x2) ) {
1589       }
1590       else {zzFAIL(1,zzerr23,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1591     }
1592     zzEXIT(zztasp2);
1593     }
1594   }
1595   {
1596     zzBLOCK(zztasp2);
1597     zzMake0;
1598     {
1599     if ( (LA(1)==Action) ) {
1600       zzmatch(Action);
1601 
1602       a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
1603       require(a!=NULL, "rule token: cannot allocate action");
1604       strcpy(a, LATEXT(1));
1605  zzCONSUME;
1606 
1607     }
1608     else {
1609       if ( (setwd5[LA(1)]&0x4) ) {
1610       }
1611       else {zzFAIL(1,zzerr24,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1612     }
1613     zzEXIT(zztasp2);
1614     }
1615   }
1616   {
1617     zzBLOCK(zztasp2);
1618     zzMake0;
1619     {
1620     if ( (LA(1)==107) ) {
1621       zzmatch(107); zzCONSUME;
1622     }
1623     else {
1624       if ( (setwd5[LA(1)]&0x8) ) {
1625       }
1626       else {zzFAIL(1,zzerr25,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1627     }
1628     zzEXIT(zztasp2);
1629     }
1630   }
1631   chkToken(t, e, a, tnum);
1632   if (t != NULL) {
1633     te=(TermEntry *)hash_get(Tname,t);
1634     if (te != NULL && akaString != NULL) {
1635       if (te->akaString != NULL) {
1636         if (strcmp(te->akaString,akaString) != 0) {
1637           warnFL(eMsg2("this #token statment conflicts with a previous #token %s(\"%s\") statement",
1638           t,te->akaString),
1639           FileStr[save_file],save_line);
1640         };
1641       } else {
1642         te->akaString=akaString;
1643       };
1644     };
1645   };
1646   zzEXIT(zztasp1);
1647   return;
1648 fail:
1649   zzEXIT(zztasp1);
1650   CannotContinue=TRUE;
1651   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1652   zzresynch(setwd5, 0x10);
1653   }
1654 }
1655 
1656 void
1657 #ifdef __USE_PROTOS
block(set * toksrefd,set * rulesrefd)1658 block(set * toksrefd,set * rulesrefd)
1659 #else
1660 block(toksrefd,rulesrefd)
1661  set *toksrefd;
1662 set *rulesrefd ;
1663 #endif
1664 {
1665   zzRULE;
1666   zzBLOCK(zztasp1);
1667   zzMake0;
1668   {
1669 
1670   Graph g, b;
1671   set saveblah;
1672   int saveinalt = inAlt;
1673   ExceptionGroup *eg;
1674   * toksrefd = empty;
1675   * rulesrefd = empty;
1676   set_clr(AST_nodes_refd_in_actions);
1677   CurBlockID++;
1678   /* MR23 */      CurBlockID_array[BlkLevel] = CurBlockID;
1679   CurAltNum = 1;
1680   /* MR23 */      CurAltNum_array[BlkLevel] = CurAltNum;
1681   saveblah = attribsRefdFromAction;
1682   attribsRefdFromAction = empty;
1683   alt( toksrefd,rulesrefd );
1684   b = g = zzaArg(zztasp1,1);
1685 
1686   if ( ((Junction *)g.left)->p1->ntype == nAction )
1687   {
1688     ActionNode *actionNode=(ActionNode *)
1689     ( ( (Junction *)g.left) ->p1);
1690     if (!actionNode->is_predicate )
1691     {
1692       actionNode->init_action = TRUE;
1693       /* MR12c */  		if (actionNode->noHoist) {
1694         /* MR12c */           errFL("<<nohoist>> appears as init-action - use <<>> <<nohoist>>",
1695         /* MR12c */                       FileStr[actionNode->file],actionNode->line);
1696         /* MR12c */         };
1697     }
1698   }
1699   ((Junction *)g.left)->blockid = CurBlockID;
1700   {
1701     zzBLOCK(zztasp2);
1702     zzMake0;
1703     {
1704     while ( (LA(1)==133) ) {
1705        eg  = exception_group();
1706 
1707 
1708       if ( eg!=NULL ) {
1709         /* MR7 *****       	eg->altID = makeAltID(CurBlockID,CurAltNum);        *****/
1710         /* MR7 *****		CurAltStart->exception_label = eg->altID;           *****/
1711         list_add(&CurExGroups, (void *)eg);
1712       }
1713       zzLOOP(zztasp2);
1714     }
1715     zzEXIT(zztasp2);
1716     }
1717   }
1718   CurAltNum++;
1719   /* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;
1720   {
1721     zzBLOCK(zztasp2);
1722     zzMake0;
1723     {
1724     while ( (LA(1)==123) ) {
1725       zzmatch(123);
1726       inAlt=1;
1727  zzCONSUME;
1728 
1729       alt( toksrefd,rulesrefd );
1730       g = Or(g, zzaArg(zztasp2,2));
1731 
1732       ((Junction *)g.left)->blockid = CurBlockID;
1733       {
1734         zzBLOCK(zztasp3);
1735         zzMake0;
1736         {
1737         while ( (LA(1)==133) ) {
1738            eg  = exception_group();
1739 
1740 
1741           if ( eg!=NULL ) {
1742             /* MR7 *****       	eg->altID = makeAltID(CurBlockID,CurAltNum);        *****/
1743             /* MR7 *****		CurAltStart->exception_label = eg->altID;           *****/
1744             list_add(&CurExGroups, (void *)eg);
1745           }
1746           zzLOOP(zztasp3);
1747         }
1748         zzEXIT(zztasp3);
1749         }
1750       }
1751       CurAltNum++;
1752       /* MR23 */        CurAltNum_array[BlkLevel] = CurAltNum;
1753       zzLOOP(zztasp2);
1754     }
1755     zzEXIT(zztasp2);
1756     }
1757   }
1758   zzaArg(zztasp1,0) = b;
1759   attribsRefdFromAction = saveblah; inAlt = saveinalt;
1760   zzEXIT(zztasp1);
1761   return;
1762 fail:
1763   zzEXIT(zztasp1);
1764   CannotContinue=TRUE;
1765   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1766   zzresynch(setwd5, 0x20);
1767   }
1768 }
1769 
1770 void
1771 #ifdef __USE_PROTOS
alt(set * toksrefd,set * rulesrefd)1772 alt(set * toksrefd,set * rulesrefd)
1773 #else
1774 alt(toksrefd,rulesrefd)
1775  set *toksrefd;
1776 set *rulesrefd ;
1777 #endif
1778 {
1779   zzRULE;
1780   zzBLOCK(zztasp1);
1781   zzMake0;
1782   {
1783   int n=0; Graph g; int e_num=0, old_not=0; Node *node; set elems, dif;
1784   int first_on_line = 1, use_def_MT_handler = 0;
1785   g.left=NULL; g.right=NULL;
1786 
1787 			CurAltStart = NULL;
1788   elems = empty;
1789   inAlt = 1;
1790   {
1791     zzBLOCK(zztasp2);
1792     zzMake0;
1793     {
1794     if ( (LA(1)==88) ) {
1795       zzmatch(88);
1796       use_def_MT_handler = 1;
1797  zzCONSUME;
1798 
1799     }
1800     else {
1801       if ( (setwd5[LA(1)]&0x40) ) {
1802       }
1803       else {zzFAIL(1,zzerr26,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1804     }
1805     zzEXIT(zztasp2);
1806     }
1807   }
1808   {
1809     zzBLOCK(zztasp2);
1810     zzMake0;
1811     {
1812     ;
1813     while ( (setwd5[LA(1)]&0x80) ) {
1814       {
1815         zzBLOCK(zztasp3);
1816         zzMake0;
1817         {
1818         old_not=0;
1819         if ( (LA(1)==124) ) {
1820           zzmatch(124);
1821           old_not=1;
1822  zzCONSUME;
1823 
1824         }
1825         else {
1826           if ( (setwd6[LA(1)]&0x1) ) {
1827           }
1828           else {zzFAIL(1,zzerr27,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
1829         }
1830         zzEXIT(zztasp3);
1831         }
1832       }
1833        node  = element( old_not, first_on_line, use_def_MT_handler );
1834 
1835       if ( node!=NULL && node->ntype!=nAction ) first_on_line = 0;
1836 
1837       if ( zzaArg(zztasp2,2 ).left!=NULL ) {
1838         g = Cat(g, zzaArg(zztasp2,2));
1839         n++;
1840         if ( node!=NULL ) {
1841           if ( node->ntype!=nAction ) e_num++;
1842           /* record record number of all rule and token refs */
1843           if ( node->ntype==nToken ) {
1844             TokNode *tk = (TokNode *)((Junction *)zzaArg(zztasp2,2 ).left)->p1;
1845             tk->elnum = e_num;
1846             set_orel(e_num, &elems);
1847           }
1848           else if ( node->ntype==nRuleRef ) {
1849             RuleRefNode *rn = (RuleRefNode *)((Junction *)zzaArg(zztasp2,2 ).left)->p1;
1850             rn->elnum = e_num;
1851             set_orel(e_num,  rulesrefd);
1852           }
1853         }
1854       }
1855       zzLOOP(zztasp2);
1856     }
1857     zzEXIT(zztasp2);
1858     }
1859   }
1860   if ( n == 0 ) g = emptyAlt();
1861   zzaArg(zztasp1,0) = g;
1862   /* We want to reduce number of LT(i) calls and the number of
1863   * local attribute variables in C++ mode (for moment, later we'll
1864   * do for C also).  However, if trees are being built, they
1865   * require most of the attrib variables to create the tree nodes
1866   * with; therefore, we gen a token ptr for each token ref in C++
1867   */
1868   if ( GenCC && !GenAST )
1869   {
1870   /* This now free's the temp set -ATG 5/6/95 */
1871   set temp;
1872   temp = set_and(elems, attribsRefdFromAction);
1873   set_orin( toksrefd, temp);
1874   set_free(temp);
1875 }
1876 else set_orin( toksrefd, elems);
1877 if ( GenCC ) {
1878   dif = set_dif(attribsRefdFromAction, elems);
1879   if ( set_deg(dif)>0 )
1880   err("one or more $i in action(s) refer to non-token elements");
1881   set_free(dif);
1882 }
1883 set_free(elems);
1884 set_free(attribsRefdFromAction);
1885 inAlt = 0;
1886   zzEXIT(zztasp1);
1887   return;
1888 fail:
1889   zzEXIT(zztasp1);
1890   CannotContinue=TRUE;
1891   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1892   zzresynch(setwd6, 0x2);
1893   }
1894 }
1895 
1896 LabelEntry *
1897 #ifdef __USE_PROTOS
element_label(void)1898 element_label(void)
1899 #else
1900 element_label()
1901 #endif
1902 {
1903   LabelEntry *   _retv;
1904   zzRULE;
1905   zzBLOCK(zztasp1);
1906   PCCTS_PURIFY(_retv,sizeof(LabelEntry *  ))
1907   zzMake0;
1908   {
1909   TermEntry *t=NULL; LabelEntry *l=NULL; RuleEntry *r=NULL; char *lab;
1910   zzmatch(LABEL);
1911   lab = mystrdup(LATEXT(1));
1912  zzCONSUME;
1913 
1914 
1915   UsedNewStyleLabel = 1;
1916   if ( UsedOldStyleAttrib ) err("cannot mix with new-style labels with old-style $i");
1917   t = (TermEntry *) hash_get(Tname, lab);
1918   if ( t==NULL ) t = (TermEntry *) hash_get(Texpr, lab);
1919   if ( t==NULL ) r = (RuleEntry *) hash_get(Rname, lab);
1920   if ( t!=NULL ) {
1921     err(eMsg1("label definition clashes with token/tokclass definition: '%s'", lab));
1922     _retv = NULL;
1923   }
1924   else if ( r!=NULL ) {
1925     err(eMsg1("label definition clashes with rule definition: '%s'", lab));
1926     _retv = NULL;
1927   }
1928   else {
1929     /* we don't clash with anybody else */
1930     l = (LabelEntry *) hash_get(Elabel, lab);
1931     if ( l==NULL ) {	/* ok to add new element label */
1932     l = (LabelEntry *)hash_add(Elabel,
1933     lab,
1934     (Entry *)newLabelEntry(lab));
1935     /* add to list of element labels for this rule */
1936     list_add(&CurElementLabels, (void *)lab);
1937     /* MR7 */       leAdd(l);  /* list of labels waiting for exception group definitions */
1938     _retv = l;
1939   }
1940   else {
1941   err(eMsg1("label definitions must be unique per rule: '%s'", lab));
1942   _retv = NULL;
1943 }
1944 }
1945   zzmatch(106); zzCONSUME;
1946   zzEXIT(zztasp1);
1947   return _retv;
1948 fail:
1949   zzEXIT(zztasp1);
1950   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
1951   zzresynch(setwd6, 0x4);
1952   return _retv;
1953   }
1954 }
1955 
1956 Node *
1957 #ifdef __USE_PROTOS
element(int old_not,int first_on_line,int use_def_MT_handler)1958 element(int old_not,int first_on_line,int use_def_MT_handler)
1959 #else
1960 element(old_not,first_on_line,use_def_MT_handler)
1961  int old_not;
1962 int first_on_line;
1963 int use_def_MT_handler ;
1964 #endif
1965 {
1966   Node *   _retv;
1967   zzRULE;
1968   zzBLOCK(zztasp1);
1969   PCCTS_PURIFY(_retv,sizeof(Node *  ))
1970   zzMake0;
1971   {
1972 
1973   Attrib blk;
1974   Predicate *pred = NULL;
1975   int local_use_def_MT_handler=0;
1976   ActionNode *act;
1977   RuleRefNode *rr;
1978   set toksrefd, rulesrefd;
1979   TermEntry *term;
1980   TokNode *p=NULL; RuleRefNode *q; int approx=0;
1981   LabelEntry *label=NULL;
1982   int predMsgDone=0;
1983   int semDepth=0;
1984   int   ampersandStyle;
1985   int   height;         /* MR11 */
1986   int   equal_height;   /* MR11 */
1987 
1988           char* pFirstSetSymbol = NULL; /* MR21 */
1989 
1990 		  _retv = NULL;
1991   if ( (setwd6[LA(1)]&0x8) ) {
1992     {
1993       zzBLOCK(zztasp2);
1994       zzMake0;
1995       {
1996       if ( (LA(1)==LABEL) ) {
1997          label  = element_label();
1998 
1999       }
2000       else {
2001         if ( (setwd6[LA(1)]&0x10) ) {
2002         }
2003         else {zzFAIL(1,zzerr28,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2004       }
2005       zzEXIT(zztasp2);
2006       }
2007     }
2008     {
2009       zzBLOCK(zztasp2);
2010       zzMake0;
2011       {
2012       if ( (LA(1)==TokenTerm) ) {
2013         zzmatch(TokenTerm);
2014 
2015         term = (TermEntry *) hash_get(Tname, LATEXT(1));
2016         if ( term==NULL && UserDefdTokens ) {
2017           err("implicit token definition not allowed with #tokdefs");
2018           zzaRet.left = zzaRet.right = NULL;
2019         }
2020         else {
2021           zzaRet = buildToken(LATEXT(1));
2022           p=((TokNode *)((Junction *)zzaRet.left)->p1);
2023           term = (TermEntry *) hash_get(Tname, LATEXT(1));
2024           require( term!= NULL, "hash table mechanism is broken");
2025           p->tclass = term->tclass;
2026           p->complement =  old_not;
2027           if ( label!=NULL ) {
2028             p->el_label = label->str;
2029             label->elem = (Node *)p;
2030           }
2031         }
2032  zzCONSUME;
2033 
2034         {
2035           zzBLOCK(zztasp3);
2036           zzMake0;
2037           {
2038           if ( (LA(1)==119) ) {
2039             zzmatch(119); zzCONSUME;
2040             {
2041               zzBLOCK(zztasp4);
2042               zzMake0;
2043               {
2044               if ( (LA(1)==QuotedTerm) ) {
2045                 zzmatch(QuotedTerm);
2046                 if ( p!=NULL ) setUpperRange(p, LATEXT(1));
2047  zzCONSUME;
2048 
2049               }
2050               else {
2051                 if ( (LA(1)==TokenTerm) ) {
2052                   zzmatch(TokenTerm);
2053                   if ( p!=NULL ) setUpperRange(p, LATEXT(1));
2054  zzCONSUME;
2055 
2056                 }
2057                 else {zzFAIL(1,zzerr29,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2058               }
2059               zzEXIT(zztasp4);
2060               }
2061             }
2062           }
2063           else {
2064             if ( (setwd6[LA(1)]&0x20) ) {
2065             }
2066             else {zzFAIL(1,zzerr30,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2067           }
2068           zzEXIT(zztasp3);
2069           }
2070         }
2071 
2072         if ( p!=NULL && (p->upper_range!=0 || p->tclass ||  old_not) )
2073         list_add(&MetaTokenNodes, (void *)p);
2074         {
2075           zzBLOCK(zztasp3);
2076           zzMake0;
2077           {
2078           if ( (LA(1)==125) ) {
2079             zzmatch(125);
2080             if ( p!=NULL ) p->astnode=ASTroot;
2081  zzCONSUME;
2082 
2083           }
2084           else {
2085             if ( (setwd6[LA(1)]&0x40) ) {
2086               if ( p!=NULL ) p->astnode=ASTchild;
2087             }
2088             else {
2089               if ( (LA(1)==103) ) {
2090                 zzmatch(103);
2091                 if ( p!=NULL ) p->astnode=ASTexclude;
2092  zzCONSUME;
2093 
2094               }
2095               else {zzFAIL(1,zzerr31,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2096             }
2097           }
2098           zzEXIT(zztasp3);
2099           }
2100         }
2101         {
2102           zzBLOCK(zztasp3);
2103           zzMake0;
2104           {
2105           if ( (LA(1)==88) ) {
2106             zzmatch(88);
2107             local_use_def_MT_handler = 1;
2108  zzCONSUME;
2109 
2110           }
2111           else {
2112             if ( (setwd6[LA(1)]&0x80) ) {
2113             }
2114             else {zzFAIL(1,zzerr32,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2115           }
2116           zzEXIT(zztasp3);
2117           }
2118         }
2119 
2120         if ( p!=NULL &&  first_on_line ) {
2121           CurAltStart = (Junction *)zzaRet.left;
2122           altAdd(CurAltStart);                                 /* MR7 */
2123           p->altstart = CurAltStart;
2124         }
2125         if ( p!=NULL )
2126         p->use_def_MT_handler =  use_def_MT_handler || local_use_def_MT_handler;
2127         _retv = (Node *)p;
2128       }
2129       else {
2130         if ( (LA(1)==QuotedTerm) ) {
2131           zzmatch(QuotedTerm);
2132 
2133           term = (TermEntry *) hash_get(Texpr, LATEXT(1));
2134           if ( term==NULL && UserDefdTokens ) {
2135             err("implicit token definition not allowed with #tokdefs");
2136             zzaRet.left = zzaRet.right = NULL;
2137           }
2138           else {
2139             zzaRet = buildToken(LATEXT(1)); p=((TokNode *)((Junction *)zzaRet.left)->p1);
2140             p->complement =  old_not;
2141             if ( label!=NULL ) {
2142               p->el_label = label->str;
2143               label->elem = (Node *)p;
2144             }
2145           }
2146  zzCONSUME;
2147 
2148           {
2149             zzBLOCK(zztasp3);
2150             zzMake0;
2151             {
2152             if ( (LA(1)==119) ) {
2153               zzmatch(119); zzCONSUME;
2154               {
2155                 zzBLOCK(zztasp4);
2156                 zzMake0;
2157                 {
2158                 if ( (LA(1)==QuotedTerm) ) {
2159                   zzmatch(QuotedTerm);
2160                   if ( p!=NULL ) setUpperRange(p, LATEXT(1));
2161  zzCONSUME;
2162 
2163                 }
2164                 else {
2165                   if ( (LA(1)==TokenTerm) ) {
2166                     zzmatch(TokenTerm);
2167                     if ( p!=NULL ) setUpperRange(p, LATEXT(1));
2168  zzCONSUME;
2169 
2170                   }
2171                   else {zzFAIL(1,zzerr33,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2172                 }
2173                 zzEXIT(zztasp4);
2174                 }
2175               }
2176             }
2177             else {
2178               if ( (setwd7[LA(1)]&0x1) ) {
2179               }
2180               else {zzFAIL(1,zzerr34,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2181             }
2182             zzEXIT(zztasp3);
2183             }
2184           }
2185           {
2186             zzBLOCK(zztasp3);
2187             zzMake0;
2188             {
2189             if ( (LA(1)==125) ) {
2190               zzmatch(125);
2191               if ( p!=NULL ) p->astnode=ASTroot;
2192  zzCONSUME;
2193 
2194             }
2195             else {
2196               if ( (setwd7[LA(1)]&0x2) ) {
2197                 if ( p!=NULL ) p->astnode=ASTchild;
2198               }
2199               else {
2200                 if ( (LA(1)==103) ) {
2201                   zzmatch(103);
2202                   if ( p!=NULL ) p->astnode=ASTexclude;
2203  zzCONSUME;
2204 
2205                 }
2206                 else {zzFAIL(1,zzerr35,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2207               }
2208             }
2209             zzEXIT(zztasp3);
2210             }
2211           }
2212           {
2213             zzBLOCK(zztasp3);
2214             zzMake0;
2215             {
2216             if ( (LA(1)==88) ) {
2217               zzmatch(88);
2218               local_use_def_MT_handler = 1;
2219  zzCONSUME;
2220 
2221             }
2222             else {
2223               if ( (setwd7[LA(1)]&0x4) ) {
2224               }
2225               else {zzFAIL(1,zzerr36,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2226             }
2227             zzEXIT(zztasp3);
2228             }
2229           }
2230 
2231           if ( p!=NULL && (p->upper_range!=0 || p->tclass ||  old_not) )
2232           list_add(&MetaTokenNodes, (void *)p);
2233 
2234           if (  first_on_line ) {
2235             CurAltStart = (Junction *)zzaRet.left;
2236             altAdd(CurAltStart);                                 /* MR7 */
2237             p->altstart = CurAltStart;
2238           }
2239           if ( p!=NULL )
2240           p->use_def_MT_handler =  use_def_MT_handler || local_use_def_MT_handler;
2241           _retv = (Node *)p;
2242         }
2243         else {
2244           if ( (LA(1)==WildCard) ) {
2245             if (  old_not ) warn("~ WILDCARD is an undefined operation (implies 'nothing')");
2246             zzmatch(WildCard);
2247             zzaRet = buildWildCard(LATEXT(1)); p=((TokNode *)((Junction *)zzaRet.left)->p1);
2248  zzCONSUME;
2249 
2250             {
2251               zzBLOCK(zztasp3);
2252               zzMake0;
2253               {
2254               if ( (LA(1)==125) ) {
2255                 zzmatch(125);
2256                 p->astnode=ASTroot;
2257  zzCONSUME;
2258 
2259               }
2260               else {
2261                 if ( (setwd7[LA(1)]&0x8) ) {
2262                   p->astnode=ASTchild;
2263                 }
2264                 else {
2265                   if ( (LA(1)==103) ) {
2266                     zzmatch(103);
2267                     p->astnode=ASTexclude;
2268  zzCONSUME;
2269 
2270                   }
2271                   else {zzFAIL(1,zzerr37,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2272                 }
2273               }
2274               zzEXIT(zztasp3);
2275               }
2276             }
2277             list_add(&MetaTokenNodes, (void *)p);
2278 
2279             if (  first_on_line ) {
2280               CurAltStart = (Junction *)zzaRet.left;
2281               altAdd(CurAltStart);                                 /* MR7 */
2282               p->altstart = CurAltStart;
2283               if ( label!=NULL ) {
2284                 p->el_label = label->str;
2285                 label->elem = (Node *)p;
2286               }
2287             }
2288             _retv = (Node *)p;
2289           }
2290           else {
2291             if ( (LA(1)==NonTerminal) ) {
2292               if (  old_not ) warn("~ NONTERMINAL is an undefined operation");
2293               zzmatch(NonTerminal);
2294               zzaRet = buildRuleRef(LATEXT(1));
2295  zzCONSUME;
2296 
2297               {
2298                 zzBLOCK(zztasp3);
2299                 zzMake0;
2300                 {
2301                 if ( (LA(1)==103) ) {
2302                   zzmatch(103);
2303                   q = (RuleRefNode *) ((Junction *)zzaRet.left)->p1;
2304                   q->astnode=ASTexclude;
2305  zzCONSUME;
2306 
2307                 }
2308                 else {
2309                   if ( (setwd7[LA(1)]&0x10) ) {
2310                   }
2311                   else {zzFAIL(1,zzerr38,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2312                 }
2313                 zzEXIT(zztasp3);
2314                 }
2315               }
2316               {
2317                 zzBLOCK(zztasp3);
2318                 zzMake0;
2319                 {
2320                 if ( (setwd7[LA(1)]&0x20) ) {
2321                   {
2322                     zzBLOCK(zztasp4);
2323                     zzMake0;
2324                     {
2325                     if ( (LA(1)==104) ) {
2326                       zzmatch(104); zzCONSUME;
2327                     }
2328                     else {
2329                       if ( (LA(1)==PassAction) ) {
2330                       }
2331                       else {zzFAIL(1,zzerr39,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2332                     }
2333                     zzEXIT(zztasp4);
2334                     }
2335                   }
2336                   zzmatch(PassAction);
2337                   addParm(((Junction *)zzaRet.left)->p1, LATEXT(1));
2338  zzCONSUME;
2339 
2340                 }
2341                 else {
2342                   if ( (setwd7[LA(1)]&0x40) ) {
2343                   }
2344                   else {zzFAIL(1,zzerr40,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2345                 }
2346                 zzEXIT(zztasp3);
2347                 }
2348               }
2349               rr=(RuleRefNode *) ((Junction *)zzaRet.left)->p1;
2350               {
2351                 zzBLOCK(zztasp3);
2352                 zzMake0;
2353                 {
2354                 char *a;
2355                 if ( (LA(1)==105) ) {
2356                   zzmatch(105); zzCONSUME;
2357                   zzmatch(PassAction);
2358 
2359                   a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2360                   require(a!=NULL, "rule element: cannot allocate assignment");
2361                   strcpy(a, LATEXT(1));
2362                   rr->assign = a;
2363  zzCONSUME;
2364 
2365                 }
2366                 else {
2367                   if ( (setwd7[LA(1)]&0x80) ) {
2368                   }
2369                   else {zzFAIL(1,zzerr41,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2370                 }
2371                 zzEXIT(zztasp3);
2372                 }
2373               }
2374 
2375               if ( label!=NULL ) {
2376                 rr->el_label = label->str;
2377                 label->elem = (Node *)rr;
2378               }
2379               if (  first_on_line ) {
2380                 CurAltStart = (Junction *)zzaRet.left;
2381                 altAdd(CurAltStart);                                 /* MR7 */
2382                 ((RuleRefNode *)((Junction *)zzaRet.left)->p1)->altstart = CurAltStart;
2383               }
2384               _retv = (Node *)rr;
2385             }
2386             else {zzFAIL(1,zzerr42,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2387           }
2388         }
2389       }
2390       zzEXIT(zztasp2);
2391       }
2392     }
2393   }
2394   else {
2395     if ( (LA(1)==Action) ) {
2396       if (  old_not )	warn("~ ACTION is an undefined operation");
2397       zzmatch(Action);
2398       zzaArg(zztasp1,0) = buildAction(LATEXT(1),action_file,action_line, 0);
2399  zzCONSUME;
2400 
2401       if (  first_on_line ) {                                /* MR7 */
2402         CurAltStart = (Junction *)zzaArg(zztasp1,0 ).left;                   /* MR7 */
2403         altAdd(CurAltStart);                                 /* MR7 */
2404       };
2405       _retv = (Node *) ((Junction *)zzaArg(zztasp1,0 ).left)->p1;
2406     }
2407     else {
2408       if ( (LA(1)==Pred) ) {
2409         if (  old_not )	warn("~ SEMANTIC-PREDICATE is an undefined operation");
2410         zzmatch(Pred);
2411         zzaArg(zztasp1,0) = buildAction(LATEXT(1),action_file,action_line, 1);
2412  zzCONSUME;
2413 
2414         act = (ActionNode *) ((Junction *)zzaArg(zztasp1,0 ).left)->p1;
2415         if (numericActionLabel) {             /* MR10 */
2416           list_add(&NumericPredLabels,act);   /* MR10 */
2417           numericActionLabel=0;               /* MR10 */
2418         };                                    /* MR10 */
2419         {
2420           zzBLOCK(zztasp2);
2421           zzMake0;
2422           {
2423           char *a;
2424           if ( (LA(1)==PassAction) ) {
2425             zzmatch(PassAction);
2426 
2427             a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2428             require(a!=NULL, "rule element: cannot allocate predicate fail action");
2429             strcpy(a, LATEXT(1));
2430             act->pred_fail = a;
2431  zzCONSUME;
2432 
2433           }
2434           else {
2435             if ( (setwd8[LA(1)]&0x1) ) {
2436             }
2437             else {zzFAIL(1,zzerr43,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2438           }
2439           zzEXIT(zztasp2);
2440           }
2441         }
2442         if (  first_on_line ) {                                /* MR7 */
2443           CurAltStart = (Junction *)zzaArg(zztasp1,0 ).left;                   /* MR7 */
2444           altAdd(CurAltStart);                                 /* MR7 */
2445         };
2446         _retv = (Node *)act;
2447       }
2448       else {
2449         if ( (setwd8[LA(1)]&0x2) ) {
2450           if (  old_not )	warn("~ BLOCK is an undefined operation");
2451           BlkLevel++;
2452           if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");
2453           /* MR23 */    CurBlockID_array[BlkLevel] = CurBlockID;
2454           /* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;
2455           {
2456             zzBLOCK(zztasp2);
2457             zzMake0;
2458             {
2459             if ( (LA(1)==Pragma) ) {
2460               zzmatch(Pragma); zzCONSUME;
2461               {
2462                 zzBLOCK(zztasp3);
2463                 zzMake0;
2464                 {
2465                 if ( (LA(1)==126) ) {
2466                   zzmatch(126);
2467                   approx=LL_k;
2468  zzCONSUME;
2469 
2470                 }
2471                 else {
2472                   if ( (LA(1)==127) ) {
2473                     zzmatch(127);
2474                     approx = 1;
2475  zzCONSUME;
2476 
2477                   }
2478                   else {
2479                     if ( (LA(1)==128) ) {
2480                       zzmatch(128);
2481                       approx = 2;
2482  zzCONSUME;
2483 
2484                     }
2485                     else {zzFAIL(1,zzerr44,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2486                   }
2487                 }
2488                 zzEXIT(zztasp3);
2489                 }
2490               }
2491             }
2492             else {
2493               if ( (setwd8[LA(1)]&0x4) ) {
2494               }
2495               else {zzFAIL(1,zzerr45,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2496             }
2497             zzEXIT(zztasp2);
2498             }
2499           }
2500           {
2501             zzBLOCK(zztasp2);
2502             zzMake0;
2503             {
2504             if ( (LA(1)==FirstSetSymbol) ) {
2505               zzmatch(FirstSetSymbol); zzCONSUME;
2506               zzmatch(114); zzCONSUME;
2507               {
2508                 zzBLOCK(zztasp3);
2509                 zzMake0;
2510                 {
2511                 if ( (LA(1)==NonTerminal) ) {
2512                   zzmatch(NonTerminal);
2513 
2514                   /* MR21 */                     pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,
2515                   /* MR21 */                                                    sizeof(char));
2516                   /* MR21 */                          require(pFirstSetSymbol!=NULL,
2517                   /* MR21 */                                  "cannot allocate first set name");
2518                   /* MR21 */                          strcpy(pFirstSetSymbol, LATEXT(1));
2519                   /* MR21 */
2520  zzCONSUME;
2521 
2522                 }
2523                 else {
2524                   if ( (LA(1)==TokenTerm) ) {
2525                     zzmatch(TokenTerm);
2526 
2527                     /* MR21 */                      pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,
2528                     /* MR21 */                                                        sizeof(char));
2529                     /* MR21 */                      require(pFirstSetSymbol!=NULL,
2530                     /* MR21 */                              "cannot allocate first set name");
2531                     /* MR21 */                      strcpy(pFirstSetSymbol, LATEXT(1));
2532                     /* MR21 */
2533  zzCONSUME;
2534 
2535                   }
2536                   else {zzFAIL(1,zzerr46,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2537                 }
2538                 zzEXIT(zztasp3);
2539                 }
2540               }
2541               zzmatch(115); zzCONSUME;
2542             }
2543             else {
2544               if ( (setwd8[LA(1)]&0x8) ) {
2545               }
2546               else {zzFAIL(1,zzerr47,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2547             }
2548             zzEXIT(zztasp2);
2549             }
2550           }
2551           {
2552             zzBLOCK(zztasp2);
2553             zzMake0;
2554             {
2555             if ( (LA(1)==114) ) {
2556               zzmatch(114); zzCONSUME;
2557               block( &toksrefd,&rulesrefd );
2558               zzmatch(115);
2559               blk = zzaRet = zzaArg(zztasp2,2);
2560               /* MR23 */      CurBlockID_array[BlkLevel] = (-1);
2561               /* MR23 */      CurAltNum_array[BlkLevel] = (-1);
2562               --BlkLevel;
2563  zzCONSUME;
2564 
2565               {
2566                 zzBLOCK(zztasp3);
2567                 zzMake0;
2568                 {
2569                 if ( (LA(1)==129) ) {
2570                   zzmatch(129);
2571                   zzaRet = makeLoop(zzaRet,approx,pFirstSetSymbol);
2572  zzCONSUME;
2573 
2574                 }
2575                 else {
2576                   if ( (LA(1)==130) ) {
2577                     zzmatch(130);
2578                     zzaRet = makePlus(zzaRet,approx,pFirstSetSymbol);
2579  zzCONSUME;
2580 
2581                   }
2582                   else {
2583                     if ( (LA(1)==131) ) {
2584                       zzmatch(131); zzCONSUME;
2585                       {
2586                         zzBLOCK(zztasp4);
2587                         zzMake0;
2588                         {
2589                         if ( (setwd8[LA(1)]&0x10) ) {
2590                           {
2591                             zzBLOCK(zztasp5);
2592                             zzMake0;
2593                             {
2594                             if ( (LA(1)==132) ) {
2595                               zzmatch(132);
2596                               ampersandStyle=0;
2597  zzCONSUME;
2598 
2599                             }
2600                             else {
2601                               if ( (LA(1)==113) ) {
2602                                 zzmatch(113);
2603                                 ampersandStyle=1;
2604  zzCONSUME;
2605 
2606                               }
2607                               else {zzFAIL(1,zzerr48,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2608                             }
2609                             zzEXIT(zztasp5);
2610                             }
2611                           }
2612                           zzmatch(Pred);
2613                           zzaRet = buildAction(LATEXT(1),action_file,action_line,1);
2614  zzCONSUME;
2615 
2616                           act = (ActionNode *) ((Junction *)zzaRet.left)->p1;
2617                           semDepth=predicateLookaheadDepth(act);
2618                           if (numericActionLabel) {             /* MR10 */
2619                             list_add(&NumericPredLabels,act);   /* MR10 */
2620                             numericActionLabel=0;               /* MR10 */
2621                           };                                    /* MR10 */
2622                           {
2623                             zzBLOCK(zztasp5);
2624                             zzMake0;
2625                             {
2626                             char *a;
2627                             if ( (LA(1)==PassAction) ) {
2628                               zzmatch(PassAction);
2629 
2630                               a = (char *)calloc(strlen(LATEXT(1))+1, sizeof(char));
2631                               require(a!=NULL, "rule element: cannot allocate predicate fail action");
2632                               strcpy(a, LATEXT(1));
2633                               act->pred_fail = a;
2634  zzCONSUME;
2635 
2636                             }
2637                             else {
2638                               if ( (setwd8[LA(1)]&0x20) ) {
2639                               }
2640                               else {zzFAIL(1,zzerr49,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2641                             }
2642                             zzEXIT(zztasp5);
2643                             }
2644                           }
2645                           if ( first_on_line) {                      /* MR7 */
2646                             CurAltStart=(Junction *)zzaRet.left;         /* MR7 */
2647                             altAdd(CurAltStart);                     /* MR7 */
2648                           };
2649                           _retv = (Node *)act;
2650 
2651                           pred = computePredFromContextGuard(blk,&predMsgDone);           /* MR10 */
2652                           if ( pred==NULL) {                                              /* MR10 */
2653                             if ( !predMsgDone) err("invalid or missing context guard");   /* MR10 */
2654                             predMsgDone=1;                                                /* MR10 */
2655                           } else {                                                        /* MR10 */
2656                             act->guardNodes=(Junction *)blk.left;                       /* MR11 */
2657                             pred->expr = act->action;
2658                             pred->source = act;
2659                             /* MR10 */                  pred->ampersandStyle = ampersandStyle;  /* 0 means (g)? => ... 1 means (g)? && ... */
2660                             /* MR13 */                  if (pred->tcontext != NULL) {
2661                               /* MR13 */                    height=MR_max_height_of_tree(pred->tcontext);
2662                               /* MR13 */                    equal_height=MR_all_leaves_same_height(pred->tcontext,height);
2663                               /* MR13 */                    if (! equal_height) {
2664                                 /* MR13 */                       errFL("in guarded predicates all tokens in the guard must be at the same height",
2665                                 /* MR13 */                              FileStr[act->file],act->line);
2666                                 /* MR13 */                    };
2667                               /* MR13 */                  }
2668                             /* MR10 */                  if (ampersandStyle) {
2669                               /* MR10 */			  		  act->ampersandPred = pred;
2670                               /* MR11 */                    if (! HoistPredicateContext) {
2671                                 /* MR11 */                      errFL("without \"-prc on\" (guard)? && <<pred>>? ... doesn't make sense",
2672                                 /* MR11 */                              FileStr[act->file],act->line);
2673                                 /* MR11 */                    };
2674                               /* MR10 */                  } else {
2675                               /* MR10 */			  		  act->guardpred = pred;
2676                               /* MR10 */                  };
2677                             /* MR10 */                  if (pred->k != semDepth) {
2678                               /* MR10 */                     warn(eMsgd2("length of guard (%d) does not match the length of semantic predicate (%d)",
2679                               /* MR10 */                                  pred->k,semDepth));
2680                               /* MR10 */                  };
2681                           }
2682                         }
2683                         else {
2684                           if ( (setwd8[LA(1)]&0x40) ) {
2685                             zzaRet = makeBlk(zzaRet,approx,pFirstSetSymbol);
2686                             FoundGuessBlk = 1;
2687                             ((Junction *) ((Junction *)zzaRet.left)->p1)->guess=1;
2688                             if ( ! first_on_line ) {
2689                               err("(...)? predicate must be first element of production");
2690                             }
2691                           }
2692                           else {zzFAIL(1,zzerr50,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2693                         }
2694                         zzEXIT(zztasp4);
2695                         }
2696                       }
2697                     }
2698                     else {
2699                       if ( (setwd8[LA(1)]&0x80) ) {
2700                         zzaRet = makeBlk(zzaRet,approx,pFirstSetSymbol);
2701                       }
2702                       else {zzFAIL(1,zzerr51,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2703                     }
2704                   }
2705                 }
2706                 zzEXIT(zztasp3);
2707                 }
2708               }
2709 
2710               if ( pred==NULL && !predMsgDone) {                                      /* MR10 */
2711                 ((Junction *)((Junction *)zzaRet.left)->p1)->blockid = CurBlockID;
2712                 ((Junction *)((Junction *)zzaRet.left)->p1)->tokrefs = toksrefd;
2713                 ((Junction *)((Junction *)zzaRet.left)->p1)->rulerefs = rulesrefd;
2714                 if (  first_on_line ) {                         /* MR7 */
2715                   CurAltStart = (Junction *)((Junction *)((Junction *)zzaRet.left)->p1);  /* MR7 */
2716                   altAdd(CurAltStart);                         /* MR7 */
2717                 };                                              /* MR7 */
2718                 _retv = (Node *) ((Junction *)zzaRet.left)->p1;
2719               }
2720             }
2721             else {
2722               if ( (LA(1)==102) ) {
2723                 zzmatch(102); zzCONSUME;
2724                 block( &toksrefd,&rulesrefd );
2725                 zzaRet = makeOpt(zzaArg(zztasp2,2),approx,pFirstSetSymbol);
2726                 /* MR23 */      CurBlockID_array[BlkLevel] = (-1);
2727                 /* MR23 */      CurAltNum_array[BlkLevel] = (-1);
2728                 --BlkLevel;
2729                 zzmatch(98);
2730 
2731                 ((Junction *)((Junction *)zzaRet.left)->p1)->blockid = CurBlockID;
2732                 ((Junction *)((Junction *)zzaRet.left)->p1)->tokrefs = toksrefd;
2733                 ((Junction *)((Junction *)zzaRet.left)->p1)->rulerefs = rulesrefd;
2734  zzCONSUME;
2735 
2736                 if (  first_on_line ) {                            /* MR7 */
2737                   CurAltStart = (Junction *) ((Junction *)((Junction *)zzaRet.left)->p1);  /* MR7 */
2738                   altAdd(CurAltStart);                             /* MR7 */
2739                 };
2740                 _retv = (Node *) ((Junction *)zzaRet.left)->p1;
2741               }
2742               else {zzFAIL(1,zzerr52,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2743             }
2744             zzEXIT(zztasp2);
2745             }
2746           }
2747         }
2748         else {
2749           if ( (LA(1)==129) ) {
2750             zzmatch(129);
2751             warn("don't you want a ')' with that '*'?"); CannotContinue=TRUE;
2752  zzCONSUME;
2753 
2754           }
2755           else {
2756             if ( (LA(1)==130) ) {
2757               zzmatch(130);
2758               warn("don't you want a ')' with that '+'?"); CannotContinue=TRUE;
2759  zzCONSUME;
2760 
2761             }
2762             else {
2763               if ( (LA(1)==105) ) {
2764                 zzmatch(105);
2765                 warn("'>' can only appear after a nonterminal"); CannotContinue=TRUE;
2766  zzCONSUME;
2767 
2768               }
2769               else {
2770                 if ( (LA(1)==PassAction) ) {
2771                   zzmatch(PassAction);
2772                   warn("[...] out of context 'rule > [...]'");
2773                   CannotContinue=TRUE;
2774  zzCONSUME;
2775 
2776                 }
2777                 else {zzFAIL(1,zzerr53,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2778               }
2779             }
2780           }
2781         }
2782       }
2783     }
2784   }
2785   zzEXIT(zztasp1);
2786   return _retv;
2787 fail:
2788   zzEXIT(zztasp1);
2789   CannotContinue=TRUE;
2790   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
2791   zzresynch(setwd9, 0x1);
2792   return _retv;
2793   }
2794 }
2795 
2796 void
2797 #ifdef __USE_PROTOS
default_exception_handler(void)2798 default_exception_handler(void)
2799 #else
2800 default_exception_handler()
2801 #endif
2802 {
2803   zzRULE;
2804   zzBLOCK(zztasp1);
2805   zzMake0;
2806   {
2807    DefaultExGroup  = exception_group();
2808 
2809   zzEXIT(zztasp1);
2810   return;
2811 fail:
2812   zzEXIT(zztasp1);
2813   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
2814   zzresynch(setwd9, 0x2);
2815   }
2816 }
2817 
2818 ExceptionGroup *
2819 #ifdef __USE_PROTOS
exception_group(void)2820 exception_group(void)
2821 #else
2822 exception_group()
2823 #endif
2824 {
2825   ExceptionGroup *   _retv;
2826   zzRULE;
2827   zzBLOCK(zztasp1);
2828   PCCTS_PURIFY(_retv,sizeof(ExceptionGroup *  ))
2829   zzMake0;
2830   {
2831   ExceptionHandler *h; LabelEntry *label=NULL;	  /* MR6 */
2832   FoundException = 1; FoundExceptionGroup = 1;
2833   zzmatch(133);
2834   _retv = (ExceptionGroup *)calloc(1, sizeof(ExceptionGroup));
2835  zzCONSUME;
2836 
2837   {
2838     zzBLOCK(zztasp2);
2839     zzMake0;
2840     {
2841     char *p;
2842     if ( (LA(1)==PassAction) ) {
2843       zzmatch(PassAction);
2844 
2845       p = LATEXT(1)+1;
2846       p[strlen(p)-1] = '\0';		/* kill trailing space */
2847       label = (LabelEntry *) hash_get(Elabel, LATEXT(1)+1);
2848       if ( label==NULL )
2849       {
2850         err(eMsg1("unknown label in exception handler: '%s'", LATEXT(1)+1));
2851       }
2852  zzCONSUME;
2853 
2854     }
2855     else {
2856       if ( (setwd9[LA(1)]&0x4) ) {
2857       }
2858       else {zzFAIL(1,zzerr54,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2859     }
2860     zzEXIT(zztasp2);
2861     }
2862   }
2863   {
2864     zzBLOCK(zztasp2);
2865     zzMake0;
2866     {
2867     while ( (LA(1)==135) ) {
2868        h  = exception_handler();
2869 
2870       list_add(&(_retv->handlers), (void *)h);
2871       zzLOOP(zztasp2);
2872     }
2873     zzEXIT(zztasp2);
2874     }
2875   }
2876   {
2877     zzBLOCK(zztasp2);
2878     zzMake0;
2879     {
2880     if ( (LA(1)==134) ) {
2881       zzmatch(134); zzCONSUME;
2882       zzmatch(106); zzCONSUME;
2883       zzmatch(Action);
2884       {
2885         ExceptionHandler *eh = (ExceptionHandler *)
2886         calloc(1, sizeof(ExceptionHandler));
2887         char *a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2888         require(eh!=NULL, "exception: cannot allocate handler");
2889         require(a!=NULL, "exception: cannot allocate action");
2890         strcpy(a, LATEXT(1));
2891         eh->action = a;
2892         eh->signalname = (char *) calloc(strlen("default")+1, sizeof(char));
2893         require(eh->signalname!=NULL, "exception: cannot allocate sig name");
2894         strcpy(eh->signalname, "default");
2895         list_add(&(_retv->handlers), (void *)eh);
2896       }
2897  zzCONSUME;
2898 
2899     }
2900     else {
2901       if ( (setwd9[LA(1)]&0x8) ) {
2902       }
2903       else {zzFAIL(1,zzerr55,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
2904     }
2905     zzEXIT(zztasp2);
2906     }
2907   }
2908 
2909   if ( label!=NULL ) {
2910     /* Record ex group in sym tab for this label */
2911     if ( label->ex_group!=NULL ) {
2912       err(eMsg1("duplicate exception handler for label '%s'",label->str));
2913     } else {
2914       label->ex_group = _retv;
2915       /* Label the exception group itself */
2916       _retv->label = label->str;
2917       /* Make the labelled element pt to the exception also */
2918       /* MR6 */	  if (label->elem == NULL) {
2919         /* MR6 */	     err(eMsg1("reference in exception handler to undefined label '%s'",label->str));
2920         /* MR6 */	  } else {
2921         switch ( label->elem->ntype ) {
2922           case nRuleRef :
2923           {
2924             RuleRefNode *r = (RuleRefNode *)label->elem;
2925             r->ex_group = _retv;
2926             break;
2927           }
2928           case nToken :
2929           {
2930             TokNode *t = (TokNode *)label->elem;
2931             t->ex_group = _retv;
2932             break;
2933           }
2934         } /* end switch */
2935         /* MR6 */	  }; /* end test on label->elem */
2936     } /* end test on label->ex_group */
2937 
2938 		} /* end test on exception label */
2939 
2940 /* MR7 */
2941   /* MR7 */   if (BlkLevel == 1 && label == NULL) {
2942     /* MR7 */     _retv->forRule=1;
2943     /* MR7 */   } else if (label == NULL) {
2944     /* MR7 */     _retv->altID = makeAltID(CurBlockID_array[BlkLevel], CurAltNum_array[BlkLevel]);
2945     /* MR7 */     egAdd(_retv);
2946     /* MR7 */   } else {
2947     /* MR7 */     _retv->labelEntry=label;
2948     /* MR7 */   };
2949   /* MR7 */
2950   /* MR7 */	    /* You may want to remove this exc from the rule list  */
2951   /* MR7 */		/* and handle at the labeled element site.             */
2952   /* MR7 */
2953   /* MR7 */   if (label != NULL) {
2954     /* MR7 */     _retv = NULL;
2955     /* MR7 */   };
2956   zzEXIT(zztasp1);
2957   return _retv;
2958 fail:
2959   zzEXIT(zztasp1);
2960   CannotContinue=TRUE;
2961   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
2962   zzresynch(setwd9, 0x10);
2963   return _retv;
2964   }
2965 }
2966 
2967 ExceptionHandler *
2968 #ifdef __USE_PROTOS
exception_handler(void)2969 exception_handler(void)
2970 #else
2971 exception_handler()
2972 #endif
2973 {
2974   ExceptionHandler *   _retv;
2975   zzRULE;
2976   zzBLOCK(zztasp1);
2977   PCCTS_PURIFY(_retv,sizeof(ExceptionHandler *  ))
2978   zzMake0;
2979   {
2980   ;
2981   zzmatch(135);
2982 
2983   _retv = (ExceptionHandler *)calloc(1, sizeof(ExceptionHandler));
2984   require(_retv!=NULL, "exception: cannot allocate handler");
2985  zzCONSUME;
2986 
2987   {
2988     zzBLOCK(zztasp2);
2989     zzMake0;
2990     {
2991     if ( (LA(1)==NonTerminal) ) {
2992       zzmatch(NonTerminal);
2993 
2994       _retv->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
2995       require(_retv->signalname!=NULL, "exception: cannot allocate sig name");
2996       strcpy(_retv->signalname, LATEXT(1));
2997  zzCONSUME;
2998 
2999     }
3000     else {
3001       if ( (LA(1)==TokenTerm) ) {
3002         zzmatch(TokenTerm);
3003 
3004         _retv->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
3005         require(_retv->signalname!=NULL, "exception: cannot allocate sig name");
3006         strcpy(_retv->signalname, LATEXT(1));
3007  zzCONSUME;
3008 
3009       }
3010       else {zzFAIL(1,zzerr56,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3011     }
3012     zzEXIT(zztasp2);
3013     }
3014   }
3015   zzmatch(106); zzCONSUME;
3016   {
3017     zzBLOCK(zztasp2);
3018     zzMake0;
3019     {
3020     _retv->action = NULL;
3021     if ( (LA(1)==Action) ) {
3022       zzmatch(Action);
3023 
3024       _retv->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));
3025       require(_retv->action!=NULL, "exception: cannot allocate action");
3026       strcpy(_retv->action, LATEXT(1));
3027  zzCONSUME;
3028 
3029     }
3030     else {
3031       if ( (setwd9[LA(1)]&0x20) ) {
3032       }
3033       else {zzFAIL(1,zzerr57,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3034     }
3035     zzEXIT(zztasp2);
3036     }
3037   }
3038   zzEXIT(zztasp1);
3039   return _retv;
3040 fail:
3041   zzEXIT(zztasp1);
3042   CannotContinue=TRUE;
3043   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
3044   zzresynch(setwd9, 0x40);
3045   return _retv;
3046   }
3047 }
3048 
3049 void
3050 #ifdef __USE_PROTOS
enum_file(char * fname)3051 enum_file(char * fname)
3052 #else
3053 enum_file(fname)
3054  char *fname ;
3055 #endif
3056 {
3057   zzRULE;
3058   zzBLOCK(zztasp1);
3059   zzMake0;
3060   {
3061   if ( (setwd9[LA(1)]&0x80) ) {
3062     {
3063       zzBLOCK(zztasp2);
3064       zzMake0;
3065       {
3066       if ( (LA(1)==143) ) {
3067         zzmatch(143); zzCONSUME;
3068         zzmatch(ID); zzCONSUME;
3069         {
3070           zzBLOCK(zztasp3);
3071           zzMake0;
3072           {
3073           if ( (LA(1)==149) ) {
3074             zzmatch(149); zzCONSUME;
3075             zzmatch(ID); zzCONSUME;
3076           }
3077           else {
3078             if ( (setwd10[LA(1)]&0x1) ) {
3079             }
3080             else {zzFAIL(1,zzerr58,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3081           }
3082           zzEXIT(zztasp3);
3083           }
3084         }
3085       }
3086       else {
3087         if ( (setwd10[LA(1)]&0x2) ) {
3088         }
3089         else {zzFAIL(1,zzerr59,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3090       }
3091       zzEXIT(zztasp2);
3092       }
3093     }
3094     {
3095       zzBLOCK(zztasp2);
3096       zzMake0;
3097       {
3098       if ( (LA(1)==151) ) {
3099         {
3100           zzBLOCK(zztasp3);
3101           int zzcnt=1;
3102           zzMake0;
3103           {
3104           do {
3105             enum_def(  fname );
3106             zzLOOP(zztasp3);
3107           } while ( (LA(1)==151) );
3108           zzEXIT(zztasp3);
3109           }
3110         }
3111       }
3112       else {
3113         if ( (LA(1)==149) ) {
3114           defines(  fname );
3115         }
3116         else {zzFAIL(1,zzerr60,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3117       }
3118       zzEXIT(zztasp2);
3119       }
3120     }
3121   }
3122   else {
3123     if ( (LA(1)==Eof) ) {
3124     }
3125     else {zzFAIL(1,zzerr61,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3126   }
3127   zzEXIT(zztasp1);
3128   return;
3129 fail:
3130   zzEXIT(zztasp1);
3131   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
3132   zzresynch(setwd10, 0x4);
3133   }
3134 }
3135 
3136 void
3137 #ifdef __USE_PROTOS
defines(char * fname)3138 defines(char * fname)
3139 #else
3140 defines(fname)
3141  char *fname ;
3142 #endif
3143 {
3144   zzRULE;
3145   zzBLOCK(zztasp1);
3146   zzMake0;
3147   {
3148   int v; int maxt=(-1); char *t;
3149   {
3150     zzBLOCK(zztasp2);
3151     int zzcnt=1;
3152     zzMake0;
3153     {
3154     do {
3155       zzmatch(149); zzCONSUME;
3156       zzmatch(ID);
3157       t = mystrdup(LATEXT(1));
3158  zzCONSUME;
3159 
3160       zzmatch(INT);
3161 
3162       v = atoi(LATEXT(1));
3163       /*			fprintf(stderr, "#token %s=%d\n", t, v);*/
3164 
3165 	/* MR2 Andreas Magnusson ([email protected]) */
3166       /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */
3167       /* MR2 Don't let #tokdefs be confused by 			*/
3168       /* MR2   DLGminToken and DLGmaxToken     			*/
3169 
3170 			if ( ! isDLGmaxToken(t)) {		/* MR2 */
3171       TokenNum = v;
3172       if ( v>maxt ) maxt=v;
3173       if ( Tnum( t ) == 0 ) {
3174       addForcedTname( t, v );
3175     } else {
3176     warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);
3177   };
3178 };
3179  zzCONSUME;
3180 
3181       zzLOOP(zztasp2);
3182     } while ( (LA(1)==149) );
3183     zzEXIT(zztasp2);
3184     }
3185   }
3186   TokenNum = maxt + 1;
3187   zzEXIT(zztasp1);
3188   return;
3189 fail:
3190   zzEXIT(zztasp1);
3191   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
3192   zzresynch(setwd10, 0x8);
3193   }
3194 }
3195 
3196 void
3197 #ifdef __USE_PROTOS
enum_def(char * fname)3198 enum_def(char * fname)
3199 #else
3200 enum_def(fname)
3201  char *fname ;
3202 #endif
3203 {
3204   zzRULE;
3205   zzBLOCK(zztasp1);
3206   zzMake0;
3207   {
3208   int v= 0; int maxt=(-1); char *t;
3209   zzmatch(151); zzCONSUME;
3210   zzmatch(ID); zzCONSUME;
3211   zzmatch(152); zzCONSUME;
3212   zzmatch(ID);
3213   t = mystrdup(LATEXT(1));
3214  zzCONSUME;
3215 
3216   {
3217     zzBLOCK(zztasp2);
3218     zzMake0;
3219     {
3220     if ( (LA(1)==153) ) {
3221       zzmatch(153); zzCONSUME;
3222       zzmatch(INT);
3223       v=atoi(LATEXT(1));
3224  zzCONSUME;
3225 
3226     }
3227     else {
3228       if ( (setwd10[LA(1)]&0x10) ) {
3229         v++;
3230       }
3231       else {zzFAIL(1,zzerr62,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3232     }
3233     zzEXIT(zztasp2);
3234     }
3235   }
3236 
3237   /*			fprintf(stderr, "#token %s=%d\n", t, v);*/
3238   TokenNum = v;
3239   if ( v>maxt ) maxt=v;				/* MR3 */
3240   if ( Tnum( t ) == 0 ) addForcedTname( t, v );
3241   else {
3242     warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);
3243   }
3244   {
3245     zzBLOCK(zztasp2);
3246     zzMake0;
3247     {
3248     while ( (LA(1)==154) ) {
3249       zzmatch(154); zzCONSUME;
3250       {
3251         zzBLOCK(zztasp3);
3252         zzMake0;
3253         {
3254         if ( (LA(1)==ID)&&(isDLGmaxToken(LATEXT(1))) ) {
3255           if (!(isDLGmaxToken(LATEXT(1)))            ) {zzfailed_pred("  isDLGmaxToken(LATEXT(1))",0 /* report */, { 0; /* no user action */ } );}
3256           zzmatch(ID); zzCONSUME;
3257           {
3258             zzBLOCK(zztasp4);
3259             zzMake0;
3260             {
3261             if ( (LA(1)==153) ) {
3262               zzmatch(153); zzCONSUME;
3263               zzmatch(INT); zzCONSUME;
3264             }
3265             else {
3266               if ( (setwd10[LA(1)]&0x20) ) {
3267               }
3268               else {zzFAIL(1,zzerr63,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3269             }
3270             zzEXIT(zztasp4);
3271             }
3272           }
3273         }
3274         else {
3275           if ( (LA(1)==ID) ) {
3276             zzmatch(ID);
3277             t = mystrdup(LATEXT(1));
3278  zzCONSUME;
3279 
3280             {
3281               zzBLOCK(zztasp4);
3282               zzMake0;
3283               {
3284               if ( (LA(1)==153) ) {
3285                 zzmatch(153); zzCONSUME;
3286                 zzmatch(INT);
3287                 v=atoi(LATEXT(1));
3288  zzCONSUME;
3289 
3290               }
3291               else {
3292                 if ( (setwd10[LA(1)]&0x40) ) {
3293                   v++;
3294                 }
3295                 else {zzFAIL(1,zzerr64,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3296               }
3297               zzEXIT(zztasp4);
3298               }
3299             }
3300 
3301             /*					fprintf(stderr, "#token %s=%d\n", t, v);*/
3302             TokenNum = v;
3303             if ( v>maxt ) maxt=v;				/* MR3 */
3304             if ( Tnum( t ) == 0 ) addForcedTname( t, v );
3305             else {
3306               warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);
3307             }
3308           }
3309           else {
3310             if ( (setwd10[LA(1)]&0x80) ) {
3311             }
3312             else {zzFAIL(1,zzerr65,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
3313           }
3314         }
3315         zzEXIT(zztasp3);
3316         }
3317       }
3318       zzLOOP(zztasp2);
3319     }
3320     zzEXIT(zztasp2);
3321     }
3322   }
3323   zzmatch(155); zzCONSUME;
3324   zzmatch(156);
3325   TokenNum = maxt + 1;
3326  zzCONSUME;
3327 
3328   zzEXIT(zztasp1);
3329   return;
3330 fail:
3331   zzEXIT(zztasp1);
3332   zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
3333   zzresynch(setwd11, 0x1);
3334   }
3335 }
3336 
3337 
3338 /* MR2 Andreas Magnusson ([email protected]) */
3339 /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */
3340 /* MR2 Don't let #tokdefs be confused by 			*/
3341 /* MR2   DLGminToken and DLGmaxToken     			*/
3342 
3343 /* semantic check on DLGminToken and DLGmaxmaxToken in #tokdefs */
3344 
3345 #ifdef __USE_PROTOS
isDLGmaxToken(char * Token)3346 static int isDLGmaxToken(char *Token)
3347 #else
3348 static int isDLGmaxToken(Token)
3349 char *	Token;
3350 #endif
3351 {
3352 static char checkStr1[] = "DLGmaxToken";
3353 static char checkStr2[] = "DLGminToken";
3354 
3355    if (strcmp(Token, checkStr1) == 0)
3356 return 1;
3357 else if (strcmp(Token, checkStr2) == 0)
3358 return 1;
3359 else
3360 return 0;
3361 }
3362 
3363 /* semantics of #token */
3364 static void
3365 #ifdef __USE_PROTOS
chkToken(char * t,char * e,char * a,int tnum)3366 chkToken(char *t, char *e, char *a, int tnum)
3367 #else
3368 chkToken(t,e,a,tnum)
3369 char *t, *e, *a;
3370 int tnum;
3371 #endif
3372 {
3373 TermEntry *p;
3374 
3375 	/* check to see that they don't try to redefine a token as a token class */
3376 if ( t!=NULL ) {
3377 p = (TermEntry *) hash_get(Tname, t);
3378 if ( p!=NULL && p->classname ) {
3379   err(eMsg1("redefinition of #tokclass '%s' to #token not allowed; ignored",t));
3380   if ( a!=NULL ) free((char *)a);
3381   return;
3382 }
3383 }
3384 
3385 	if ( t==NULL && e==NULL ) {			/* none found */
3386 err("#token requires at least token name or rexpr");
3387 }
3388 else if ( t!=NULL && e!=NULL ) {	/* both found */
3389 if ( UserDefdTokens ) {			/* if #tokdefs, must not define new */
3390   p = (TermEntry *) hash_get(Tname, t);
3391   if ( p == NULL) {
3392     err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));
3393     return;
3394   };
3395 }
3396 Tklink(t, e);
3397 if ( a!=NULL ) {
3398   if ( hasAction(e) ) {
3399     err(eMsg1("redefinition of action for %s; ignored",e));
3400   }
3401   else setHasAction(e, a);
3402 }
3403 }
3404 else if ( t!=NULL ) {				/* only one found */
3405 if ( UserDefdTokens ) {
3406   p = (TermEntry *) hash_get(Tname, t);
3407   if (p == NULL) {
3408     err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));
3409   };
3410   return;
3411 }
3412 if ( Tnum( t ) == 0 ) addTname( t );
3413 else {
3414   err(eMsg1("redefinition of token %s; ignored",t));
3415 }
3416 if ( a!=NULL ) {
3417   err(eMsg1("action cannot be attached to a token name (%s); ignored",t));
3418   free((char *)a);
3419 }
3420 }
3421 else if ( e!=NULL ) {
3422 if ( Tnum( e ) == 0 ) addTexpr( e );
3423 else {
3424   if ( hasAction(e) ) {
3425     err(eMsg1("redefinition of action for expr %s; ignored",e));
3426   }
3427   else if ( a==NULL ) {
3428     err(eMsg1("redefinition of expr %s; ignored",e));
3429   }
3430 }
3431 if ( a!=NULL ) setHasAction(e, a);
3432 }
3433 
3434 	/* if a token type number was specified, then add the token ID and 'tnum'
3435 * pair to the ForcedTokens list.  (only applies if an id was given)
3436 */
3437 if ( t!=NULL && tnum>0 )
3438 {
3439 if ( set_el(tnum, reserved_positions) )
3440 {
3441   err(eMsgd("a token has already been forced to token number %d; ignored", tnum));
3442 }
3443 else
3444 {
3445   list_add(&ForcedTokens, newForcedToken(t,tnum));
3446   set_orel(tnum, &reserved_positions);
3447 }
3448 }
3449 }
3450 
3451 static int
3452 #ifdef __USE_PROTOS
match_token(char * s,char ** nxt)3453 match_token(char *s, char **nxt)
3454 #else
3455 match_token(s,nxt)
3456 char *s;
3457 char **nxt;
3458 #endif
3459 {
3460   if ( !(*s>='A' && *s<='Z') ) return 0;
3461   s++;
3462   while ( (*s>='a' && *s<='z') ||
3463   (*s>='A' && *s<='Z') ||
3464   (*s>='0' && *s<='9') ||
3465   *s=='_' )
3466   {
3467     s++;
3468   }
3469   if ( *s!=' ' && *s!='}' ) return 0;
3470   *nxt = s;
3471   return 1;
3472 }
3473 
3474 static int
3475 #ifdef __USE_PROTOS
match_rexpr(char * s,char ** nxt)3476 match_rexpr(char *s, char **nxt)
3477 #else
3478 match_rexpr(s,nxt)
3479 char *s;
3480 char **nxt;
3481 #endif
3482 {
3483   if ( *s!='"' ) return 0;
3484   s++;
3485   while ( *s!='"' )
3486   {
3487     if ( *s=='\n' || *s=='\r' )                   /* MR13 */
3488     warn("eoln found in regular expression");
3489     if ( *s=='\\' ) s++;
3490     s++;
3491   }
3492   *nxt = s+1;
3493   return 1;
3494 }
3495 
3496 /*
3497 * Walk a string "{ A .. Z }" where A..Z is a space separated list
3498 * of token references (either labels or reg exprs).  Return a
3499 * string "inlineX_set" for some unique integer X.  Basically,
3500 * we pretend as if we had seen "#tokclass inlineX { A .. Z }"
3501 * on the input stream outside of an action.
3502 */
3503 char *
3504 #ifdef __USE_PROTOS
inline_set(char * s)3505 inline_set(char *s)
3506 #else
3507 inline_set(s)
3508 char *s;
3509 #endif
3510 {
3511   char *nxt;
3512   fprintf(stderr, "found consumeUntil( {...} )\n");
3513   while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}
3514   if ( *s!='{' )
3515   {
3516     err("malformed consumeUntil( {...} ); missing '{'");
3517     return "bad_set";
3518   }
3519   s++;
3520   while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}
3521   while ( *s!='}' )
3522   {
3523     if ( match_token(s,&nxt) ) fprintf(stderr, "found token %s\n", s);
3524     else if ( match_rexpr(s,&nxt) ) fprintf(stderr, "found rexpr %s\n", s);
3525     else {
3526       err("invalid element in consumeUntil( {...} )");
3527       return "bad_set";
3528     }
3529     s = nxt;
3530     while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}
3531   }
3532   return "inlineX_set";
3533 }
3534 
3535 /* ANTLR-specific syntax error message generator
3536 * (define USER_ZZSYN when compiling so don't get 2 definitions)
3537 */
3538 void
3539 #ifdef __USE_PROTOS
zzsyn(char * text,int tok,char * egroup,SetWordType * eset,int etok,int k,char * bad_text)3540 zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok,
3541 int k, char *bad_text)
3542 #else
3543 zzsyn(text, tok, egroup, eset, etok, k, bad_text)
3544 char *text, *egroup, *bad_text;
3545 int tok;
3546 int etok;
3547 int k;
3548 SetWordType *eset;
3549 #endif
3550 {
3551 fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);
3552 fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);
3553 if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
3554 if ( k==1 ) fprintf(stderr, " missing");
3555 else
3556 {
3557 fprintf(stderr, "; \"%s\" not", bad_text);
3558 if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
3559 }
3560 if ( zzset_deg(eset)>0 ) zzedecode(eset);
3561 else fprintf(stderr, " %s", zztokens[etok]);
3562 if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);
3563 fprintf(stderr, "\n");
3564 }
3565