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