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