]> git.saurik.com Git - bison.git/blob - src/bison.simple
* src/conflicts.c (count_sr_conflicts, count_rr_conflicts): Return
[bison.git] / src / bison.simple
1 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2 #line
3 /* Skeleton output parser for bison,
4 Copyright 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26 /* This is the parser code that is written into each bison parser when
27 the %semantic_parser declaration is not specified in the grammar.
28 It was written by Richard Stallman by simplifying the hairy parser
29 used when %semantic_parser is specified. */
30
31 #ifndef YYSTACK_USE_ALLOCA
32 # ifdef alloca
33 # define YYSTACK_USE_ALLOCA 1
34 # else /* alloca not defined */
35 # ifdef __GNUC__
36 # define YYSTACK_USE_ALLOCA 1
37 # define alloca __builtin_alloca
38 # else /* not GNU C. */
39 # if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
40 # define YYSTACK_USE_ALLOCA 1
41 # include <alloca.h>
42 # else /* not sparc */
43 /* We think this test detects Watcom and Microsoft C. */
44 /* This used to test MSDOS, but that is a bad idea since that
45 symbol is in the user namespace. */
46 # if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
47 # if 0
48 /* No need for malloc.h, which pollutes the namespace; instead,
49 just don't use alloca. */
50 # include <malloc.h>
51 # endif
52 # else /* not MSDOS, or __TURBOC__ */
53 # if defined(_AIX)
54 /* I don't know what this was needed for, but it pollutes the
55 namespace. So I turned it off. rms, 2 May 1997. */
56 /* #include <malloc.h> */
57 #pragma alloca
58 # define YYSTACK_USE_ALLOCA 1
59 # else /* not MSDOS, or __TURBOC__, or _AIX */
60 # if 0
61 /* haible@ilog.fr says this works for HPUX 9.05 and up, and on
62 HPUX 10. Eventually we can turn this on. */
63 # ifdef __hpux
64 # define YYSTACK_USE_ALLOCA 1
65 # define alloca __builtin_alloca
66 # endif /* __hpux */
67 # endif
68 # endif /* not _AIX */
69 # endif /* not MSDOS, or __TURBOC__ */
70 # endif /* not sparc */
71 # endif /* not GNU C */
72 # endif /* alloca not defined */
73 #endif /* YYSTACK_USE_ALLOCA not defined */
74
75 #ifndef YYSTACK_USE_ALLOCA
76 # define YYSTACK_USE_ALLOCA 0
77 #endif
78
79 /* Realloc WHAT from SIZE to YYSTACKSIZE elements of TYPE.
80 If WHAT was malloc'ed (not the original automatic ARRAY), free it. */
81 #if YYSTACK_USE_ALLOCA
82 # define YYSTACK_REALLOC(Type, What, Array) \
83 do { \
84 Type *old = What; \
85 What = (Type *) malloc (yystacksize * sizeof (Type)); \
86 __yy_memcpy ((char *) What, (char *) old, \
87 (size) * (unsigned int) sizeof (Type)); \
88 yyfree_stacks = 1; \
89 if (old != Array) \
90 free (old); \
91 } while (0)
92 #else
93 # define YYSTACK_REALLOC(Type, What, Array) \
94 do { \
95 Type *old = What; \
96 What = (Type *) alloca (yystacksize * sizeof (Type)); \
97 __yy_memcpy ((char *) What, (char *) old, \
98 (size) * (unsigned int) sizeof (Type)); \
99 } while (0)
100 #endif
101
102 #define yyerrok (yyerrstatus = 0)
103 #define yyclearin (yychar = YYEMPTY)
104 #define YYEMPTY -2
105 #define YYEOF 0
106 #define YYACCEPT goto yyacceptlab
107 #define YYABORT goto yyabortlab
108 #define YYERROR goto yyerrlab1
109 /* Like YYERROR except do call yyerror. This remains here temporarily
110 to ease the transition to the new meaning of YYERROR, for GCC.
111 Once GCC version 2 has supplanted version 1, this can go. */
112 #define YYFAIL goto yyerrlab
113 #define YYRECOVERING() (!!yyerrstatus)
114 #define YYBACKUP(Token, Value) \
115 do \
116 if (yychar == YYEMPTY && yylen == 1) \
117 { \
118 yychar = (Token); \
119 yylval = (Value); \
120 yychar1 = YYTRANSLATE (yychar); \
121 YYPOPSTACK; \
122 goto yybackup; \
123 } \
124 else \
125 { \
126 yyerror ("syntax error: cannot back up"); \
127 YYERROR; \
128 } \
129 while (0)
130
131 #define YYTERROR 1
132 #define YYERRCODE 256
133
134
135 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
136 are run).
137
138 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
139 first token. By default, to implement support for ranges, extend
140 its range to the last symbol. */
141
142 #ifndef YYLLOC_DEFAULT
143 # define YYLLOC_DEFAULT(Current, Rhs, N) \
144 Current.last_line = Rhs[N].last_line; \
145 Current.last_column = Rhs[N].last_column;
146 #endif
147
148
149 /* YYLEX -- calling `yylex' with the right arguments. */
150
151 #if YYPURE
152 # if YYLSP_NEEDED
153 # ifdef YYLEX_PARAM
154 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
155 # else
156 # define YYLEX yylex (&yylval, &yylloc)
157 # endif
158 # else /* !YYLSP_NEEDED */
159 # ifdef YYLEX_PARAM
160 # define YYLEX yylex (&yylval, YYLEX_PARAM)
161 # else
162 # define YYLEX yylex (&yylval)
163 # endif
164 # endif /* !YYLSP_NEEDED */
165 #else /* !YYPURE */
166 # define YYLEX yylex ()
167 #endif /* !YYPURE */
168
169
170 /* Enable debugging if requested. */
171 #if YYDEBUG
172 # define YYDPRINTF(Args) \
173 do { \
174 if (yydebug) \
175 fprintf Args; \
176 } while (0)
177 /* Nonzero means print parse trace. [The following comment makes no
178 sense to me. Could someone clarify it? --akim] Since this is
179 uninitialized, it does not stop multiple parsers from coexisting.
180 */
181 int yydebug;
182 #else /* !YYDEBUG */
183 # define YYDPRINTF(Args)
184 #endif /* !YYDEBUG */
185
186 /* YYINITDEPTH -- initial size of the parser's stacks. */
187 #ifndef YYINITDEPTH
188 # define YYINITDEPTH 200
189 #endif
190
191 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
192 if the built-in stack extension method is used). */
193 #if YYMAXDEPTH == 0
194 # undef YYMAXDEPTH
195 #endif
196
197 #ifndef YYMAXDEPTH
198 # define YYMAXDEPTH 10000
199 #endif
200 \f
201 /* Define __yy_memcpy. Note that the size argument
202 should be passed with type unsigned int, because that is what the non-GCC
203 definitions require. With GCC, __builtin_memcpy takes an arg
204 of type size_t, but it can handle unsigned int. */
205
206 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
207 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
208 #else /* not GNU C or C++ */
209
210 /* This is the most reliable way to avoid incompatibilities
211 in available built-in functions on various systems. */
212 static void
213 # ifndef __cplusplus
214 __yy_memcpy (to, from, count)
215 char *to;
216 const char *from;
217 unsigned int count;
218 # else /* __cplusplus */
219 __yy_memcpy (char *to, const char *from, unsigned int count)
220 # endif
221 {
222 register const char *f = from;
223 register char *t = to;
224 register int i = count;
225
226 while (i-- > 0)
227 *t++ = *f++;
228 }
229
230 #endif
231 \f
232 #line
233
234 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
235 into yyparse. The argument should have type void *.
236 It should actually point to an object.
237 Grammar actions can access the variable by casting it
238 to the proper pointer type. */
239
240 #ifdef YYPARSE_PARAM
241 # ifdef __cplusplus
242 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
243 # define YYPARSE_PARAM_DECL
244 # else /* !__cplusplus */
245 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
246 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
247 # endif /* !__cplusplus */
248 #else /* !YYPARSE_PARAM */
249 # define YYPARSE_PARAM_ARG
250 # define YYPARSE_PARAM_DECL
251 #endif /* !YYPARSE_PARAM */
252
253 /* Prevent warning if -Wstrict-prototypes. */
254 #ifdef __GNUC__
255 # ifdef YYPARSE_PARAM
256 int yyparse (void *);
257 # else
258 int yyparse (void);
259 # endif
260 #endif
261
262 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
263 variables are global, or local to YYPARSE. */
264
265 #define _YY_DECL_VARIABLES \
266 /* The lookahead symbol. */ \
267 int yychar; \
268 \
269 /* The semantic value of the lookahead symbol. */ \
270 YYSTYPE yylval; \
271 \
272 /* Number of parse errors so far. */ \
273 int yynerrs;
274
275 #if YYLSP_NEEDED
276 # define YY_DECL_VARIABLES \
277 _YY_DECL_VARIABLES \
278 \
279 /* Location data for the lookahead symbol. */ \
280 YYLTYPE yylloc;
281 #else
282 # define YY_DECL_VARIABLES \
283 _YY_DECL_VARIABLES
284 #endif
285
286
287 /* If nonreentrant, generate the variables here. */
288
289 #if !YYPURE
290 YY_DECL_VARIABLES
291 #endif /* !YYPURE */
292
293 int
294 yyparse (YYPARSE_PARAM_ARG)
295 YYPARSE_PARAM_DECL
296 {
297 /* If reentrant, generate the variables here. */
298 #if YYPURE
299 YY_DECL_VARIABLES
300 #endif /* !YYPURE */
301
302 register int yystate;
303 register int yyn;
304 /* Number of tokens to shift before error messages enabled. */
305 int yyerrstatus;
306 /* Lookahead token as an internal (translated) token number. */
307 int yychar1 = 0;
308
309 /* Three stacks and their tools:
310 `yyss': related to states,
311 `yyvs': related to semantic values,
312 `yyls': related to locations.
313
314 Refer to the stacks thru separate pointers, to allow yyoverflow
315 to reallocate them elsewhere. */
316
317 /* The state stack. */
318 short yyssa[YYINITDEPTH];
319 short *yyss = yyssa;
320 register short *yyssp;
321
322 /* The semantic value stack. */
323 YYSTYPE yyvsa[YYINITDEPTH];
324 YYSTYPE *yyvs = yyvsa;
325 register YYSTYPE *yyvsp;
326
327 #if YYLSP_NEEDED
328 /* The location stack. */
329 YYLTYPE yylsa[YYINITDEPTH];
330 YYLTYPE *yyls = yylsa;
331 YYLTYPE *yylsp;
332 #endif
333
334 #if YYLSP_NEEDED
335 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
336 #else
337 # define YYPOPSTACK (yyvsp--, yyssp--)
338 #endif
339
340 int yystacksize = YYINITDEPTH;
341 int yyfree_stacks = 0;
342
343
344 /* The variables used to return semantic value and location from the
345 action routines. */
346 YYSTYPE yyval;
347 # if YYLSP_NEEDED
348 YYLTYPE yyloc;
349 # endif
350
351 /* When reducing, the number of symbols on the RHS of the reduced
352 rule. */
353 int yylen;
354
355 YYDPRINTF ((stderr, "Starting parse\n"));
356
357 yystate = 0;
358 yyerrstatus = 0;
359 yynerrs = 0;
360 yychar = YYEMPTY; /* Cause a token to be read. */
361
362 /* Initialize stack pointers.
363 Waste one element of value and location stack
364 so that they stay on the same level as the state stack.
365 The wasted elements are never initialized. */
366
367 yyssp = yyss;
368 yyvsp = yyvs;
369 #if YYLSP_NEEDED
370 yylsp = yyls;
371 #endif
372 goto yysetstate;
373
374 /*------------------------------------------------------------.
375 | yynewstate -- Push a new state, which is found in yystate. |
376 `------------------------------------------------------------*/
377 yynewstate:
378 /* In all cases, when you get here, the value and location stacks
379 have just been pushed. so pushing a state here evens the stacks.
380 */
381 yyssp++;
382
383 yysetstate:
384 *yyssp = yystate;
385
386 if (yyssp >= yyss + yystacksize - 1)
387 {
388 /* Give user a chance to reallocate the stack. Use copies of
389 these so that the &'s don't force the real ones into memory.
390 */
391 YYSTYPE *yyvs1 = yyvs;
392 short *yyss1 = yyss;
393 #if YYLSP_NEEDED
394 YYLTYPE *yyls1 = yyls;
395 #endif
396
397 /* Get the current used size of the three stacks, in elements. */
398 int size = yyssp - yyss + 1;
399
400 #ifdef yyoverflow
401 /* Each stack pointer address is followed by the size of the
402 data in use in that stack, in bytes. */
403 # if YYLSP_NEEDED
404 /* This used to be a conditional around just the two extra args,
405 but that might be undefined if yyoverflow is a macro. */
406 yyoverflow ("parser stack overflow",
407 &yyss1, size * sizeof (*yyssp),
408 &yyvs1, size * sizeof (*yyvsp),
409 &yyls1, size * sizeof (*yylsp),
410 &yystacksize);
411 # else
412 yyoverflow ("parser stack overflow",
413 &yyss1, size * sizeof (*yyssp),
414 &yyvs1, size * sizeof (*yyvsp),
415 &yystacksize);
416 # endif
417
418 yyss = yyss1; yyvs = yyvs1;
419 # if YYLSP_NEEDED
420 yyls = yyls1;
421 # endif
422 #else /* no yyoverflow */
423 /* Extend the stack our own way. */
424 if (yystacksize >= YYMAXDEPTH)
425 {
426 yyerror ("parser stack overflow");
427 if (yyfree_stacks)
428 {
429 free (yyss);
430 free (yyvs);
431 # if YYLSP_NEEDED
432 free (yyls);
433 # endif
434 }
435 return 2;
436 }
437 yystacksize *= 2;
438 if (yystacksize > YYMAXDEPTH)
439 yystacksize = YYMAXDEPTH;
440
441 YYSTACK_REALLOC (short, yyss, yyssa);
442 YYSTACK_REALLOC (YYSTYPE, yyvs, yyvsa);
443 # if YYLSP_NEEDED
444 YYSTACK_REALLOC (YYLTYPE, yyls, yylsa);
445 # endif
446 #endif /* no yyoverflow */
447
448 yyssp = yyss + size - 1;
449 yyvsp = yyvs + size - 1;
450 #if YYLSP_NEEDED
451 yylsp = yyls + size - 1;
452 #endif
453
454 YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
455
456 if (yyssp >= yyss + yystacksize - 1)
457 YYABORT;
458 }
459
460 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
461
462 goto yybackup;
463
464
465 /*-----------.
466 | yybackup. |
467 `-----------*/
468 yybackup:
469
470 /* Do appropriate processing given the current state. */
471 /* Read a lookahead token if we need one and don't already have one. */
472 /* yyresume: */
473
474 /* First try to decide what to do without reference to lookahead token. */
475
476 yyn = yypact[yystate];
477 if (yyn == YYFLAG)
478 goto yydefault;
479
480 /* Not known => get a lookahead token if don't already have one. */
481
482 /* yychar is either YYEMPTY or YYEOF
483 or a valid token in external form. */
484
485 if (yychar == YYEMPTY)
486 {
487 YYDPRINTF ((stderr, "Reading a token: "));
488 yychar = YYLEX;
489 }
490
491 /* Convert token to internal form (in yychar1) for indexing tables with */
492
493 if (yychar <= 0) /* This means end of input. */
494 {
495 yychar1 = 0;
496 yychar = YYEOF; /* Don't call YYLEX any more */
497
498 YYDPRINTF ((stderr, "Now at end of input.\n"));
499 }
500 else
501 {
502 yychar1 = YYTRANSLATE (yychar);
503
504 #if YYDEBUG
505 /* We have to keep this `#if YYDEBUG', since we use variables
506 which are defined only if `YYDEBUG' is set. */
507 if (yydebug)
508 {
509 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
510 /* Give the individual parser a way to print the precise
511 meaning of a token, for further debugging info. */
512 # ifdef YYPRINT
513 YYPRINT (stderr, yychar, yylval);
514 # endif
515 fprintf (stderr, ")\n");
516 }
517 #endif
518 }
519
520 yyn += yychar1;
521 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
522 goto yydefault;
523
524 yyn = yytable[yyn];
525
526 /* yyn is what to do for this token type in this state.
527 Negative => reduce, -yyn is rule number.
528 Positive => shift, yyn is new state.
529 New state is final state => don't bother to shift,
530 just return success.
531 0, or most negative number => error. */
532
533 if (yyn < 0)
534 {
535 if (yyn == YYFLAG)
536 goto yyerrlab;
537 yyn = -yyn;
538 goto yyreduce;
539 }
540 else if (yyn == 0)
541 goto yyerrlab;
542
543 if (yyn == YYFINAL)
544 YYACCEPT;
545
546 /* Shift the lookahead token. */
547 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
548
549 /* Discard the token being shifted unless it is eof. */
550 if (yychar != YYEOF)
551 yychar = YYEMPTY;
552
553 *++yyvsp = yylval;
554 #if YYLSP_NEEDED
555 *++yylsp = yylloc;
556 #endif
557
558 /* Count tokens shifted since error; after three, turn off error
559 status. */
560 if (yyerrstatus)
561 yyerrstatus--;
562
563 yystate = yyn;
564 goto yynewstate;
565
566
567 /*-----------------------------------------------------------.
568 | yydefault -- do the default action for the current state. |
569 `-----------------------------------------------------------*/
570 yydefault:
571 yyn = yydefact[yystate];
572 if (yyn == 0)
573 goto yyerrlab;
574 goto yyreduce;
575
576
577 /*-----------------------------.
578 | yyreduce -- Do a reduction. |
579 `-----------------------------*/
580 yyreduce:
581 /* yyn is the number of a rule to reduce with. */
582 yylen = yyr2[yyn];
583
584 /* If YYLEN is nonzero, implement the default value of the action:
585 `$$ = $1'.
586
587 Otherwise, the following line sets YYVAL to the semantic value of
588 the lookahead token. This behavior is undocumented and Bison
589 users should not rely upon it. Assigning to YYVAL
590 unconditionally makes the parser a bit smaller, and it avoids a
591 GCC warning that YYVAL may be used uninitialized. */
592 yyval = yyvsp[1-yylen];
593
594 #if YYLSP_NEEDED
595 /* Similarly for the default location. Let the user run additional
596 commands if for instance locations are ranges. */
597 yyloc = yylsp[1-yylen];
598 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
599 #endif
600
601 #if YYDEBUG
602 /* We have to keep this `#if YYDEBUG', since we use variables which
603 are defined only if `YYDEBUG' is set. */
604 if (yydebug)
605 {
606 int i;
607
608 fprintf (stderr, "Reducing via rule %d (line %d), ",
609 yyn, yyrline[yyn]);
610
611 /* Print the symbols being reduced, and their result. */
612 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
613 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
614 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
615 }
616 #endif
617 %% actions /* The action file replaces this line. */
618 #line
619 \f
620 yyvsp -= yylen;
621 yyssp -= yylen;
622 #if YYLSP_NEEDED
623 yylsp -= yylen;
624 #endif
625
626 #if YYDEBUG
627 if (yydebug)
628 {
629 short *ssp1 = yyss - 1;
630 fprintf (stderr, "state stack now");
631 while (ssp1 != yyssp)
632 fprintf (stderr, " %d", *++ssp1);
633 fprintf (stderr, "\n");
634 }
635 #endif
636
637 *++yyvsp = yyval;
638 #if YYLSP_NEEDED
639 *++yylsp = yyloc;
640 #endif
641
642 /* Now `shift' the result of the reduction. Determine what state
643 that goes to, based on the state we popped back to and the rule
644 number reduced by. */
645
646 yyn = yyr1[yyn];
647
648 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
649 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
650 yystate = yytable[yystate];
651 else
652 yystate = yydefgoto[yyn - YYNTBASE];
653
654 goto yynewstate;
655
656
657 /*------------------------------------.
658 | yyerrlab -- here on detecting error |
659 `------------------------------------*/
660 yyerrlab:
661 /* If not already recovering from an error, report this error. */
662 if (!yyerrstatus)
663 {
664 ++yynerrs;
665
666 #ifdef YYERROR_VERBOSE
667 yyn = yypact[yystate];
668
669 if (yyn > YYFLAG && yyn < YYLAST)
670 {
671 int size = 0;
672 char *msg;
673 int x, count;
674
675 count = 0;
676 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
677 for (x = (yyn < 0 ? -yyn : 0);
678 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
679 if (yycheck[x + yyn] == x)
680 size += strlen (yytname[x]) + 15, count++;
681 size += strlen ("parse error, unexpected `") + 1;
682 size += strlen (yytname[YYTRANSLATE (yychar)]);
683 msg = (char *) malloc (size);
684 if (msg != 0)
685 {
686 strcpy (msg, "parse error, unexpected `");
687 strcat (msg, yytname[YYTRANSLATE (yychar)]);
688 strcat (msg, "'");
689
690 if (count < 5)
691 {
692 count = 0;
693 for (x = (yyn < 0 ? -yyn : 0);
694 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
695 if (yycheck[x + yyn] == x)
696 {
697 strcat (msg, count == 0 ? ", expecting `" : " or `");
698 strcat (msg, yytname[x]);
699 strcat (msg, "'");
700 count++;
701 }
702 }
703 yyerror (msg);
704 free (msg);
705 }
706 else
707 yyerror ("parse error; also virtual memory exceeded");
708 }
709 else
710 #endif /* YYERROR_VERBOSE */
711 yyerror ("parse error");
712 }
713 goto yyerrlab1;
714
715
716 /*--------------------------------------------------.
717 | yyerrlab1 -- error raised explicitly by an action |
718 `--------------------------------------------------*/
719 yyerrlab1:
720 if (yyerrstatus == 3)
721 {
722 /* If just tried and failed to reuse lookahead token after an
723 error, discard it. */
724
725 /* return failure if at end of input */
726 if (yychar == YYEOF)
727 YYABORT;
728 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
729 yychar, yytname[yychar1]));
730 yychar = YYEMPTY;
731 }
732
733 /* Else will try to reuse lookahead token after shifting the error
734 token. */
735
736 yyerrstatus = 3; /* Each real token shifted decrements this */
737
738 goto yyerrhandle;
739
740
741 /*-------------------------------------------------------------------.
742 | yyerrdefault -- current state does not do anything special for the |
743 | error token. |
744 `-------------------------------------------------------------------*/
745 yyerrdefault:
746 #if 0
747 /* This is wrong; only states that explicitly want error tokens
748 should shift them. */
749
750 /* If its default is to accept any token, ok. Otherwise pop it. */
751 yyn = yydefact[yystate];
752 if (yyn)
753 goto yydefault;
754 #endif
755
756
757 /*---------------------------------------------------------------.
758 | yyerrpop -- pop the current state because it cannot handle the |
759 | error token |
760 `---------------------------------------------------------------*/
761 yyerrpop:
762 if (yyssp == yyss)
763 YYABORT;
764 yyvsp--;
765 yystate = *--yyssp;
766 #if YYLSP_NEEDED
767 yylsp--;
768 #endif
769
770 #if YYDEBUG
771 if (yydebug)
772 {
773 short *ssp1 = yyss - 1;
774 fprintf (stderr, "Error: state stack now");
775 while (ssp1 != yyssp)
776 fprintf (stderr, " %d", *++ssp1);
777 fprintf (stderr, "\n");
778 }
779 #endif
780
781 /*--------------.
782 | yyerrhandle. |
783 `--------------*/
784 yyerrhandle:
785 yyn = yypact[yystate];
786 if (yyn == YYFLAG)
787 goto yyerrdefault;
788
789 yyn += YYTERROR;
790 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
791 goto yyerrdefault;
792
793 yyn = yytable[yyn];
794 if (yyn < 0)
795 {
796 if (yyn == YYFLAG)
797 goto yyerrpop;
798 yyn = -yyn;
799 goto yyreduce;
800 }
801 else if (yyn == 0)
802 goto yyerrpop;
803
804 if (yyn == YYFINAL)
805 YYACCEPT;
806
807 YYDPRINTF ((stderr, "Shifting error token, "));
808
809 *++yyvsp = yylval;
810 #if YYLSP_NEEDED
811 *++yylsp = yylloc;
812 #endif
813
814 yystate = yyn;
815 goto yynewstate;
816
817
818 /*-------------------------------------.
819 | yyacceptlab -- YYACCEPT comes here. |
820 `-------------------------------------*/
821 yyacceptlab:
822 if (yyfree_stacks)
823 {
824 free (yyss);
825 free (yyvs);
826 #if YYLSP_NEEDED
827 free (yyls);
828 #endif
829 }
830 return 0;
831
832
833 /*-----------------------------------.
834 | yyabortlab -- YYABORT comes here. |
835 `-----------------------------------*/
836 yyabortlab:
837 if (yyfree_stacks)
838 {
839 free (yyss);
840 free (yyvs);
841 #if YYLSP_NEEDED
842 free (yyls);
843 #endif
844 }
845 return 1;
846 }