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