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