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