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