]> git.saurik.com Git - bison.git/blob - src/bison.simple
3b11285b4e90e28efe8e10a19a9255ceaf33a495
[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
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
6 Foundation, Inc.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
22
23 /* As a special exception, when this file is copied by Bison into a
24 Bison output file, you may use that output file without restriction.
25 This special exception was added by the Free Software Foundation
26 in version 1.24 of Bison. */
27
28 /* This is the parser code that is written into each bison parser when
29 the %semantic_parser declaration is not specified in the grammar.
30 It was written by Richard Stallman by simplifying the hairy parser
31 used when %semantic_parser is specified. */
32
33 /* All symbols defined below should begin with yy or YY, to avoid
34 infringing on user name space. This should be done even for local
35 variables, as they might otherwise be expanded by user macros.
36 There are some unavoidable exceptions within include files to
37 define necessary library symbols; they are noted "INFRINGES ON
38 USER NAME SPACE" below. */
39
40 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
41
42 /* The parser invokes alloca or malloc; define the necessary symbols. */
43
44 # if YYSTACK_USE_ALLOCA
45 # define YYSTACK_ALLOC alloca
46 # else
47 # ifndef YYSTACK_USE_ALLOCA
48 # if defined (alloca) || defined (_ALLOCA_H)
49 # define YYSTACK_ALLOC alloca
50 # else
51 # ifdef __GNUC__
52 # define YYSTACK_ALLOC __builtin_alloca
53 # endif
54 # endif
55 # endif
56 # endif
57
58 # ifdef YYSTACK_ALLOC
59 /* Pacify GCC's `empty if-body' warning. */
60 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
61 # else
62 # if defined (__STDC__) || defined (__cplusplus)
63 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
64 # define YYSIZE_T size_t
65 # endif
66 # define YYSTACK_ALLOC malloc
67 # define YYSTACK_FREE free
68 # endif
69 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
70
71
72 #if (! defined (yyoverflow) \
73 && (! defined (__cplusplus) \
74 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
75
76 /* A type that is properly aligned for any stack member. */
77 union yyalloc
78 {
79 short yyss;
80 YYSTYPE yyvs;
81 # if YYLSP_NEEDED
82 YYLTYPE yyls;
83 # endif
84 };
85
86 /* The size of the maximum gap between one aligned stack and the next. */
87 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
88
89 /* The size of an array large to enough to hold all stacks, each with
90 N elements. */
91 # if YYLSP_NEEDED
92 # define YYSTACK_BYTES(N) \
93 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
94 + 2 * YYSTACK_GAP_MAX)
95 # else
96 # define YYSTACK_BYTES(N) \
97 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
98 + YYSTACK_GAP_MAX)
99 # endif
100
101 /* Relocate the TYPE STACK from its old location to the new one. The
102 local variables YYSIZE and YYSTACKSIZE give the old and new number of
103 elements in the stack, and YYPTR gives the new location of the
104 stack. Advance YYPTR to a properly aligned location for the next
105 stack. */
106 # define YYSTACK_RELOCATE(Type, Stack) \
107 do \
108 { \
109 YYSIZE_T yynewbytes; \
110 yymemcpy ((char *) yyptr, (char *) (Stack), \
111 yysize * (YYSIZE_T) sizeof (Type)); \
112 Stack = &yyptr->Stack; \
113 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
114 yyptr += yynewbytes / sizeof (*yyptr); \
115 } \
116 while (0)
117
118 #endif
119
120
121 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
122 # define YYSIZE_T __SIZE_TYPE__
123 #endif
124 #if ! defined (YYSIZE_T) && defined (size_t)
125 # define YYSIZE_T size_t
126 #endif
127 #if ! defined (YYSIZE_T)
128 # if defined (__STDC__) || defined (__cplusplus)
129 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
130 # define YYSIZE_T size_t
131 # endif
132 #endif
133 #if ! defined (YYSIZE_T)
134 # define YYSIZE_T unsigned int
135 #endif
136
137 #define yyerrok (yyerrstatus = 0)
138 #define yyclearin (yychar = YYEMPTY)
139 #define YYEMPTY -2
140 #define YYEOF 0
141 #define YYACCEPT goto yyacceptlab
142 #define YYABORT goto yyabortlab
143 #define YYERROR goto yyerrlab1
144 /* Like YYERROR except do call yyerror. This remains here temporarily
145 to ease the transition to the new meaning of YYERROR, for GCC.
146 Once GCC version 2 has supplanted version 1, this can go. */
147 #define YYFAIL goto yyerrlab
148 #define YYRECOVERING() (!!yyerrstatus)
149 #define YYBACKUP(Token, Value) \
150 do \
151 if (yychar == YYEMPTY && yylen == 1) \
152 { \
153 yychar = (Token); \
154 yylval = (Value); \
155 yychar1 = YYTRANSLATE (yychar); \
156 YYPOPSTACK; \
157 goto yybackup; \
158 } \
159 else \
160 { \
161 yyerror ("syntax error: cannot back up"); \
162 YYERROR; \
163 } \
164 while (0)
165
166 #define YYTERROR 1
167 #define YYERRCODE 256
168
169
170 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
171 are run).
172
173 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
174 first token. By default, to implement support for ranges, extend
175 its range to the last symbol. */
176
177 #ifndef YYLLOC_DEFAULT
178 # define YYLLOC_DEFAULT(Current, Rhs, N) \
179 Current.last_line = Rhs[N].last_line; \
180 Current.last_column = Rhs[N].last_column;
181 #endif
182
183
184 /* YYLEX -- calling `yylex' with the right arguments. */
185
186 #if YYPURE
187 # if YYLSP_NEEDED
188 # ifdef YYLEX_PARAM
189 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
190 # else
191 # define YYLEX yylex (&yylval, &yylloc)
192 # endif
193 # else /* !YYLSP_NEEDED */
194 # ifdef YYLEX_PARAM
195 # define YYLEX yylex (&yylval, YYLEX_PARAM)
196 # else
197 # define YYLEX yylex (&yylval)
198 # endif
199 # endif /* !YYLSP_NEEDED */
200 #else /* !YYPURE */
201 # define YYLEX yylex ()
202 #endif /* !YYPURE */
203
204
205 /* Enable debugging if requested. */
206 #if YYDEBUG
207
208 # ifndef YYFPRINTF
209 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
210 # define YYFPRINTF fprintf
211 # endif
212
213 # define YYDPRINTF(Args) \
214 do { \
215 if (yydebug) \
216 YYFPRINTF Args; \
217 } while (0)
218 /* Nonzero means print parse trace. It is left uninitialized so that
219 multiple parsers can coexist. */
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 (YYSTACK_RELOCATE) && ! 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 # if defined (__STDC__) || defined (__cplusplus)
305 yystpcpy (char *yydest, const char *yysrc)
306 # else
307 yystpcpy (yydest, yysrc)
308 char *yydest;
309 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 # if defined (__STDC__) || defined (__cplusplus)
334 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
335 # define YYPARSE_PARAM_DECL
336 # else
337 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
338 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
339 # endif
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 # ifndef YYSTACK_RELOCATE
514 goto yyoverflowlab;
515 # else
516 /* Extend the stack our own way. */
517 if (yystacksize >= YYMAXDEPTH)
518 goto yyoverflowlab;
519 yystacksize *= 2;
520 if (yystacksize > YYMAXDEPTH)
521 yystacksize = YYMAXDEPTH;
522
523 {
524 short *yyss1 = yyss;
525 union yyalloc *yyptr =
526 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
527 if (! yyptr)
528 goto yyoverflowlab;
529 YYSTACK_RELOCATE (short, yyss);
530 YYSTACK_RELOCATE (YYSTYPE, yyvs);
531 # if YYLSP_NEEDED
532 YYSTACK_RELOCATE (YYLTYPE, yyls);
533 # endif
534 # undef YYSTACK_RELOCATE
535 if (yyss1 != yyssa)
536 YYSTACK_FREE (yyss1);
537 }
538 # endif
539 #endif /* no yyoverflow */
540
541 yyssp = yyss + yysize - 1;
542 yyvsp = yyvs + yysize - 1;
543 #if YYLSP_NEEDED
544 yylsp = yyls + yysize - 1;
545 #endif
546
547 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
548 (unsigned long int) yystacksize));
549
550 if (yyssp >= yyss + yystacksize - 1)
551 YYABORT;
552 }
553
554 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
555
556 goto yybackup;
557
558
559 /*-----------.
560 | yybackup. |
561 `-----------*/
562 yybackup:
563
564 /* Do appropriate processing given the current state. */
565 /* Read a lookahead token if we need one and don't already have one. */
566 /* yyresume: */
567
568 /* First try to decide what to do without reference to lookahead token. */
569
570 yyn = yypact[yystate];
571 if (yyn == YYFLAG)
572 goto yydefault;
573
574 /* Not known => get a lookahead token if don't already have one. */
575
576 /* yychar is either YYEMPTY or YYEOF
577 or a valid token in external form. */
578
579 if (yychar == YYEMPTY)
580 {
581 YYDPRINTF ((stderr, "Reading a token: "));
582 yychar = YYLEX;
583 }
584
585 /* Convert token to internal form (in yychar1) for indexing tables with */
586
587 if (yychar <= 0) /* This means end of input. */
588 {
589 yychar1 = 0;
590 yychar = YYEOF; /* Don't call YYLEX any more */
591
592 YYDPRINTF ((stderr, "Now at end of input.\n"));
593 }
594 else
595 {
596 yychar1 = YYTRANSLATE (yychar);
597
598 #if YYDEBUG
599 /* We have to keep this `#if YYDEBUG', since we use variables
600 which are defined only if `YYDEBUG' is set. */
601 if (yydebug)
602 {
603 YYFPRINTF (stderr, "Next token is %d (%s",
604 yychar, yytname[yychar1]);
605 /* Give the individual parser a way to print the precise
606 meaning of a token, for further debugging info. */
607 # ifdef YYPRINT
608 YYPRINT (stderr, yychar, yylval);
609 # endif
610 YYFPRINTF (stderr, ")\n");
611 }
612 #endif
613 }
614
615 yyn += yychar1;
616 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
617 goto yydefault;
618
619 yyn = yytable[yyn];
620
621 /* yyn is what to do for this token type in this state.
622 Negative => reduce, -yyn is rule number.
623 Positive => shift, yyn is new state.
624 New state is final state => don't bother to shift,
625 just return success.
626 0, or most negative number => error. */
627
628 if (yyn < 0)
629 {
630 if (yyn == YYFLAG)
631 goto yyerrlab;
632 yyn = -yyn;
633 goto yyreduce;
634 }
635 else if (yyn == 0)
636 goto yyerrlab;
637
638 if (yyn == YYFINAL)
639 YYACCEPT;
640
641 /* Shift the lookahead token. */
642 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
643 yychar, yytname[yychar1]));
644
645 /* Discard the token being shifted unless it is eof. */
646 if (yychar != YYEOF)
647 yychar = YYEMPTY;
648
649 *++yyvsp = yylval;
650 #if YYLSP_NEEDED
651 *++yylsp = yylloc;
652 #endif
653
654 /* Count tokens shifted since error; after three, turn off error
655 status. */
656 if (yyerrstatus)
657 yyerrstatus--;
658
659 yystate = yyn;
660 goto yynewstate;
661
662
663 /*-----------------------------------------------------------.
664 | yydefault -- do the default action for the current state. |
665 `-----------------------------------------------------------*/
666 yydefault:
667 yyn = yydefact[yystate];
668 if (yyn == 0)
669 goto yyerrlab;
670 goto yyreduce;
671
672
673 /*-----------------------------.
674 | yyreduce -- Do a reduction. |
675 `-----------------------------*/
676 yyreduce:
677 /* yyn is the number of a rule to reduce with. */
678 yylen = yyr2[yyn];
679
680 /* If YYLEN is nonzero, implement the default value of the action:
681 `$$ = $1'.
682
683 Otherwise, the following line sets YYVAL to the semantic value of
684 the lookahead token. This behavior is undocumented and Bison
685 users should not rely upon it. Assigning to YYVAL
686 unconditionally makes the parser a bit smaller, and it avoids a
687 GCC warning that YYVAL may be used uninitialized. */
688 yyval = yyvsp[1-yylen];
689
690 #if YYLSP_NEEDED
691 /* Similarly for the default location. Let the user run additional
692 commands if for instance locations are ranges. */
693 yyloc = yylsp[1-yylen];
694 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
695 #endif
696
697 #if YYDEBUG
698 /* We have to keep this `#if YYDEBUG', since we use variables which
699 are defined only if `YYDEBUG' is set. */
700 if (yydebug)
701 {
702 int yyi;
703
704 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
705 yyn, yyrline[yyn]);
706
707 /* Print the symbols being reduced, and their result. */
708 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
709 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
710 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
711 }
712 #endif
713 %% actions /* The action file replaces this line. */
714 #line
715 \f
716 yyvsp -= yylen;
717 yyssp -= yylen;
718 #if YYLSP_NEEDED
719 yylsp -= yylen;
720 #endif
721
722 #if YYDEBUG
723 if (yydebug)
724 {
725 short *yyssp1 = yyss - 1;
726 YYFPRINTF (stderr, "state stack now");
727 while (yyssp1 != yyssp)
728 YYFPRINTF (stderr, " %d", *++yyssp1);
729 YYFPRINTF (stderr, "\n");
730 }
731 #endif
732
733 *++yyvsp = yyval;
734 #if YYLSP_NEEDED
735 *++yylsp = yyloc;
736 #endif
737
738 /* Now `shift' the result of the reduction. Determine what state
739 that goes to, based on the state we popped back to and the rule
740 number reduced by. */
741
742 yyn = yyr1[yyn];
743
744 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
745 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
746 yystate = yytable[yystate];
747 else
748 yystate = yydefgoto[yyn - YYNTBASE];
749
750 goto yynewstate;
751
752
753 /*------------------------------------.
754 | yyerrlab -- here on detecting error |
755 `------------------------------------*/
756 yyerrlab:
757 /* If not already recovering from an error, report this error. */
758 if (!yyerrstatus)
759 {
760 ++yynerrs;
761
762 #ifdef YYERROR_VERBOSE
763 yyn = yypact[yystate];
764
765 if (yyn > YYFLAG && yyn < YYLAST)
766 {
767 YYSIZE_T yysize = 0;
768 char *yymsg;
769 int yyx, yycount;
770
771 yycount = 0;
772 /* Start YYX at -YYN if negative to avoid negative indexes in
773 YYCHECK. */
774 for (yyx = yyn < 0 ? -yyn : 0;
775 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
776 if (yycheck[yyx + yyn] == yyx)
777 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
778 yysize += yystrlen ("parse error, unexpected ") + 1;
779 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
780 yymsg = (char *) YYSTACK_ALLOC (yysize);
781 if (yymsg != 0)
782 {
783 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
784 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
785
786 if (yycount < 5)
787 {
788 yycount = 0;
789 for (yyx = yyn < 0 ? -yyn : 0;
790 yyx < (int) (sizeof (yytname) / sizeof (char *));
791 yyx++)
792 if (yycheck[yyx + yyn] == yyx)
793 {
794 const char *yyq = ! yycount ? ", expecting " : " or ";
795 yyp = yystpcpy (yyp, yyq);
796 yyp = yystpcpy (yyp, yytname[yyx]);
797 yycount++;
798 }
799 }
800 yyerror (yymsg);
801 YYSTACK_FREE (yymsg);
802 }
803 else
804 yyerror ("parse error; also virtual memory exhausted");
805 }
806 else
807 #endif /* defined (YYERROR_VERBOSE) */
808 yyerror ("parse error");
809 }
810 goto yyerrlab1;
811
812
813 /*--------------------------------------------------.
814 | yyerrlab1 -- error raised explicitly by an action |
815 `--------------------------------------------------*/
816 yyerrlab1:
817 if (yyerrstatus == 3)
818 {
819 /* If just tried and failed to reuse lookahead token after an
820 error, discard it. */
821
822 /* return failure if at end of input */
823 if (yychar == YYEOF)
824 YYABORT;
825 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
826 yychar, yytname[yychar1]));
827 yychar = YYEMPTY;
828 }
829
830 /* Else will try to reuse lookahead token after shifting the error
831 token. */
832
833 yyerrstatus = 3; /* Each real token shifted decrements this */
834
835 goto yyerrhandle;
836
837
838 /*-------------------------------------------------------------------.
839 | yyerrdefault -- current state does not do anything special for the |
840 | error token. |
841 `-------------------------------------------------------------------*/
842 yyerrdefault:
843 #if 0
844 /* This is wrong; only states that explicitly want error tokens
845 should shift them. */
846
847 /* If its default is to accept any token, ok. Otherwise pop it. */
848 yyn = yydefact[yystate];
849 if (yyn)
850 goto yydefault;
851 #endif
852
853
854 /*---------------------------------------------------------------.
855 | yyerrpop -- pop the current state because it cannot handle the |
856 | error token |
857 `---------------------------------------------------------------*/
858 yyerrpop:
859 if (yyssp == yyss)
860 YYABORT;
861 yyvsp--;
862 yystate = *--yyssp;
863 #if YYLSP_NEEDED
864 yylsp--;
865 #endif
866
867 #if YYDEBUG
868 if (yydebug)
869 {
870 short *yyssp1 = yyss - 1;
871 YYFPRINTF (stderr, "Error: state stack now");
872 while (yyssp1 != yyssp)
873 YYFPRINTF (stderr, " %d", *++yyssp1);
874 YYFPRINTF (stderr, "\n");
875 }
876 #endif
877
878 /*--------------.
879 | yyerrhandle. |
880 `--------------*/
881 yyerrhandle:
882 yyn = yypact[yystate];
883 if (yyn == YYFLAG)
884 goto yyerrdefault;
885
886 yyn += YYTERROR;
887 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
888 goto yyerrdefault;
889
890 yyn = yytable[yyn];
891 if (yyn < 0)
892 {
893 if (yyn == YYFLAG)
894 goto yyerrpop;
895 yyn = -yyn;
896 goto yyreduce;
897 }
898 else if (yyn == 0)
899 goto yyerrpop;
900
901 if (yyn == YYFINAL)
902 YYACCEPT;
903
904 YYDPRINTF ((stderr, "Shifting error token, "));
905
906 *++yyvsp = yylval;
907 #if YYLSP_NEEDED
908 *++yylsp = yylloc;
909 #endif
910
911 yystate = yyn;
912 goto yynewstate;
913
914
915 /*-------------------------------------.
916 | yyacceptlab -- YYACCEPT comes here. |
917 `-------------------------------------*/
918 yyacceptlab:
919 yyresult = 0;
920 goto yyreturn;
921
922 /*-----------------------------------.
923 | yyabortlab -- YYABORT comes here. |
924 `-----------------------------------*/
925 yyabortlab:
926 yyresult = 1;
927 goto yyreturn;
928
929 /*---------------------------------------------.
930 | yyoverflowab -- parser overflow comes here. |
931 `---------------------------------------------*/
932 yyoverflowlab:
933 yyerror ("parser stack overflow");
934 yyresult = 2;
935 /* Fall through. */
936
937 yyreturn:
938 #ifndef yyoverflow
939 if (yyss != yyssa)
940 YYSTACK_FREE (yyss);
941 #endif
942 return yyresult;
943 }