4 * Standard error handling mechanism
8 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
9 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
10 * company may do whatever they wish with source code distributed with
11 * PCCTS or the code generated by PCCTS, including the incorporation of
12 * PCCTS, or its output, into commerical software.
14 * We encourage users to develop software with PCCTS. However, we do ask
15 * that credit is given to us for developing PCCTS. By "credit",
16 * we mean that if you incorporate our source code into one of your
17 * programs (commercial product, research project, or otherwise) that you
18 * acknowledge this fact somewhere in the documentation, research report,
19 * etc... If you like PCCTS and have developed a nice tool with the
20 * output, please mention that you developed it using PCCTS. In
21 * addition, we ask that this header remain intact in our source code.
22 * As long as these guidelines are kept, we expect to continue enhancing
23 * this system and expect to make other tools available as they are
26 * Has grown to hold all kinds of stuff (err.h is increasingly misnamed)
30 * Parr Research Corporation
31 * with Purdue University and AHPCRC, University of Minnesota
44 /* Proper choice of STDC and cplusplus pre-processor symbols (?) */
46 #include "pccts_string.h"
48 #ifdef PCCTS_USE_STDARG
49 #include "pccts_stdarg.h"
55 /* Define usable bits per unsigned int word (used for set stuff) */
57 #define BSETWORDSIZE 16
58 #define BSETLOGWORDSIZE 4
60 #define BSETWORDSIZE 32
61 #define BSETLOGWORDSIZE 5
65 #define BSETWORDSIZE 8
66 #define BSETLOGWORDSIZE 3 /* SetWordType is 8bits */
68 #define BSETMODWORD(x) ((x) & (BSETWORDSIZE-1)) /* x % BSETWORDSIZE */
69 #define BSETDIVWORD(x) ((x) >> BSETLOGWORDSIZE) /* x / BSETWORDSIZE */
71 /* This is not put into the global pccts_parser structure because it is
72 * hidden and does not need to be saved during a "save state" operation
74 /* maximum of 32 bits/unsigned int and must be 8 bits/byte */
75 static SetWordType bitmask
[] = {
76 0x00000001, 0x00000002, 0x00000004, 0x00000008,
77 0x00000010, 0x00000020, 0x00000040, 0x00000080
81 int zzTraceOptionValueDefault
=1;
82 int zzTraceOptionValue
=1;
83 int zzTraceGuessOptionValue
=1;
84 char *zzTraceCurrentRuleName
=NULL
;
88 int zzGuessSeq
=0; /* MR10 */
89 int zzSyntaxErrCount
=0; /* MR11 */
90 int zzLexErrCount
=0; /* MR11 */
94 zzresynch(SetWordType
*wd
,SetWordType mask
)
97 SetWordType
*wd
, mask
;
100 static int consumed
= 1;
102 /* if you enter here without having consumed a token from last resynch
103 * force a token consumption.
105 if ( !consumed
) {zzCONSUME
; consumed
=1; return;} /* MR10 */
107 /* if current token is in resynch set, we've got what we wanted */
108 if ( wd
[LA(1)]&mask
|| LA(1) == zzEOF_TOKEN
) {consumed
=0; return;}
110 /* scan until we find something in the resynch set */
111 while ( !(wd
[LA(1)]&mask
) && LA(1) != zzEOF_TOKEN
) {zzCONSUME
;}
116 /* 7-Apr-97 133MR1 for C++ and MR7 for C */
117 /* Change suggested by Eli Sternheim (eli@interhdl.com) */
122 zzconsumeUntil(SetWordType
*st
)
129 while ( !zzset_el( (tmp
=LA(1)), st
) && tmp
!=1 /* Eof */) { /* MR7 */
130 zzCONSUME
; } /* MR7 */
134 /* 7-Apr-97 133MR1 for C++ and MR7 for C */
135 /* Change suggested by Eli Sternheim (eli@interhdl.com) */
140 zzconsumeUntilToken(int t
)
142 zzconsumeUntilToken(t
)
147 while ( (tmp
=LA(1)) !=t
&& tmp
!=1 /* Eof */) { zzCONSUME
; } /* MR7 */
151 * zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText)
152 * where the zzMiss stuff is set here to the token that did not match
153 * (and which set wasn't it a member of).
156 #ifdef PCCTS_USE_STDARG
157 void zzFAIL(int k
, ...)
159 void zzFAIL(va_alist
)
164 static char text
[LL_K
*ZZLEXBUFSIZE
+1];
165 SetWordType
*f
[LL_K
];
167 static char text
[ZZLEXBUFSIZE
+1];
170 SetWordType
**miss_set
;
177 #ifndef PCCTS_USE_STDARG /* MR20 */
180 #ifdef PCCTS_USE_STDARG /* MR20 */
184 k
= va_arg(ap
, int); /* how many lookahead sets? */
186 assert(k
<= sizeof(f
)/sizeof(f
[0])); /* MR20 G. Hobbelt */
188 for (i
=1; i
<=k
; i
++) /* collect all lookahead sets */
190 f
[i
-1] = va_arg(ap
, SetWordType
*);
192 for (i
=1; i
<=k
; i
++) /* look for offending token */
194 if ( i
>1 ) strcat(text
, " ");
195 strcat(text
, LATEXT(i
));
196 if ( !zzset_el((unsigned)LA(i
), f
[i
-1]) ) break;
198 miss_set
= va_arg(ap
, SetWordType
**);
199 miss_text
= va_arg(ap
, char **);
200 bad_tok
= va_arg(ap
, int *);
201 bad_text
= va_arg(ap
, char **);
202 err_k
= va_arg(ap
, int *);
205 /* bad; lookahead is permutation that cannot be matched,
206 * but, the ith token of lookahead is valid at the ith position
207 * (The old LL sub 1 (k) versus LL(k) parsing technique)
210 *miss_text
= zzlextext
;
212 *bad_text
= LATEXT(1);
216 /* fprintf(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/
220 *bad_text
= LATEXT(i
);
221 if ( i
==1 ) *err_k
= 1;
226 void zzTraceGuessDone(zzantlr_state
*state
)
228 void zzTraceGuessDone(state
)
229 zzantlr_state
*state
;
237 if (zzTraceCurrentRuleName
== NULL
) return;
239 if (zzTraceOptionValue
<= 0) {
241 } else if (zzTraceGuessOptionValue
<= 0) {
248 fprintf(stderr
,"guess done - returning to rule %s {\"%s\"} at depth %d",
249 state
->traceCurrentRuleName
,
252 if (state
->guessing
!= 0) {
253 fprintf(stderr
," (guess mode continues - an enclosing guess is still active)");
255 fprintf(stderr
," (guess mode ends)");
257 fprintf(stderr
,"\n");
265 zzsave_antlr_state(zzantlr_state
*buf
)
267 zzsave_antlr_state(buf
)
276 buf
->guess_start
= zzguess_start
;
277 buf
->guessing
= zzguessing
;
281 buf
->ast_sp
= zzast_sp
;
284 buf
->inf_labase
= zzinf_labase
;
285 buf
->inf_last
= zzinf_last
;
287 /* MR6 Gunnar Rxnning (gunnar@candleweb.no) */
288 /* MR6 Additional state needs to be saved/restored */
290 buf
->inf_tokens
= zzinf_tokens
; /* MR6 */
291 buf
->inf_text
= zzinf_text
; /* MR6 */
292 buf
->inf_text_buffer
= zzinf_text_buffer
; /* MR6 */
293 buf
->inf_line
= zzinf_line
; /* MR6 */
297 buf
->dirty
= zzdirty
;
300 for (i
=0; i
<LL_K
; i
++) buf
->tokenLA
[i
] = zztokenLA
[i
];
301 for (i
=0; i
<LL_K
; i
++) strcpy(buf
->textLA
[i
], zztextLA
[i
]);
303 buf
->labase
= zzlabase
;
305 buf
->token
= zztoken
;
306 strcpy(buf
->text
, zzlextext
);
312 buf
->traceOptionValue
=zzTraceOptionValue
;
313 buf
->traceGuessOptionValue
=zzTraceGuessOptionValue
;
314 buf
->traceCurrentRuleName
=zzTraceCurrentRuleName
;
315 buf
->traceDepth
=zzTraceDepth
;
321 zzrestore_antlr_state(zzantlr_state
*buf
)
323 zzrestore_antlr_state(buf
)
329 int prevTraceOptionValue
;
337 zzguess_start
= buf
->guess_start
;
338 zzguessing
= buf
->guessing
;
342 zzast_sp
= buf
->ast_sp
;
345 zzinf_labase
= buf
->inf_labase
;
346 zzinf_last
= buf
->inf_last
;
348 /* MR6 Gunnar Rxnning (gunnar@candleweb.no) */
349 /* MR6 Additional state needs to be saved/restored */
351 zzinf_tokens
= buf
->inf_tokens
; /* MR6 */
352 zzinf_text
= buf
->inf_text
; /* MR6 */
353 zzinf_text_buffer
= buf
->inf_text_buffer
; /* MR6 */
354 zzinf_line
= buf
->inf_line
; /* MR6 */
357 zzdirty
= buf
->dirty
;
360 for (i
=0; i
<LL_K
; i
++) zztokenLA
[i
] = buf
->tokenLA
[i
];
361 for (i
=0; i
<LL_K
; i
++) strcpy(zztextLA
[i
], buf
->textLA
[i
]);
363 zzlabase
= buf
->labase
;
365 zztoken
= buf
->token
;
366 strcpy(zzlextext
, buf
->text
);
370 prevTraceOptionValue
=zzTraceOptionValue
;
371 zzTraceOptionValue
=buf
->traceOptionValue
;
372 if ( (prevTraceOptionValue
> 0) !=
373 (zzTraceOptionValue
> 0)) {
374 if (zzTraceOptionValue
> 0) {
375 fprintf(stderr
,"trace enable restored in rule %s depth %d\n",
376 zzTraceCurrentRuleName
,zzTraceDepth
);
378 if (zzTraceOptionValue
<= 0) {
379 fprintf(stderr
,"trace disable restored in rule %s depth %d\n",
380 zzTraceCurrentRuleName
,zzTraceDepth
);
384 zzTraceOptionValue
=buf
->traceOptionValue
; /* MR10 */
385 zzTraceGuessOptionValue
=buf
->traceGuessOptionValue
; /* MR10 */
386 zzTraceCurrentRuleName
=buf
->traceCurrentRuleName
; /* MR10 */
387 zzTraceDepth
=buf
->traceDepth
; /* MR10 */
388 zzTraceGuessDone(buf
); /* MR10 */
394 zzedecode(SetWordType
*a
)
400 register SetWordType
*p
= a
;
401 register SetWordType
*endp
= &(p
[zzSET_SIZE
]);
402 register unsigned e
= 0;
404 if ( zzset_deg(a
)>1 ) fprintf(stderr
, " {");
406 register SetWordType t
= *p
;
407 register SetWordType
*b
= &(bitmask
[0]);
409 if ( t
& *b
) fprintf(stderr
, " %s", zztokens
[e
]);
411 } while (++b
< &(bitmask
[sizeof(SetWordType
)*8]));
412 } while (++p
< endp
);
413 if ( zzset_deg(a
)>1 ) fprintf(stderr
, " }");
417 /* standard error reporting function */
420 zzsyn(char *text
, int tok
, char *egroup
, SetWordType
*eset
, int etok
, int k
, char *bad_text
)
422 zzsyn(text
, tok
, egroup
, eset
, etok
, k
, bad_text
)
423 char *text
, *egroup
, *bad_text
;
431 zzSyntaxErrCount
++; /* MR11 */
432 fprintf(stderr
, "line %d: syntax error at \"%s\"", zzline
, (tok
==zzEOF_TOKEN
)?"EOF":bad_text
);
433 if ( !etok
&& !eset
) {fprintf(stderr
, "\n"); return;}
434 if ( k
==1 ) fprintf(stderr
, " missing");
437 fprintf(stderr
, "; \"%s\" not", bad_text
);
438 if ( zzset_deg(eset
)>1 ) fprintf(stderr
, " in");
440 if ( zzset_deg(eset
)>0 ) zzedecode(eset
);
441 else fprintf(stderr
, " %s", zztokens
[etok
]);
442 if ( strlen(egroup
) > 0 ) fprintf(stderr
, " in %s", egroup
);
443 fprintf(stderr
, "\n");
447 /* is b an element of set p? */
450 zzset_el(unsigned b
, SetWordType
*p
)
457 return( p
[BSETDIVWORD(b
)] & bitmask
[BSETMODWORD(b
)] );
462 zzset_deg(SetWordType
*a
)
468 /* Fast compute degree of a set... the number
469 of elements present in the set. Assumes
470 that all word bits are used in the set
472 register SetWordType
*p
= a
;
473 register SetWordType
*endp
= &(a
[zzSET_SIZE
]);
474 register int degree
= 0;
476 if ( a
== NULL
) return 0;
479 register SetWordType t
= *p
;
480 register SetWordType
*b
= &(bitmask
[0]);
482 if (t
& *b
) ++degree
;
483 } while (++b
< &(bitmask
[sizeof(SetWordType
)*8]));
495 _zzmatch(int _t
, char **zzBadText
, char **zzMissText
,
496 int *zzMissTok
, int *zzBadTok
,
497 SetWordType
**zzMissSet
)
499 _zzmatch(_t
, zzBadText
, zzMissText
, zzMissTok
, zzBadTok
, zzMissSet
)
503 int *zzMissTok
, *zzBadTok
;
504 SetWordType
**zzMissSet
;
507 if ( zzdirty
==LL_K
) {
511 *zzBadText
= *zzMissText
=LATEXT(1);
512 *zzMissTok
= _t
; *zzBadTok
=LA(1);
524 _zzmatch_wsig(int _t
)
530 if ( zzdirty
==LL_K
) {
546 _zzmatch(int _t
, char **zzBadText
, char **zzMissText
,
547 int *zzMissTok
, int *zzBadTok
, SetWordType
**zzMissSet
)
549 _zzmatch(_t
, zzBadText
, zzMissText
, zzMissTok
, zzBadTok
, zzMissSet
)
553 int *zzMissTok
, *zzBadTok
;
554 SetWordType
**zzMissSet
;
557 if ( zzdirty
) {zzCONSUME
;}
559 *zzBadText
= *zzMissText
=LATEXT(1);
560 *zzMissTok
= _t
; *zzBadTok
=LA(1);
571 _zzmatch_wsig(int _t
)
577 if ( zzdirty
) {zzCONSUME
;}
592 _zzmatch(int _t
, char **zzBadText
, char **zzMissText
,
593 int *zzMissTok
, int *zzBadTok
,
594 SetWordType
**zzMissSet
)
596 _zzmatch(_t
, zzBadText
, zzMissText
, zzMissTok
, zzBadTok
, zzMissSet
)
600 int *zzMissTok
, *zzBadTok
;
601 SetWordType
**zzMissSet
;
605 *zzBadText
= *zzMissText
=LATEXT(1);
606 *zzMissTok
= _t
; *zzBadTok
=LA(1);
616 _zzmatch_wsig(int _t
)
622 if ( LA(1)!=_t
) return 0;
627 #endif /*DEMAND_LOOK*/
637 if ( zzinf_labase
>= zzinf_last
)
638 {NLA
= zzEOF_TOKEN
; strcpy(NLATEXT
, "");}
640 NLA
= zzinf_tokens
[zzinf_labase
];
641 zzline
= zzinf_line
[zzinf_labase
]; /* wrong in 1.21 */
642 strcpy(NLATEXT
, zzinf_text
[zzinf_labase
]);
649 /* allocate default size text,token and line arrays;
650 * then, read all of the input reallocing the arrays as needed.
651 * Once the number of total tokens is known, the LATEXT(i) array (zzinf_text)
652 * is allocated and its pointers are set to the tokens in zzinf_text_buffer.
656 zzfill_inf_look(void)
662 int zzinf_token_buffer_size
= ZZINF_DEF_TOKEN_BUFFER_SIZE
;
663 int zzinf_text_buffer_size
= ZZINF_DEF_TEXT_BUFFER_SIZE
;
664 int zzinf_text_buffer_index
= 0;
667 /* allocate text/token buffers */
668 zzinf_text_buffer
= (char *) malloc(zzinf_text_buffer_size
);
669 if ( zzinf_text_buffer
== NULL
)
671 fprintf(stderr
, "cannot allocate lookahead text buffer (%d bytes)\n",
672 zzinf_text_buffer_size
);
673 exit(PCCTS_EXIT_FAILURE
);
675 zzinf_tokens
= (int *) calloc(zzinf_token_buffer_size
,sizeof(int));
676 if ( zzinf_tokens
== NULL
)
678 fprintf(stderr
, "cannot allocate token buffer (%d tokens)\n",
679 zzinf_token_buffer_size
);
680 exit(PCCTS_EXIT_FAILURE
);
682 zzinf_line
= (int *) calloc(zzinf_token_buffer_size
,sizeof(int));
683 if ( zzinf_line
== NULL
)
685 fprintf(stderr
, "cannot allocate line buffer (%d ints)\n",
686 zzinf_token_buffer_size
);
687 exit(PCCTS_EXIT_FAILURE
);
690 /* get tokens, copying text to text buffer */
691 zzinf_text_buffer_index
= 0;
695 while ( zzinf_lap
>=zzinf_token_buffer_size
)
697 zzinf_token_buffer_size
+= ZZINF_BUFFER_TOKEN_CHUNK_SIZE
;
698 zzinf_tokens
= (int *) realloc(zzinf_tokens
,
699 zzinf_token_buffer_size
*sizeof(int));
700 if ( zzinf_tokens
== NULL
)
702 fprintf(stderr
, "cannot allocate lookahead token buffer (%d tokens)\n",
703 zzinf_token_buffer_size
);
704 exit(PCCTS_EXIT_FAILURE
);
706 zzinf_line
= (int *) realloc(zzinf_line
,
707 zzinf_token_buffer_size
*sizeof(int));
708 if ( zzinf_line
== NULL
)
710 fprintf(stderr
, "cannot allocate lookahead line buffer (%d ints)\n",
711 zzinf_token_buffer_size
);
712 exit(PCCTS_EXIT_FAILURE
);
716 while ( (zzinf_text_buffer_index
+strlen(NLATEXT
)+1) >= zzinf_text_buffer_size
)
718 zzinf_text_buffer_size
+= ZZINF_BUFFER_TEXT_CHUNK_SIZE
;
719 zzinf_text_buffer
= (char *) realloc(zzinf_text_buffer
,
720 zzinf_text_buffer_size
);
721 if ( zzinf_text_buffer
== NULL
)
723 fprintf(stderr
, "cannot allocate lookahead text buffer (%d bytes)\n",
724 zzinf_text_buffer_size
);
725 exit(PCCTS_EXIT_FAILURE
);
728 /* record token and text and line of input symbol */
729 tok
= zzinf_tokens
[zzinf_lap
] = NLA
;
730 strcpy(&zzinf_text_buffer
[zzinf_text_buffer_index
], NLATEXT
);
731 zzinf_text_buffer_index
+= strlen(NLATEXT
)+1;
732 zzinf_line
[zzinf_lap
] = line
;
734 } while (tok
!=zzEOF_TOKEN
);
736 zzinf_last
= zzinf_lap
-1;
738 /* allocate ptrs to text of ith token */
739 zzinf_text
= (char **) calloc(zzinf_last
+1,sizeof(char *));
740 if ( zzinf_text
== NULL
)
742 fprintf(stderr
, "cannot allocate lookahead text buffer (%d)\n",
743 zzinf_text_buffer_size
);
744 exit(PCCTS_EXIT_FAILURE
);
746 zzinf_text_buffer_index
= 0;
748 /* set ptrs so that zzinf_text[i] is the text of the ith token found on input */
749 while (zzinf_lap
<=zzinf_last
)
751 zzinf_text
[zzinf_lap
++] = &zzinf_text_buffer
[zzinf_text_buffer_index
];
752 zzinf_text_buffer_index
+= strlen(&zzinf_text_buffer
[zzinf_text_buffer_index
])+1;
759 _zzsetmatch(SetWordType
*e
, char **zzBadText
, char **zzMissText
,
760 int *zzMissTok
, int *zzBadTok
,
761 SetWordType
**zzMissSet
,
762 SetWordType
*zzTokclassErrset
/* MR23 */)
764 _zzsetmatch(e
, zzBadText
, zzMissText
, zzMissTok
, zzBadTok
, zzMissSet
, zzTokclassErrset
/* MR23 */)
768 int *zzMissTok
, *zzBadTok
;
769 SetWordType
**zzMissSet
;
770 SetWordType
*zzTokclassErrset
;
775 if ( zzdirty
==LL_K
) {zzCONSUME
;}
777 if ( zzdirty
) {zzCONSUME
;}
780 if ( !zzset_el((unsigned)LA(1), e
) ) {
781 *zzBadText
= LATEXT(1); *zzMissText
=NULL
;
782 *zzMissTok
= 0; *zzBadTok
=LA(1);
783 *zzMissSet
=zzTokclassErrset
; /* MR23 */
786 zzMakeAttr
/* MR14 Ger Hobbelt (hobbelt@axa.nl) */
790 zzlabase
++; /* MR14 Ger Hobbelt (hobbelt@axa.nl) */
800 _zzmatch_wdfltsig(int tokenWanted
, SetWordType
*whatFollows
)
802 _zzmatch_wdfltsig(tokenWanted
, whatFollows
)
804 SetWordType
*whatFollows
;
809 if ( zzdirty
==LL_K
) {
813 if ( zzdirty
) {zzCONSUME
;}
817 if ( LA(1)!=tokenWanted
)
819 zzSyntaxErrCount
++; /* MR11 */
821 "line %d: syntax error at \"%s\" missing %s\n",
823 (LA(1)==zzEOF_TOKEN
)?"<eof>":(char *)LATEXT(1),
824 zztokens
[tokenWanted
]);
825 zzconsumeUntil( whatFollows
);
838 /* zzCONSUME; consume if not demand lookahead */
846 _zzsetmatch_wdfltsig(SetWordType
*tokensWanted
,
848 SetWordType
*whatFollows
)
850 _zzsetmatch_wdfltsig(tokensWanted
, tokenTypeOfSet
, whatFollows
)
851 SetWordType
*tokensWanted
;
853 SetWordType
*whatFollows
;
858 if ( zzdirty
==LL_K
) {zzCONSUME
;}
860 if ( zzdirty
) {zzCONSUME
;}
863 if ( !zzset_el((unsigned)LA(1), tokensWanted
) )
865 zzSyntaxErrCount
++; /* MR11 */
867 "line %d: syntax error at \"%s\" missing %s\n",
869 (LA(1)==zzEOF_TOKEN
)?"<eof>":(char *)LATEXT(1),
870 zztokens
[tokenTypeOfSet
]);
871 zzconsumeUntil( whatFollows
);
884 /* zzCONSUME; consume if not demand lookahead */
892 _zzsetmatch_wsig(SetWordType
*e
)
900 if ( zzdirty
==LL_K
) {zzCONSUME
;}
902 if ( zzdirty
) {zzCONSUME
;}
905 if ( !zzset_el((unsigned)LA(1), e
) ) return 0;
906 zzMakeAttr
/* MR14 Ger Hobbelt (hobbelt@axa.nl) */
910 zzlabase
++; /* MR14 Ger Hobbelt (hobbelt@axa.nl) */
918 #ifdef USER_ZZMODE_STACK
919 static int zzmstk
[ZZMAXSTK
] = { -1 };
920 static int zzmdep
= 0;
921 static char zzmbuf
[70];
931 if(zzmdep
== ZZMAXSTK
- 1) {
932 sprintf(zzmbuf
, "Mode stack overflow ");
935 zzmstk
[zzmdep
++] = zzauto
;
948 { sprintf(zzmbuf
, "Mode stack underflow ");
953 zzmode(zzmstk
[zzmdep
]);
959 zzsave_mode_stack( int modeStack
[], int *modeLevel
)
961 zzsave_mode_stack( modeStack
, modeLevel
)
967 memcpy(modeStack
, zzmstk
, sizeof(zzmstk
));
976 zzrestore_mode_stack( int modeStack
[], int *modeLevel
)
978 zzrestore_mode_stack( modeStack
, modeLevel
)
985 memcpy(zzmstk
, modeStack
, sizeof(zzmstk
));
990 #endif /* USER_ZZMODE_STACK */
993 void zzTraceReset(void)
999 zzTraceOptionValue
=zzTraceOptionValueDefault
;
1000 zzTraceGuessOptionValue
=1;
1001 zzTraceCurrentRuleName
=NULL
;
1007 void zzTraceGuessFail(void)
1009 void zzTraceGuessFail()
1013 #ifdef zzTRACE_RULES
1018 if (zzTraceOptionValue
<= 0) {
1020 } else if (zzguessing
&& zzTraceGuessOptionValue
<= 0) {
1027 fprintf(stderr
,"guess failed\n");
1034 zero value turns off trace
1038 void zzTraceIn(char * rule
)
1040 void zzTraceIn(rule
)
1044 #ifdef zzTRACE_RULES
1049 zzTraceCurrentRuleName
=rule
;
1051 if (zzTraceOptionValue
<= 0) {
1054 } else if (zzguessing
&& zzTraceGuessOptionValue
<= 0) {
1062 fprintf(stderr
,"enter rule %s {\"%s\"} depth %d",
1064 LA(1)==1 ? "@" : (char *) LATEXT(1), /* MR19 */
1067 if (zzguessing
) fprintf(stderr
," guessing");
1069 fprintf(stderr
,"\n");
1076 void zzTraceOut(char * rule
)
1078 void zzTraceOut(rule
)
1082 #ifdef zzTRACE_RULES
1087 if (zzTraceOptionValue
<= 0) {
1090 } else if (zzguessing
&& zzTraceGuessOptionValue
<= 0) {
1098 fprintf(stderr
,"exit rule %s {\"%s\"} depth %d",
1100 LA(1)==1 ? "@" : (char *) LATEXT(1), /* MR19 */
1103 if (zzguessing
) fprintf(stderr
," guessing");
1105 fprintf(stderr
,"\n");
1111 int zzTraceOption(int delta
)
1113 int zzTraceOption(delta
)
1117 #ifdef zzTRACE_RULES
1118 int prevValue
=zzTraceOptionValue
;
1120 zzTraceOptionValue
=zzTraceOptionValue
+delta
;
1122 if (zzTraceCurrentRuleName
!= NULL
) {
1123 if (prevValue
<= 0 && zzTraceOptionValue
> 0) {
1124 fprintf(stderr
,"trace enabled in rule %s depth %d\n",
1125 zzTraceCurrentRuleName
,zzTraceDepth
);
1127 if (prevValue
> 0 && zzTraceOptionValue
<= 0) {
1128 fprintf(stderr
,"trace disabled in rule %s depth %d\n",
1129 zzTraceCurrentRuleName
,zzTraceDepth
);
1139 int zzTraceGuessOption(int delta
)
1141 int zzTraceGuessOption(delta
)
1145 #ifdef zzTRACE_RULES
1147 int prevValue
=zzTraceGuessOptionValue
;
1149 zzTraceGuessOptionValue
=zzTraceGuessOptionValue
+delta
;
1151 if (zzTraceCurrentRuleName
!= NULL
) {
1152 if (prevValue
<= 0 && zzTraceGuessOptionValue
> 0) {
1153 fprintf(stderr
,"guess trace enabled in rule %s depth %d\n",
1154 zzTraceCurrentRuleName
,zzTraceDepth
);
1156 if (prevValue
> 0 && zzTraceGuessOptionValue
<= 0) {
1157 fprintf(stderr
,"guess trace disabled in rule %s depth %d\n",
1158 zzTraceCurrentRuleName
,zzTraceDepth
);