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