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