]> git.saurik.com Git - bison.git/blob - src/bison.simple
0e121d229075126890183c397a9ea716df2ab125
[bison.git] / src / bison.simple
1 /* -*- C -*- */
2
3 /* A Bison parser, made from %%filename
4 by GNU bison %%version. */
5
6 /* Skeleton output parser for bison,
7 Copyright 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
23
24 /* As a special exception, when this file is copied by Bison into a
25 Bison output file, you may use that output file without restriction.
26 This special exception was added by the Free Software Foundation
27 in version 1.24 of Bison. */
28
29 /* This is the parser code that is written into each bison parser when
30 the %semantic_parser declaration is not specified in the grammar.
31 It was written by Richard Stallman by simplifying the hairy parser
32 used when %semantic_parser is specified. */
33
34 /* Identify Bison output. */
35 #define YYBISON 1
36
37 /* Pure parsers. */
38 #define YYPURE %%pure
39
40 /* Using locations. */
41 #define YYLSP_NEEDED %%locations-flag
42
43 /* Enabling traces. */
44 #ifndef YYDEBUG
45 # define YYDEBUG %%debug
46 #endif
47
48 /* Enabling verbose error messages. */
49 #ifdef YYERROR_VERBOSE
50 # undef YYERROR_VERBOSE
51 # define YYERROR_VERBOSE 1
52 #else
53 # define YYERROR_VERBOSE %%error-verbose
54 #endif
55
56 /* If name_prefix is specify substitute the variables and functions
57 names. */
58 #define yyparse %%prefix##parse
59 #define yylex %%prefix##lex
60 #define yyerror %%prefix##error
61 #define yylval %%prefix##lval
62 #define yychar %%prefix##char
63 #define yydebug %%prefix##debug
64 #define yynerrs %%prefix##nerrs
65
66 #ifndef YYSTYPE
67 typedef %%stype yystype;
68 # define YYSTYPE yystype
69 #endif
70
71 #ifndef YYLTYPE
72 typedef struct yyltype
73 {
74 int first_line;
75 int first_column;
76 int last_line;
77 int last_column;
78 } yyltype;
79 # define YYLTYPE %%ltype
80 #endif
81
82 /* Copy the user declarations. */
83 %%prologue
84
85 #line %%line "%%skeleton"
86
87 #include <stdio.h>
88
89 /* All symbols defined below should begin with yy or YY, to avoid
90 infringing on user name space. This should be done even for local
91 variables, as they might otherwise be expanded by user macros.
92 There are some unavoidable exceptions within include files to
93 define necessary library symbols; they are noted "INFRINGES ON
94 USER NAME SPACE" below. */
95
96 #if ! defined (yyoverflow) || YYERROR_VERBOSE
97
98 /* The parser invokes alloca or malloc; define the necessary symbols. */
99
100 # if YYSTACK_USE_ALLOCA
101 # define YYSTACK_ALLOC alloca
102 # define YYSIZE_T size_t
103 # else
104 # ifndef YYSTACK_USE_ALLOCA
105 # if defined (alloca) || defined (_ALLOCA_H)
106 # define YYSTACK_ALLOC alloca
107 # define YYSIZE_T size_t
108 # else
109 # if defined (__GNUC__) || defined (_AIX) || defined (__hpux)
110 # define YYSTACK_ALLOC __builtin_alloca
111 # endif
112 # ifndef __GNUC__
113 # ifdef _AIX
114 # pragma alloca
115 # endif
116 # if defined (__sgi) || defined (__sparc__) || defined (__sparc) || defined (__sun)
117 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
118 # define YYSTACK_ALLOC alloca
119 # define YYSIZE_T size_t
120 # endif
121 # endif
122 # endif
123 # endif
124 # endif
125
126 # ifdef YYSTACK_ALLOC
127 /* Pacify GCC's `empty if-body' warning. */
128 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
129 # else
130 # ifdef __cplusplus
131 # include <cstdlib> /* INFRINGES ON USER NAME SPACE */
132 # define YYSIZE_T std::size_t
133 # define YYSTACK_ALLOC std::malloc
134 # define YYSTACK_FREE std::free
135 # else
136 # ifdef __STDC__
137 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
138 # define YYSIZE_T size_t
139 # endif
140 # define YYSTACK_ALLOC malloc
141 # define YYSTACK_FREE free
142 # endif
143 # endif
144
145 /* A type that is properly aligned for any stack member. */
146 union yyalloc
147 {
148 short yyss;
149 YYSTYPE yyvs;
150 # if YYLSP_NEEDED
151 YYLTYPE yyls;
152 # endif
153 };
154
155 /* The size of the maximum gap between one aligned stack and the next. */
156 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
157
158 /* The size of an array large to enough to hold all stacks, each with
159 N elements. */
160 # if YYLSP_NEEDED
161 # define YYSTACK_BYTES(N) \
162 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
163 + 2 * YYSTACK_GAP_MAX)
164 # else
165 # define YYSTACK_BYTES(N) \
166 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
167 + YYSTACK_GAP_MAX)
168 # endif
169
170 /* Relocate the TYPE STACK from its old location to the new one. The
171 local variables YYSIZE and YYSTACKSIZE give the old and new number of
172 elements in the stack, and YYPTR gives the new location of the
173 stack. Advance YYPTR to a properly aligned location for the next
174 stack. */
175 # define YYSTACK_RELOCATE(Type, Stack) \
176 do \
177 { \
178 YYSIZE_T yynewbytes; \
179 yymemcpy ((char *) yyptr, (char *) (Stack), \
180 yysize * (YYSIZE_T) sizeof (Type)); \
181 Stack = &yyptr->Stack; \
182 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
183 yyptr += yynewbytes / sizeof (*yyptr); \
184 } \
185 while (0)
186
187 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
188
189 /* Tokens. */
190 %%tokendef
191
192 #define YYFINAL %%final
193 #define YYFLAG %%flag
194 #define YYNTBASE %%ntbase
195 #define YYLAST %%last
196
197 #define YYNTOKENS %%ntokens
198 #define YYNNTS %%nnts
199 #define YYNRULES %%nrules
200 #define YYNSTATES %%nstates
201 #define YYMAXUTOK %%maxtok
202
203 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
204 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
205
206 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
207 static const char yytranslate[] =
208 {
209 %%translate
210 };
211
212 #if YYDEBUG
213 static const short yyprhs[] =
214 {
215 %%prhs
216 };
217
218 static const short yyrhs[] =
219 {
220 %%rhs
221 };
222
223 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
224 static const short yyrline[] =
225 {
226 %%rline
227 };
228 #endif
229
230 #if YYDEBUG || YYERROR_VERBOSE
231 /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
232 static const char *const yytname[] =
233 {
234 %%tname
235 };
236 #endif
237
238 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
239 static const short yytoknum[] =
240 {
241 %%toknum
242 };
243
244 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
245 static const short yyr1[] =
246 {
247 %%r1
248 };
249
250 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
251 static const short yyr2[] =
252 {
253 %%r2
254 };
255
256 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
257 doesn't specify something else to do. Zero means the default is an
258 error. */
259 static const short yydefact[] =
260 {
261 %%defact
262 };
263
264 static const short yydefgoto[] =
265 {
266 %%defgoto
267 };
268
269 static const short yypact[] =
270 {
271 %%pact
272 };
273
274 static const short yypgoto[] =
275 {
276 %%pgoto
277 };
278
279 static const short yytable[] =
280 {
281 %%table
282 };
283
284 static const short yycheck[] =
285 {
286 %%check
287 };
288
289
290 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
291 # define YYSIZE_T __SIZE_TYPE__
292 #endif
293 #if ! defined (YYSIZE_T) && defined (size_t)
294 # define YYSIZE_T size_t
295 #endif
296 #if ! defined (YYSIZE_T)
297 # ifdef __cplusplus
298 # include <cstddef> /* INFRINGES ON USER NAME SPACE */
299 # define YYSIZE_T std::size_t
300 # else
301 # ifdef __STDC__
302 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
303 # define YYSIZE_T size_t
304 # endif
305 # endif
306 #endif
307 #if ! defined (YYSIZE_T)
308 # define YYSIZE_T unsigned int
309 #endif
310
311 #define yyerrok (yyerrstatus = 0)
312 #define yyclearin (yychar = YYEMPTY)
313 #define YYEMPTY -2
314 #define YYEOF 0
315
316 #define YYACCEPT goto yyacceptlab
317 #define YYABORT goto yyabortlab
318 #define YYERROR goto yyerrlab1
319
320 /* Like YYERROR except do call yyerror. This remains here temporarily
321 to ease the transition to the new meaning of YYERROR, for GCC.
322 Once GCC version 2 has supplanted version 1, this can go. */
323
324 #define YYFAIL goto yyerrlab
325
326 #define YYRECOVERING() (!!yyerrstatus)
327
328 #define YYBACKUP(Token, Value) \
329 do \
330 if (yychar == YYEMPTY && yylen == 1) \
331 { \
332 yychar = (Token); \
333 yylval = (Value); \
334 yychar1 = YYTRANSLATE (yychar); \
335 YYPOPSTACK; \
336 goto yybackup; \
337 } \
338 else \
339 { \
340 yyerror ("syntax error: cannot back up"); \
341 YYERROR; \
342 } \
343 while (0)
344
345 #define YYTERROR 1
346 #define YYERRCODE 256
347
348 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
349 are run).
350
351 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
352 first token. By default, to implement support for ranges, extend
353 its range to the last symbol. */
354
355 #ifndef YYLLOC_DEFAULT
356 # define YYLLOC_DEFAULT(Current, Rhs, N) \
357 Current.last_line = Rhs[N].last_line; \
358 Current.last_column = Rhs[N].last_column;
359 #endif
360
361 /* YYLEX -- calling `yylex' with the right arguments. */
362
363 #if YYPURE
364 # if YYLSP_NEEDED
365 # ifdef YYLEX_PARAM
366 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
367 # else
368 # define YYLEX yylex (&yylval, &yylloc)
369 # endif
370 # else /* !YYLSP_NEEDED */
371 # ifdef YYLEX_PARAM
372 # define YYLEX yylex (&yylval, YYLEX_PARAM)
373 # else
374 # define YYLEX yylex (&yylval)
375 # endif
376 # endif /* !YYLSP_NEEDED */
377 #else /* !YYPURE */
378 # define YYLEX yylex ()
379 #endif /* !YYPURE */
380
381 /* Enable debugging if requested. */
382 #if YYDEBUG
383
384 # ifndef YYFPRINTF
385 # ifdef __cplusplus
386 # include <cstdio.h> /* INFRINGES ON USER NAME SPACE */
387 # define YYFPRINTF std::fprintf
388 # define YYSTDERR std::stderr
389 # else
390 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
391 # define YYFPRINTF fprintf
392 # define YYSTDERR stderr
393 # endif
394 # endif
395
396 # define YYDPRINTF(Args) \
397 do { \
398 if (yydebug) \
399 YYFPRINTF Args; \
400 } while (0)
401 /* Nonzero means print parse trace. [The following comment makes no
402 sense to me. Could someone clarify it? --akim] Since this is
403 uninitialized, it does not stop multiple parsers from coexisting.
404 */
405 int yydebug;
406 #else /* !YYDEBUG */
407 # define YYDPRINTF(Args)
408 #endif /* !YYDEBUG */
409
410 /* YYINITDEPTH -- initial size of the parser's stacks. */
411 #ifndef YYINITDEPTH
412 # define YYINITDEPTH %%initdepth
413 #endif
414
415 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
416 if the built-in stack extension method is used).
417
418 Do not make this value too large; the results are undefined if
419 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
420 evaluated with infinite-precision integer arithmetic. */
421
422 #if YYMAXDEPTH == 0
423 # undef YYMAXDEPTH
424 #endif
425
426 #ifndef YYMAXDEPTH
427 # define YYMAXDEPTH %%maxdepth
428 #endif
429
430 \f
431
432 #if ! defined (yyoverflow) && ! defined (yymemcpy)
433 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
434 # define yymemcpy __builtin_memcpy
435 # else /* not GNU C or C++ */
436
437 /* This is the most reliable way to avoid incompatibilities
438 in available built-in functions on various systems. */
439 static void
440 # if defined (__STDC__) || defined (__cplusplus)
441 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
442 # else
443 yymemcpy (yyto, yyfrom, yycount)
444 char *yyto;
445 const char *yyfrom;
446 YYSIZE_T yycount;
447 # endif
448 {
449 register const char *yyf = yyfrom;
450 register char *yyt = yyto;
451 register YYSIZE_T yyi = yycount;
452
453 while (yyi-- != 0)
454 *yyt++ = *yyf++;
455 }
456 # endif
457 #endif
458
459 #if YYERROR_VERBOSE
460
461 # ifndef yystrlen
462 # if defined (__GLIBC__) && defined (_STRING_H)
463 # define yystrlen strlen
464 # else
465 /* Return the length of YYSTR. */
466 static YYSIZE_T
467 # if defined (__STDC__) || defined (__cplusplus)
468 yystrlen (const char *yystr)
469 # else
470 yystrlen (yystr)
471 const char *yystr;
472 # endif
473 {
474 register const char *yys = yystr;
475
476 while (*yys++ != '\0')
477 continue;
478
479 return yys - yystr - 1;
480 }
481 # endif
482 # endif
483
484 # ifndef yystpcpy
485 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
486 # define yystpcpy stpcpy
487 # else
488 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
489 YYDEST. */
490 static char *
491 # if defined (__STDC__) || defined (__cplusplus)
492 yystpcpy (char *yydest, const char *yysrc)
493 # else
494 yystpcpy (yydest, yysrc)
495 char *yydest;
496 const char *yysrc;
497 # endif
498 {
499 register char *yyd = yydest;
500 register const char *yys = yysrc;
501
502 while ((*yyd++ = *yys++) != '\0')
503 continue;
504
505 return yyd - 1;
506 }
507 # endif
508 # endif
509
510 #endif /* !YYERROR_VERBOSE */
511
512 \f
513
514 #line %%line "%%skeleton"
515
516 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
517 into yyparse. The argument should have type void *.
518 It should actually point to an object.
519 Grammar actions can access the variable by casting it
520 to the proper pointer type. */
521
522 #ifdef YYPARSE_PARAM
523 # ifdef __cplusplus
524 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
525 # define YYPARSE_PARAM_DECL
526 # else /* !__cplusplus */
527 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
528 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
529 # endif /* !__cplusplus */
530 #else /* !YYPARSE_PARAM */
531 # define YYPARSE_PARAM_ARG
532 # define YYPARSE_PARAM_DECL
533 #endif /* !YYPARSE_PARAM */
534
535 /* Prevent warning if -Wstrict-prototypes. */
536 #ifdef __GNUC__
537 # ifdef YYPARSE_PARAM
538 int yyparse (void *);
539 # else
540 int yyparse (void);
541 # endif
542 #endif
543
544 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
545 variables are global, or local to YYPARSE. */
546
547 #define YY_DECL_NON_LSP_VARIABLES \
548 /* The lookahead symbol. */ \
549 int yychar; \
550 \
551 /* The semantic value of the lookahead symbol. */ \
552 YYSTYPE yylval; \
553 \
554 /* Number of parse errors so far. */ \
555 int yynerrs;
556
557 #if YYLSP_NEEDED
558 # define YY_DECL_VARIABLES \
559 YY_DECL_NON_LSP_VARIABLES \
560 \
561 /* Location data for the lookahead symbol. */ \
562 YYLTYPE yylloc;
563 #else
564 # define YY_DECL_VARIABLES \
565 YY_DECL_NON_LSP_VARIABLES
566 #endif
567
568 /* If nonreentrant, generate the variables here. */
569
570 #if !YYPURE
571 YY_DECL_VARIABLES
572 #endif /* !YYPURE */
573
574 int
575 yyparse (YYPARSE_PARAM_ARG)
576 YYPARSE_PARAM_DECL
577 {
578 /* If reentrant, generate the variables here. */
579 #if YYPURE
580 YY_DECL_VARIABLES
581 #endif /* !YYPURE */
582
583 register int yystate;
584 register int yyn;
585 int yyresult;
586 /* Number of tokens to shift before error messages enabled. */
587 int yyerrstatus;
588 /* Lookahead token as an internal (translated) token number. */
589 int yychar1 = 0;
590
591 /* Three stacks and their tools:
592 `yyss': related to states,
593 `yyvs': related to semantic values,
594 `yyls': related to locations.
595
596 Refer to the stacks thru separate pointers, to allow yyoverflow
597 to reallocate them elsewhere. */
598
599 /* The state stack. */
600 short yyssa[YYINITDEPTH];
601 short *yyss = yyssa;
602 register short *yyssp;
603
604 /* The semantic value stack. */
605 YYSTYPE yyvsa[YYINITDEPTH];
606 YYSTYPE *yyvs = yyvsa;
607 register YYSTYPE *yyvsp;
608
609 #if YYLSP_NEEDED
610 /* The location stack. */
611 YYLTYPE yylsa[YYINITDEPTH];
612 YYLTYPE *yyls = yylsa;
613 YYLTYPE *yylsp;
614 #endif
615
616 #if YYLSP_NEEDED
617 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
618 #else
619 # define YYPOPSTACK (yyvsp--, yyssp--)
620 #endif
621
622 YYSIZE_T yystacksize = YYINITDEPTH;
623
624 /* The variables used to return semantic value and location from the
625 action routines. */
626 YYSTYPE yyval;
627 #if YYLSP_NEEDED
628 YYLTYPE yyloc;
629 #endif
630
631 /* When reducing, the number of symbols on the RHS of the reduced
632 rule. */
633 int yylen;
634
635 YYDPRINTF ((YYSTDERR, "Starting parse\n"));
636
637 yystate = 0;
638 yyerrstatus = 0;
639 yynerrs = 0;
640 yychar = YYEMPTY; /* Cause a token to be read. */
641
642 /* Initialize stack pointers.
643 Waste one element of value and location stack
644 so that they stay on the same level as the state stack.
645 The wasted elements are never initialized. */
646
647 yyssp = yyss;
648 yyvsp = yyvs;
649 #if YYLSP_NEEDED
650 yylsp = yyls;
651 #endif
652 goto yysetstate;
653
654 /*------------------------------------------------------------.
655 | yynewstate -- Push a new state, which is found in yystate. |
656 `------------------------------------------------------------*/
657 yynewstate:
658 /* In all cases, when you get here, the value and location stacks
659 have just been pushed. so pushing a state here evens the stacks.
660 */
661 yyssp++;
662
663 yysetstate:
664 *yyssp = yystate;
665
666 if (yyssp >= yyss + yystacksize - 1)
667 {
668 /* Get the current used size of the three stacks, in elements. */
669 YYSIZE_T yysize = yyssp - yyss + 1;
670
671 #ifdef yyoverflow
672 {
673 /* Give user a chance to reallocate the stack. Use copies of
674 these so that the &'s don't force the real ones into
675 memory. */
676 YYSTYPE *yyvs1 = yyvs;
677 short *yyss1 = yyss;
678
679 /* Each stack pointer address is followed by the size of the
680 data in use in that stack, in bytes. */
681 # if YYLSP_NEEDED
682 YYLTYPE *yyls1 = yyls;
683 /* This used to be a conditional around just the two extra args,
684 but that might be undefined if yyoverflow is a macro. */
685 yyoverflow ("parser stack overflow",
686 &yyss1, yysize * sizeof (*yyssp),
687 &yyvs1, yysize * sizeof (*yyvsp),
688 &yyls1, yysize * sizeof (*yylsp),
689 &yystacksize);
690 yyls = yyls1;
691 # else
692 yyoverflow ("parser stack overflow",
693 &yyss1, yysize * sizeof (*yyssp),
694 &yyvs1, yysize * sizeof (*yyvsp),
695 &yystacksize);
696 # endif
697 yyss = yyss1;
698 yyvs = yyvs1;
699 }
700 #else /* no yyoverflow */
701 /* Extend the stack our own way. */
702 if (yystacksize >= YYMAXDEPTH)
703 goto yyoverflowlab;
704 yystacksize *= 2;
705 if (yystacksize > YYMAXDEPTH)
706 yystacksize = YYMAXDEPTH;
707
708 {
709 short *yyss1 = yyss;
710 union yyalloc *yyptr =
711 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
712 if (! yyptr)
713 goto yyoverflowlab;
714 YYSTACK_RELOCATE (short, yyss);
715 YYSTACK_RELOCATE (YYSTYPE, yyvs);
716 # if YYLSP_NEEDED
717 YYSTACK_RELOCATE (YYLTYPE, yyls);
718 # endif
719 # undef YYSTACK_RELOCATE
720 if (yyss1 != yyssa)
721 YYSTACK_FREE (yyss1);
722 }
723 #endif /* no yyoverflow */
724
725 yyssp = yyss + yysize - 1;
726 yyvsp = yyvs + yysize - 1;
727 #if YYLSP_NEEDED
728 yylsp = yyls + yysize - 1;
729 #endif
730
731 YYDPRINTF ((YYSTDERR, "Stack size increased to %lu\n",
732 (unsigned long int) yystacksize));
733
734 if (yyssp >= yyss + yystacksize - 1)
735 YYABORT;
736 }
737
738 YYDPRINTF ((YYSTDERR, "Entering state %d\n", yystate));
739
740 goto yybackup;
741
742 /*-----------.
743 | yybackup. |
744 `-----------*/
745 yybackup:
746
747 /* Do appropriate processing given the current state. */
748 /* Read a lookahead token if we need one and don't already have one. */
749 /* yyresume: */
750
751 /* First try to decide what to do without reference to lookahead token. */
752
753 yyn = yypact[yystate];
754 if (yyn == YYFLAG)
755 goto yydefault;
756
757 /* Not known => get a lookahead token if don't already have one. */
758
759 /* yychar is either YYEMPTY or YYEOF
760 or a valid token in external form. */
761
762 if (yychar == YYEMPTY)
763 {
764 YYDPRINTF ((YYSTDERR, "Reading a token: "));
765 yychar = YYLEX;
766 }
767
768 /* Convert token to internal form (in yychar1) for indexing tables with. */
769
770 if (yychar <= 0) /* This means end of input. */
771 {
772 yychar1 = 0;
773 yychar = YYEOF; /* Don't call YYLEX any more. */
774
775 YYDPRINTF ((YYSTDERR, "Now at end of input.\n"));
776 }
777 else
778 {
779 yychar1 = YYTRANSLATE (yychar);
780
781 #if YYDEBUG
782 /* We have to keep this `#if YYDEBUG', since we use variables
783 which are defined only if `YYDEBUG' is set. */
784 if (yydebug)
785 {
786 YYFPRINTF (YYSTDERR, "Next token is %d (%s",
787 yychar, yytname[yychar1]);
788 /* Give the individual parser a way to print the precise
789 meaning of a token, for further debugging info. */
790 # ifdef YYPRINT
791 YYPRINT (YYSTDERR, yychar, yylval);
792 # endif
793 YYFPRINTF (YYSTDERR, ")\n");
794 }
795 #endif
796 }
797
798 yyn += yychar1;
799 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
800 goto yydefault;
801
802 yyn = yytable[yyn];
803
804 /* yyn is what to do for this token type in this state.
805 Negative => reduce, -yyn is rule number.
806 Positive => shift, yyn is new state.
807 New state is final state => don't bother to shift,
808 just return success.
809 0, or most negative number => error. */
810
811 if (yyn < 0)
812 {
813 if (yyn == YYFLAG)
814 goto yyerrlab;
815 yyn = -yyn;
816 goto yyreduce;
817 }
818 else if (yyn == 0)
819 goto yyerrlab;
820
821 if (yyn == YYFINAL)
822 YYACCEPT;
823
824 /* Shift the lookahead token. */
825 YYDPRINTF ((YYSTDERR, "Shifting token %d (%s), ",
826 yychar, yytname[yychar1]));
827
828 /* Discard the token being shifted unless it is eof. */
829 if (yychar != YYEOF)
830 yychar = YYEMPTY;
831
832 *++yyvsp = yylval;
833 #if YYLSP_NEEDED
834 *++yylsp = yylloc;
835 #endif
836
837 /* Count tokens shifted since error; after three, turn off error
838 status. */
839 if (yyerrstatus)
840 yyerrstatus--;
841
842 yystate = yyn;
843 goto yynewstate;
844
845
846 /*-----------------------------------------------------------.
847 | yydefault -- do the default action for the current state. |
848 `-----------------------------------------------------------*/
849 yydefault:
850 yyn = yydefact[yystate];
851 if (yyn == 0)
852 goto yyerrlab;
853 goto yyreduce;
854
855
856 /*-----------------------------.
857 | yyreduce -- Do a reduction. |
858 `-----------------------------*/
859 yyreduce:
860 /* yyn is the number of a rule to reduce with. */
861 yylen = yyr2[yyn];
862
863 /* If YYLEN is nonzero, implement the default value of the action:
864 `$$ = $1'.
865
866 Otherwise, the following line sets YYVAL to the semantic value of
867 the lookahead token. This behavior is undocumented and Bison
868 users should not rely upon it. Assigning to YYVAL
869 unconditionally makes the parser a bit smaller, and it avoids a
870 GCC warning that YYVAL may be used uninitialized. */
871 yyval = yyvsp[1-yylen];
872
873 #if YYLSP_NEEDED
874 /* Similarly for the default location. Let the user run additional
875 commands if for instance locations are ranges. */
876 yyloc = yylsp[1-yylen];
877 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
878 #endif
879
880 #if YYDEBUG
881 /* We have to keep this `#if YYDEBUG', since we use variables which
882 are defined only if `YYDEBUG' is set. */
883 if (yydebug)
884 {
885 int yyi;
886
887 YYFPRINTF (YYSTDERR, "Reducing via rule %d (line %d), ",
888 yyn, yyrline[yyn]);
889
890 /* Print the symbols being reduced, and their result. */
891 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
892 YYFPRINTF (YYSTDERR, "%s ", yytname[yyrhs[yyi]]);
893 YYFPRINTF (YYSTDERR, " -> %s\n", yytname[yyr1[yyn]]);
894 }
895 #endif
896 switch (yyn)
897 {
898 %%actions
899 }
900 #line %%line "%%skeleton"
901 \f
902 yyvsp -= yylen;
903 yyssp -= yylen;
904 #if YYLSP_NEEDED
905 yylsp -= yylen;
906 #endif
907
908 #if YYDEBUG
909 if (yydebug)
910 {
911 short *yyssp1 = yyss - 1;
912 YYFPRINTF (YYSTDERR, "state stack now");
913 while (yyssp1 != yyssp)
914 YYFPRINTF (YYSTDERR, " %d", *++yyssp1);
915 YYFPRINTF (YYSTDERR, "\n");
916 }
917 #endif
918
919 *++yyvsp = yyval;
920 #if YYLSP_NEEDED
921 *++yylsp = yyloc;
922 #endif
923
924 /* Now `shift' the result of the reduction. Determine what state
925 that goes to, based on the state we popped back to and the rule
926 number reduced by. */
927
928 yyn = yyr1[yyn];
929
930 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
931 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
932 yystate = yytable[yystate];
933 else
934 yystate = yydefgoto[yyn - YYNTBASE];
935
936 goto yynewstate;
937
938
939 /*------------------------------------.
940 | yyerrlab -- here on detecting error |
941 `------------------------------------*/
942 yyerrlab:
943 /* If not already recovering from an error, report this error. */
944 if (!yyerrstatus)
945 {
946 ++yynerrs;
947
948 #if YYERROR_VERBOSE
949 yyn = yypact[yystate];
950
951 if (yyn > YYFLAG && yyn < YYLAST)
952 {
953 YYSIZE_T yysize = 0;
954 char *yymsg;
955 int yyx, yycount;
956
957 yycount = 0;
958 /* Start YYX at -YYN if negative to avoid negative indexes in
959 YYCHECK. */
960 for (yyx = yyn < 0 ? -yyn : 0;
961 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
962 if (yycheck[yyx + yyn] == yyx)
963 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
964 yysize += yystrlen ("parse error, unexpected ") + 1;
965 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
966 yymsg = (char *) YYSTACK_ALLOC (yysize);
967 if (yymsg != 0)
968 {
969 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
970 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
971
972 if (yycount < 5)
973 {
974 yycount = 0;
975 for (yyx = yyn < 0 ? -yyn : 0;
976 yyx < (int) (sizeof (yytname) / sizeof (char *));
977 yyx++)
978 if (yycheck[yyx + yyn] == yyx)
979 {
980 const char *yyq = ! yycount ? ", expecting " : " or ";
981 yyp = yystpcpy (yyp, yyq);
982 yyp = yystpcpy (yyp, yytname[yyx]);
983 yycount++;
984 }
985 }
986 yyerror (yymsg);
987 YYSTACK_FREE (yymsg);
988 }
989 else
990 yyerror ("parse error; also virtual memory exhausted");
991 }
992 else
993 #endif /* YYERROR_VERBOSE */
994 yyerror ("parse error");
995 }
996 goto yyerrlab1;
997
998
999 /*----------------------------------------------------.
1000 | yyerrlab1 -- error raised explicitly by an action. |
1001 `----------------------------------------------------*/
1002 yyerrlab1:
1003 if (yyerrstatus == 3)
1004 {
1005 /* If just tried and failed to reuse lookahead token after an
1006 error, discard it. */
1007
1008 /* Return failure if at end of input. */
1009 if (yychar == YYEOF)
1010 YYABORT;
1011 YYDPRINTF ((YYSTDERR, "Discarding token %d (%s).\n",
1012 yychar, yytname[yychar1]));
1013 yychar = YYEMPTY;
1014 }
1015
1016 /* Else will try to reuse lookahead token after shifting the error
1017 token. */
1018
1019 yyerrstatus = 3; /* Each real token shifted decrements this. */
1020
1021 goto yyerrhandle;
1022
1023
1024 /*-------------------------------------------------------------------.
1025 | yyerrdefault -- current state does not do anything special for the |
1026 | error token. |
1027 `-------------------------------------------------------------------*/
1028 yyerrdefault:
1029 #if 0
1030 /* This is wrong; only states that explicitly want error tokens
1031 should shift them. */
1032
1033 /* If its default is to accept any token, ok. Otherwise pop it. */
1034 yyn = yydefact[yystate];
1035 if (yyn)
1036 goto yydefault;
1037 #endif
1038
1039
1040 /*---------------------------------------------------------------.
1041 | yyerrpop -- pop the current state because it cannot handle the |
1042 | error token. |
1043 `---------------------------------------------------------------*/
1044 yyerrpop:
1045 if (yyssp == yyss)
1046 YYABORT;
1047 yyvsp--;
1048 yystate = *--yyssp;
1049 #if YYLSP_NEEDED
1050 yylsp--;
1051 #endif
1052
1053 #if YYDEBUG
1054 if (yydebug)
1055 {
1056 short *yyssp1 = yyss - 1;
1057 YYFPRINTF (YYSTDERR, "Error: state stack now");
1058 while (yyssp1 != yyssp)
1059 YYFPRINTF (YYSTDERR, " %d", *++yyssp1);
1060 YYFPRINTF (YYSTDERR, "\n");
1061 }
1062 #endif
1063
1064 /*--------------.
1065 | yyerrhandle. |
1066 `--------------*/
1067 yyerrhandle:
1068 yyn = yypact[yystate];
1069 if (yyn == YYFLAG)
1070 goto yyerrdefault;
1071
1072 yyn += YYTERROR;
1073 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1074 goto yyerrdefault;
1075
1076 yyn = yytable[yyn];
1077 if (yyn < 0)
1078 {
1079 if (yyn == YYFLAG)
1080 goto yyerrpop;
1081 yyn = -yyn;
1082 goto yyreduce;
1083 }
1084 else if (yyn == 0)
1085 goto yyerrpop;
1086
1087 if (yyn == YYFINAL)
1088 YYACCEPT;
1089
1090 YYDPRINTF ((YYSTDERR, "Shifting error token, "));
1091
1092 *++yyvsp = yylval;
1093 #if YYLSP_NEEDED
1094 *++yylsp = yylloc;
1095 #endif
1096
1097 yystate = yyn;
1098 goto yynewstate;
1099
1100
1101 /*-------------------------------------.
1102 | yyacceptlab -- YYACCEPT comes here. |
1103 `-------------------------------------*/
1104 yyacceptlab:
1105 yyresult = 0;
1106 goto yyreturn;
1107
1108 /*-----------------------------------.
1109 | yyabortlab -- YYABORT comes here. |
1110 `-----------------------------------*/
1111 yyabortlab:
1112 yyresult = 1;
1113 goto yyreturn;
1114
1115 /*---------------------------------------------.
1116 | yyoverflowab -- parser overflow comes here. |
1117 `---------------------------------------------*/
1118 yyoverflowlab:
1119 yyerror ("parser stack overflow");
1120 yyresult = 2;
1121 /* Fall through. */
1122
1123 yyreturn:
1124 #ifndef yyoverflow
1125 if (yyss != yyssa)
1126 YYSTACK_FREE (yyss);
1127 #endif
1128 return yyresult;
1129 }
1130
1131 %%epilogue