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