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