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