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