xref: /freebsd/contrib/byacc/test/btyacc/rename_debug.c (revision 1c05a6ea6b849ff95e539c31adea887c644a6a01)
1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
4 
5 #define YYBYACC 1
6 #define YYMAJOR 1
7 #define YYMINOR 9
8 #define YYCHECK "yyyymmdd"
9 
10 #define YYEMPTY        (-1)
11 #define yyclearin      (yychar = YYEMPTY)
12 #define yyerrok        (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
14 #define YYENOMEM       (-2)
15 #define YYEOF          0
16 #undef YYBTYACC
17 #define YYBTYACC 0
18 #define YYDEBUGSTR YYPREFIX "debug"
19 #line 20 "rename_debug.c"
20 #include "rename_debug.i"
21 #include "rename_debug.h"
22 typedef short YYINT;
23 static const YYINT yylhs[] = {                           -1,
24     0,
25 };
26 static const YYINT yylen[] = {                            2,
27     1,
28 };
29 static const YYINT yydefred[] = {                         0,
30     1,    0,
31 };
32 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
33 static const YYINT yystos[] = {                           0,
34   256,  258,
35 };
36 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
37 static const YYINT yydgoto[] = {                          2,
38 };
39 static const YYINT yysindex[] = {                      -256,
40     0,    0,
41 };
42 static const YYINT yyrindex[] = {                         0,
43     0,    0,
44 };
45 #if YYBTYACC
46 static const YYINT yycindex[] = {                         0,
47     0,    0,
48 };
49 #endif
50 static const YYINT yygindex[] = {                         0,
51 };
52 #define YYTABLESIZE 0
53 static const YYINT yytable[] = {                          1,
54 };
55 static const YYINT yycheck[] = {                        256,
56 };
57 #if YYBTYACC
58 static const YYINT yyctable[] = {                        -1,
59 };
60 #endif
61 #define YYFINAL 2
62 #ifndef YYDEBUG
63 #define YYDEBUG 1
64 #endif
65 #define YYMAXTOKEN 256
66 #define YYUNDFTOKEN 259
67 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
68 #if YYDEBUG
69 static const char *const yyname[] = {
70 
71 "$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
72 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
73 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
74 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
75 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
76 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
77 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","$accept","S","illegal-symbol",
78 };
79 static const char *const yyrule[] = {
80 "$accept : S",
81 "S : error",
82 
83 };
84 #endif
85 
86 int      yydebug;
87 int      yynerrs;
88 
89 int      yyerrflag;
90 int      yychar;
91 YYSTYPE  yyval;
92 YYSTYPE  yylval;
93 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
94 YYLTYPE  yyloc; /* position returned by actions */
95 YYLTYPE  yylloc; /* position from the lexer */
96 #endif
97 
98 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
99 #ifndef YYLLOC_DEFAULT
100 #define YYLLOC_DEFAULT(loc, rhs, n) \
101 do \
102 { \
103     if (n == 0) \
104     { \
105         (loc).first_line   = ((rhs)[-1]).last_line; \
106         (loc).first_column = ((rhs)[-1]).last_column; \
107         (loc).last_line    = ((rhs)[-1]).last_line; \
108         (loc).last_column  = ((rhs)[-1]).last_column; \
109     } \
110     else \
111     { \
112         (loc).first_line   = ((rhs)[ 0 ]).first_line; \
113         (loc).first_column = ((rhs)[ 0 ]).first_column; \
114         (loc).last_line    = ((rhs)[n-1]).last_line; \
115         (loc).last_column  = ((rhs)[n-1]).last_column; \
116     } \
117 } while (0)
118 #endif /* YYLLOC_DEFAULT */
119 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
120 #if YYBTYACC
121 
122 #ifndef YYLVQUEUEGROWTH
123 #define YYLVQUEUEGROWTH 32
124 #endif
125 #endif /* YYBTYACC */
126 
127 /* define the initial stack-sizes */
128 #ifdef YYSTACKSIZE
129 #undef YYMAXDEPTH
130 #define YYMAXDEPTH  YYSTACKSIZE
131 #else
132 #ifdef YYMAXDEPTH
133 #define YYSTACKSIZE YYMAXDEPTH
134 #else
135 #define YYSTACKSIZE 10000
136 #define YYMAXDEPTH  10000
137 #endif
138 #endif
139 
140 #ifndef YYINITSTACKSIZE
141 #define YYINITSTACKSIZE 200
142 #endif
143 
144 typedef struct {
145     unsigned stacksize;
146     YYINT    *s_base;
147     YYINT    *s_mark;
148     YYINT    *s_last;
149     YYSTYPE  *l_base;
150     YYSTYPE  *l_mark;
151 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
152     YYLTYPE  *p_base;
153     YYLTYPE  *p_mark;
154 #endif
155 } YYSTACKDATA;
156 #if YYBTYACC
157 
158 struct YYParseState_s
159 {
160     struct YYParseState_s *save;    /* Previously saved parser state */
161     YYSTACKDATA            yystack; /* saved parser stack */
162     int                    state;   /* saved parser state */
163     int                    errflag; /* saved error recovery status */
164     int                    lexeme;  /* saved index of the conflict lexeme in the lexical queue */
165     YYINT                  ctry;    /* saved index in yyctable[] for this conflict */
166 };
167 typedef struct YYParseState_s YYParseState;
168 #endif /* YYBTYACC */
169 /* variables for the parser stack */
170 static YYSTACKDATA yystack;
171 #if YYBTYACC
172 
173 /* Current parser state */
174 static YYParseState *yyps = 0;
175 
176 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
177 static YYParseState *yypath = 0;
178 
179 /* Base of the lexical value queue */
180 static YYSTYPE *yylvals = 0;
181 
182 /* Current position at lexical value queue */
183 static YYSTYPE *yylvp = 0;
184 
185 /* End position of lexical value queue */
186 static YYSTYPE *yylve = 0;
187 
188 /* The last allocated position at the lexical value queue */
189 static YYSTYPE *yylvlim = 0;
190 
191 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
192 /* Base of the lexical position queue */
193 static YYLTYPE *yylpsns = 0;
194 
195 /* Current position at lexical position queue */
196 static YYLTYPE *yylpp = 0;
197 
198 /* End position of lexical position queue */
199 static YYLTYPE *yylpe = 0;
200 
201 /* The last allocated position at the lexical position queue */
202 static YYLTYPE *yylplim = 0;
203 #endif
204 
205 /* Current position at lexical token queue */
206 static YYINT  *yylexp = 0;
207 
208 static YYINT  *yylexemes = 0;
209 #endif /* YYBTYACC */
210 #line 12 "code_debug.y"
211 
212 #include <stdio.h>
213 
214 #ifdef YYBYACC
215 extern int YYLEX_DECL();
216 #endif
217 
218 int
219 main(void)
220 {
221     printf("yyparse() = %d\n", yyparse());
222     return 0;
223 }
224 
225 int
226 yylex(void)
227 {
228     return -1;
229 }
230 
231 static void
232 yyerror(const char* s)
233 {
234     printf("%s\n", s);
235 }
236 #line 238 "rename_debug.c"
237 
238 /* For use in generated program */
239 #define yydepth (int)(yystack.s_mark - yystack.s_base)
240 #if YYBTYACC
241 #define yytrial (yyps->save)
242 #endif /* YYBTYACC */
243 
244 #if YYDEBUG
245 #include <stdio.h>	/* needed for printf */
246 #endif
247 
248 #include <stdlib.h>	/* needed for malloc, etc */
249 #include <string.h>	/* needed for memset */
250 
251 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
252 static int yygrowstack(YYSTACKDATA *data)
253 {
254     int i;
255     unsigned newsize;
256     YYINT *newss;
257     YYSTYPE *newvs;
258 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
259     YYLTYPE *newps;
260 #endif
261 
262     if ((newsize = data->stacksize) == 0)
263         newsize = YYINITSTACKSIZE;
264     else if (newsize >= YYMAXDEPTH)
265         return YYENOMEM;
266     else if ((newsize *= 2) > YYMAXDEPTH)
267         newsize = YYMAXDEPTH;
268 
269     i = (int) (data->s_mark - data->s_base);
270     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
271     if (newss == 0)
272         return YYENOMEM;
273 
274     data->s_base = newss;
275     data->s_mark = newss + i;
276 
277     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
278     if (newvs == 0)
279         return YYENOMEM;
280 
281     data->l_base = newvs;
282     data->l_mark = newvs + i;
283 
284 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
285     newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
286     if (newps == 0)
287         return YYENOMEM;
288 
289     data->p_base = newps;
290     data->p_mark = newps + i;
291 #endif
292 
293     data->stacksize = newsize;
294     data->s_last = data->s_base + newsize - 1;
295 
296 #if YYDEBUG
297     if (yydebug)
298         fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
299 #endif
300     return 0;
301 }
302 
303 #if YYPURE || defined(YY_NO_LEAKS)
304 static void yyfreestack(YYSTACKDATA *data)
305 {
306     free(data->s_base);
307     free(data->l_base);
308 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
309     free(data->p_base);
310 #endif
311     memset(data, 0, sizeof(*data));
312 }
313 #else
314 #define yyfreestack(data) /* nothing */
315 #endif /* YYPURE || defined(YY_NO_LEAKS) */
316 #if YYBTYACC
317 
318 static YYParseState *
319 yyNewState(unsigned size)
320 {
321     YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
322     if (p == NULL) return NULL;
323 
324     p->yystack.stacksize = size;
325     if (size == 0)
326     {
327         p->yystack.s_base = NULL;
328         p->yystack.l_base = NULL;
329 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
330         p->yystack.p_base = NULL;
331 #endif
332         return p;
333     }
334     p->yystack.s_base    = (YYINT *) malloc(size * sizeof(YYINT));
335     if (p->yystack.s_base == NULL) return NULL;
336     p->yystack.l_base    = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
337     if (p->yystack.l_base == NULL) return NULL;
338     memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
339 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
340     p->yystack.p_base    = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
341     if (p->yystack.p_base == NULL) return NULL;
342     memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
343 #endif
344 
345     return p;
346 }
347 
348 static void
349 yyFreeState(YYParseState *p)
350 {
351     yyfreestack(&p->yystack);
352     free(p);
353 }
354 #endif /* YYBTYACC */
355 
356 #define YYABORT  goto yyabort
357 #define YYREJECT goto yyabort
358 #define YYACCEPT goto yyaccept
359 #define YYERROR  goto yyerrlab
360 #if YYBTYACC
361 #define YYVALID        do { if (yyps->save)            goto yyvalid; } while(0)
362 #define YYVALID_NESTED do { if (yyps->save && \
363                                 yyps->save->save == 0) goto yyvalid; } while(0)
364 #endif /* YYBTYACC */
365 
366 int
367 YYPARSE_DECL()
368 {
369     int yym, yyn, yystate, yyresult;
370 #if YYBTYACC
371     int yynewerrflag;
372     YYParseState *yyerrctx = NULL;
373 #endif /* YYBTYACC */
374 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
375     YYLTYPE  yyerror_loc_range[2]; /* position of error start & end */
376 #endif
377 #if YYDEBUG
378     const char *yys;
379 
380     if ((yys = getenv("YYDEBUG")) != 0)
381     {
382         yyn = *yys;
383         if (yyn >= '0' && yyn <= '9')
384             yydebug = yyn - '0';
385     }
386     if (yydebug)
387         fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
388 #endif
389 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
390     memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
391 #endif
392 
393 #if YYBTYACC
394     yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
395     yyps->save = 0;
396 #endif /* YYBTYACC */
397     yym = 0;
398     yyn = 0;
399     yynerrs = 0;
400     yyerrflag = 0;
401     yychar = YYEMPTY;
402     yystate = 0;
403 
404 #if YYPURE
405     memset(&yystack, 0, sizeof(yystack));
406 #endif
407 
408     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
409     yystack.s_mark = yystack.s_base;
410     yystack.l_mark = yystack.l_base;
411 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
412     yystack.p_mark = yystack.p_base;
413 #endif
414     yystate = 0;
415     *yystack.s_mark = 0;
416 
417 yyloop:
418     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
419     if (yychar < 0)
420     {
421 #if YYBTYACC
422         do {
423         if (yylvp < yylve)
424         {
425             /* we're currently re-reading tokens */
426             yylval = *yylvp++;
427 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
428             yylloc = *yylpp++;
429 #endif
430             yychar = *yylexp++;
431             break;
432         }
433         if (yyps->save)
434         {
435             /* in trial mode; save scanner results for future parse attempts */
436             if (yylvp == yylvlim)
437             {   /* Enlarge lexical value queue */
438                 size_t p = (size_t) (yylvp - yylvals);
439                 size_t s = (size_t) (yylvlim - yylvals);
440 
441                 s += YYLVQUEUEGROWTH;
442                 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
443                 if ((yylvals   = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
444 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
445                 if ((yylpsns   = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
446 #endif
447                 yylvp   = yylve = yylvals + p;
448                 yylvlim = yylvals + s;
449 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
450                 yylpp   = yylpe = yylpsns + p;
451                 yylplim = yylpsns + s;
452 #endif
453                 yylexp  = yylexemes + p;
454             }
455             *yylexp = (YYINT) YYLEX;
456             *yylvp++ = yylval;
457             yylve++;
458 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
459             *yylpp++ = yylloc;
460             yylpe++;
461 #endif
462             yychar = *yylexp++;
463             break;
464         }
465         /* normal operation, no conflict encountered */
466 #endif /* YYBTYACC */
467         yychar = YYLEX;
468 #if YYBTYACC
469         } while (0);
470 #endif /* YYBTYACC */
471         if (yychar < 0) yychar = YYEOF;
472 #if YYDEBUG
473         if (yydebug)
474         {
475             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
476             fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
477                             YYDEBUGSTR, yydepth, yystate, yychar, yys);
478 #ifdef YYSTYPE_TOSTRING
479 #if YYBTYACC
480             if (!yytrial)
481 #endif /* YYBTYACC */
482                 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
483 #endif
484             fputc('\n', stderr);
485         }
486 #endif
487     }
488 #if YYBTYACC
489 
490     /* Do we have a conflict? */
491     if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
492         yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
493     {
494         YYINT ctry;
495 
496         if (yypath)
497         {
498             YYParseState *save;
499 #if YYDEBUG
500             if (yydebug)
501                 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
502                                 YYDEBUGSTR, yydepth, yystate);
503 #endif
504             /* Switch to the next conflict context */
505             save = yypath;
506             yypath = save->save;
507             save->save = NULL;
508             ctry = save->ctry;
509             if (save->state != yystate) YYABORT;
510             yyFreeState(save);
511 
512         }
513         else
514         {
515 
516             /* Unresolved conflict - start/continue trial parse */
517             YYParseState *save;
518 #if YYDEBUG
519             if (yydebug)
520             {
521                 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
522                 if (yyps->save)
523                     fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
524                 else
525                     fputs("Starting trial parse.\n", stderr);
526             }
527 #endif
528             save                  = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
529             if (save == NULL) goto yyenomem;
530             save->save            = yyps->save;
531             save->state           = yystate;
532             save->errflag         = yyerrflag;
533             save->yystack.s_mark  = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
534             memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
535             save->yystack.l_mark  = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
536             memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
537 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
538             save->yystack.p_mark  = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
539             memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
540 #endif
541             ctry                  = yytable[yyn];
542             if (yyctable[ctry] == -1)
543             {
544 #if YYDEBUG
545                 if (yydebug && yychar >= YYEOF)
546                     fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
547 #endif
548                 ctry++;
549             }
550             save->ctry = ctry;
551             if (yyps->save == NULL)
552             {
553                 /* If this is a first conflict in the stack, start saving lexemes */
554                 if (!yylexemes)
555                 {
556                     yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
557                     if (yylexemes == NULL) goto yyenomem;
558                     yylvals   = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
559                     if (yylvals == NULL) goto yyenomem;
560                     yylvlim   = yylvals + YYLVQUEUEGROWTH;
561 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
562                     yylpsns   = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
563                     if (yylpsns == NULL) goto yyenomem;
564                     yylplim   = yylpsns + YYLVQUEUEGROWTH;
565 #endif
566                 }
567                 if (yylvp == yylve)
568                 {
569                     yylvp  = yylve = yylvals;
570 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
571                     yylpp  = yylpe = yylpsns;
572 #endif
573                     yylexp = yylexemes;
574                     if (yychar >= YYEOF)
575                     {
576                         *yylve++ = yylval;
577 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
578                         *yylpe++ = yylloc;
579 #endif
580                         *yylexp  = (YYINT) yychar;
581                         yychar   = YYEMPTY;
582                     }
583                 }
584             }
585             if (yychar >= YYEOF)
586             {
587                 yylvp--;
588 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
589                 yylpp--;
590 #endif
591                 yylexp--;
592                 yychar = YYEMPTY;
593             }
594             save->lexeme = (int) (yylvp - yylvals);
595             yyps->save   = save;
596         }
597         if (yytable[yyn] == ctry)
598         {
599 #if YYDEBUG
600             if (yydebug)
601                 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
602                                 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
603 #endif
604             if (yychar < 0)
605             {
606                 yylvp++;
607 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
608                 yylpp++;
609 #endif
610                 yylexp++;
611             }
612             if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
613                 goto yyoverflow;
614             yystate = yyctable[ctry];
615             *++yystack.s_mark = (YYINT) yystate;
616             *++yystack.l_mark = yylval;
617 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
618             *++yystack.p_mark = yylloc;
619 #endif
620             yychar  = YYEMPTY;
621             if (yyerrflag > 0) --yyerrflag;
622             goto yyloop;
623         }
624         else
625         {
626             yyn = yyctable[ctry];
627             goto yyreduce;
628         }
629     } /* End of code dealing with conflicts */
630 #endif /* YYBTYACC */
631     if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
632             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
633     {
634 #if YYDEBUG
635         if (yydebug)
636             fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
637                             YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
638 #endif
639         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
640         yystate = yytable[yyn];
641         *++yystack.s_mark = yytable[yyn];
642         *++yystack.l_mark = yylval;
643 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
644         *++yystack.p_mark = yylloc;
645 #endif
646         yychar = YYEMPTY;
647         if (yyerrflag > 0)  --yyerrflag;
648         goto yyloop;
649     }
650     if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
651             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
652     {
653         yyn = yytable[yyn];
654         goto yyreduce;
655     }
656     if (yyerrflag != 0) goto yyinrecovery;
657 #if YYBTYACC
658 
659     yynewerrflag = 1;
660     goto yyerrhandler;
661     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
662 
663 yyerrlab:
664     /* explicit YYERROR from an action -- pop the rhs of the rule reduced
665      * before looking for error recovery */
666     yystack.s_mark -= yym;
667     yystate = *yystack.s_mark;
668     yystack.l_mark -= yym;
669 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
670     yystack.p_mark -= yym;
671 #endif
672 
673     yynewerrflag = 0;
674 yyerrhandler:
675     while (yyps->save)
676     {
677         int ctry;
678         YYParseState *save = yyps->save;
679 #if YYDEBUG
680         if (yydebug)
681             fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
682                             YYDEBUGSTR, yydepth, yystate, yyps->save->state,
683                     (int)(yylvp - yylvals - yyps->save->lexeme));
684 #endif
685         /* Memorize most forward-looking error state in case it's really an error. */
686         if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
687         {
688             /* Free old saved error context state */
689             if (yyerrctx) yyFreeState(yyerrctx);
690             /* Create and fill out new saved error context state */
691             yyerrctx                 = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
692             if (yyerrctx == NULL) goto yyenomem;
693             yyerrctx->save           = yyps->save;
694             yyerrctx->state          = yystate;
695             yyerrctx->errflag        = yyerrflag;
696             yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
697             memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
698             yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
699             memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
700 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
701             yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
702             memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
703 #endif
704             yyerrctx->lexeme         = (int) (yylvp - yylvals);
705         }
706         yylvp          = yylvals   + save->lexeme;
707 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
708         yylpp          = yylpsns   + save->lexeme;
709 #endif
710         yylexp         = yylexemes + save->lexeme;
711         yychar         = YYEMPTY;
712         yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
713         memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
714         yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
715         memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
716 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
717         yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
718         memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
719 #endif
720         ctry           = ++save->ctry;
721         yystate        = save->state;
722         /* We tried shift, try reduce now */
723         if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
724         yyps->save     = save->save;
725         save->save     = NULL;
726         yyFreeState(save);
727 
728         /* Nothing left on the stack -- error */
729         if (!yyps->save)
730         {
731 #if YYDEBUG
732             if (yydebug)
733                 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
734                                 YYPREFIX, yydepth);
735 #endif
736             /* Restore state as it was in the most forward-advanced error */
737             yylvp          = yylvals   + yyerrctx->lexeme;
738 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
739             yylpp          = yylpsns   + yyerrctx->lexeme;
740 #endif
741             yylexp         = yylexemes + yyerrctx->lexeme;
742             yychar         = yylexp[-1];
743             yylval         = yylvp[-1];
744 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
745             yylloc         = yylpp[-1];
746 #endif
747             yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
748             memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
749             yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
750             memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
751 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
752             yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
753             memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
754 #endif
755             yystate        = yyerrctx->state;
756             yyFreeState(yyerrctx);
757             yyerrctx       = NULL;
758         }
759         yynewerrflag = 1;
760     }
761     if (yynewerrflag == 0) goto yyinrecovery;
762 #endif /* YYBTYACC */
763 
764     YYERROR_CALL("syntax error");
765 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
766     yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
767 #endif
768 
769 #if !YYBTYACC
770     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
771 yyerrlab:
772 #endif
773     ++yynerrs;
774 
775 yyinrecovery:
776     if (yyerrflag < 3)
777     {
778         yyerrflag = 3;
779         for (;;)
780         {
781             if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
782                     yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
783             {
784 #if YYDEBUG
785                 if (yydebug)
786                     fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
787                                     YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
788 #endif
789                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
790                 yystate = yytable[yyn];
791                 *++yystack.s_mark = yytable[yyn];
792                 *++yystack.l_mark = yylval;
793 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
794                 /* lookahead position is error end position */
795                 yyerror_loc_range[1] = yylloc;
796                 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
797                 *++yystack.p_mark = yyloc;
798 #endif
799                 goto yyloop;
800             }
801             else
802             {
803 #if YYDEBUG
804                 if (yydebug)
805                     fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
806                                     YYDEBUGSTR, yydepth, *yystack.s_mark);
807 #endif
808                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
809 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
810                 /* the current TOS position is the error start position */
811                 yyerror_loc_range[0] = *yystack.p_mark;
812 #endif
813 #if defined(YYDESTRUCT_CALL)
814 #if YYBTYACC
815                 if (!yytrial)
816 #endif /* YYBTYACC */
817 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
818                     YYDESTRUCT_CALL("error: discarding state",
819                                     yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
820 #else
821                     YYDESTRUCT_CALL("error: discarding state",
822                                     yystos[*yystack.s_mark], yystack.l_mark);
823 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
824 #endif /* defined(YYDESTRUCT_CALL) */
825                 --yystack.s_mark;
826                 --yystack.l_mark;
827 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
828                 --yystack.p_mark;
829 #endif
830             }
831         }
832     }
833     else
834     {
835         if (yychar == YYEOF) goto yyabort;
836 #if YYDEBUG
837         if (yydebug)
838         {
839             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
840             fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
841                             YYDEBUGSTR, yydepth, yystate, yychar, yys);
842         }
843 #endif
844 #if defined(YYDESTRUCT_CALL)
845 #if YYBTYACC
846         if (!yytrial)
847 #endif /* YYBTYACC */
848 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
849             YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
850 #else
851             YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
852 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
853 #endif /* defined(YYDESTRUCT_CALL) */
854         yychar = YYEMPTY;
855         goto yyloop;
856     }
857 
858 yyreduce:
859     yym = yylen[yyn];
860 #if YYDEBUG
861     if (yydebug)
862     {
863         fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
864                         YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
865 #ifdef YYSTYPE_TOSTRING
866 #if YYBTYACC
867         if (!yytrial)
868 #endif /* YYBTYACC */
869             if (yym > 0)
870             {
871                 int i;
872                 fputc('<', stderr);
873                 for (i = yym; i > 0; i--)
874                 {
875                     if (i != yym) fputs(", ", stderr);
876                     fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
877                                            yystack.l_mark[1-i]), stderr);
878                 }
879                 fputc('>', stderr);
880             }
881 #endif
882         fputc('\n', stderr);
883     }
884 #endif
885     if (yym > 0)
886         yyval = yystack.l_mark[1-yym];
887     else
888         memset(&yyval, 0, sizeof yyval);
889 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
890 
891     /* Perform position reduction */
892     memset(&yyloc, 0, sizeof(yyloc));
893 #if YYBTYACC
894     if (!yytrial)
895 #endif /* YYBTYACC */
896     {
897         YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
898         /* just in case YYERROR is invoked within the action, save
899            the start of the rhs as the error start position */
900         yyerror_loc_range[0] = yystack.p_mark[1-yym];
901     }
902 #endif
903 
904     switch (yyn)
905     {
906     default:
907         break;
908     }
909     yystack.s_mark -= yym;
910     yystate = *yystack.s_mark;
911     yystack.l_mark -= yym;
912 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
913     yystack.p_mark -= yym;
914 #endif
915     yym = yylhs[yyn];
916     if (yystate == 0 && yym == 0)
917     {
918 #if YYDEBUG
919         if (yydebug)
920         {
921             fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
922 #ifdef YYSTYPE_TOSTRING
923 #if YYBTYACC
924             if (!yytrial)
925 #endif /* YYBTYACC */
926                 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
927 #endif
928             fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
929         }
930 #endif
931         yystate = YYFINAL;
932         *++yystack.s_mark = YYFINAL;
933         *++yystack.l_mark = yyval;
934 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
935         *++yystack.p_mark = yyloc;
936 #endif
937         if (yychar < 0)
938         {
939 #if YYBTYACC
940             do {
941             if (yylvp < yylve)
942             {
943                 /* we're currently re-reading tokens */
944                 yylval = *yylvp++;
945 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
946                 yylloc = *yylpp++;
947 #endif
948                 yychar = *yylexp++;
949                 break;
950             }
951             if (yyps->save)
952             {
953                 /* in trial mode; save scanner results for future parse attempts */
954                 if (yylvp == yylvlim)
955                 {   /* Enlarge lexical value queue */
956                     size_t p = (size_t) (yylvp - yylvals);
957                     size_t s = (size_t) (yylvlim - yylvals);
958 
959                     s += YYLVQUEUEGROWTH;
960                     if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
961                         goto yyenomem;
962                     if ((yylvals   = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
963                         goto yyenomem;
964 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
965                     if ((yylpsns   = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
966                         goto yyenomem;
967 #endif
968                     yylvp   = yylve = yylvals + p;
969                     yylvlim = yylvals + s;
970 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
971                     yylpp   = yylpe = yylpsns + p;
972                     yylplim = yylpsns + s;
973 #endif
974                     yylexp  = yylexemes + p;
975                 }
976                 *yylexp = (YYINT) YYLEX;
977                 *yylvp++ = yylval;
978                 yylve++;
979 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
980                 *yylpp++ = yylloc;
981                 yylpe++;
982 #endif
983                 yychar = *yylexp++;
984                 break;
985             }
986             /* normal operation, no conflict encountered */
987 #endif /* YYBTYACC */
988             yychar = YYLEX;
989 #if YYBTYACC
990             } while (0);
991 #endif /* YYBTYACC */
992             if (yychar < 0) yychar = YYEOF;
993 #if YYDEBUG
994             if (yydebug)
995             {
996                 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
997                 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
998                                 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
999             }
1000 #endif
1001         }
1002         if (yychar == YYEOF) goto yyaccept;
1003         goto yyloop;
1004     }
1005     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1006             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1007         yystate = yytable[yyn];
1008     else
1009         yystate = yydgoto[yym];
1010 #if YYDEBUG
1011     if (yydebug)
1012     {
1013         fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1014 #ifdef YYSTYPE_TOSTRING
1015 #if YYBTYACC
1016         if (!yytrial)
1017 #endif /* YYBTYACC */
1018             fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1019 #endif
1020         fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1021     }
1022 #endif
1023     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1024     *++yystack.s_mark = (YYINT) yystate;
1025     *++yystack.l_mark = yyval;
1026 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1027     *++yystack.p_mark = yyloc;
1028 #endif
1029     goto yyloop;
1030 #if YYBTYACC
1031 
1032     /* Reduction declares that this path is valid. Set yypath and do a full parse */
1033 yyvalid:
1034     if (yypath) YYABORT;
1035     while (yyps->save)
1036     {
1037         YYParseState *save = yyps->save;
1038         yyps->save = save->save;
1039         save->save = yypath;
1040         yypath = save;
1041     }
1042 #if YYDEBUG
1043     if (yydebug)
1044         fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1045                         YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1046 #endif
1047     if (yyerrctx)
1048     {
1049         yyFreeState(yyerrctx);
1050         yyerrctx = NULL;
1051     }
1052     yylvp          = yylvals + yypath->lexeme;
1053 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1054     yylpp          = yylpsns + yypath->lexeme;
1055 #endif
1056     yylexp         = yylexemes + yypath->lexeme;
1057     yychar         = YYEMPTY;
1058     yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1059     memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1060     yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1061     memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1062 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1063     yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1064     memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1065 #endif
1066     yystate        = yypath->state;
1067     goto yyloop;
1068 #endif /* YYBTYACC */
1069 
1070 yyoverflow:
1071     YYERROR_CALL("yacc stack overflow");
1072 #if YYBTYACC
1073     goto yyabort_nomem;
1074 yyenomem:
1075     YYERROR_CALL("memory exhausted");
1076 yyabort_nomem:
1077 #endif /* YYBTYACC */
1078     yyresult = 2;
1079     goto yyreturn;
1080 
1081 yyabort:
1082     yyresult = 1;
1083     goto yyreturn;
1084 
1085 yyaccept:
1086 #if YYBTYACC
1087     if (yyps->save) goto yyvalid;
1088 #endif /* YYBTYACC */
1089     yyresult = 0;
1090 
1091 yyreturn:
1092 #if defined(YYDESTRUCT_CALL)
1093     if (yychar != YYEOF && yychar != YYEMPTY)
1094 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1095         YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1096 #else
1097         YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1098 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1099 
1100     {
1101         YYSTYPE *pv;
1102 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1103         YYLTYPE *pp;
1104 
1105         for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1106              YYDESTRUCT_CALL("cleanup: discarding state",
1107                              yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1108 #else
1109         for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1110              YYDESTRUCT_CALL("cleanup: discarding state",
1111                              yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1112 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1113     }
1114 #endif /* defined(YYDESTRUCT_CALL) */
1115 
1116 #if YYBTYACC
1117     if (yyerrctx)
1118     {
1119         yyFreeState(yyerrctx);
1120         yyerrctx = NULL;
1121     }
1122     while (yyps)
1123     {
1124         YYParseState *save = yyps;
1125         yyps = save->save;
1126         save->save = NULL;
1127         yyFreeState(save);
1128     }
1129     while (yypath)
1130     {
1131         YYParseState *save = yypath;
1132         yypath = save->save;
1133         save->save = NULL;
1134         yyFreeState(save);
1135     }
1136 #endif /* YYBTYACC */
1137     yyfreestack(&yystack);
1138     return (yyresult);
1139 }
1140