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