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