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