3 # Yacc compatible skeleton for Bison
5 # Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
6 # 2007 Free Software Foundation, Inc.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 # Handle BISON_USE_PUSH_FOR_PULL for the test suite.
24 b4_use_push_for_pull_if([m4_include(b4_pkgdatadir
/[push
.c
])m4_exit
])
26 m4_include(b4_pkgdatadir
/[c
.m4
])
28 b4_check_percent_define_variables
30 b4_check_percent_code_qualifiers([[requires]],
34 ## ---------------- ##
36 ## ---------------- ##
39 m4_define_default([b4_stack_depth_max
], [10000])
40 m4_define_default([b4_stack_depth_init
], [200])
43 ## ------------------------ ##
44 ## Pure/impure interfaces. ##
45 ## ------------------------ ##
48 # b4_yacc_pure_if(IF-TRUE, IF-FALSE)
49 # ----------------------------------
50 # Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise.
51 m4_define([b4_yacc_pure_if
],
52 [b4_pure_if([m4_ifset([b4_parse_param
],
59 # Arguments passed to yyerror: user args plus yylloc.
60 m4_define([b4_yyerror_args
],
61 [b4_yacc_pure_if([b4_locations_if([&yylloc
, ])])dnl
62 m4_ifset([b4_parse_param
], [b4_c_args(b4_parse_param
), ])])
67 # Accumulate in b4_lex_param all the yylex arguments.
68 # b4_lex_param arrives quoted twice, but we want to keep only one level.
69 m4_define([b4_lex_param
],
70 m4_dquote(b4_pure_if([[[[YYSTYPE
*]], [[&yylval
]]][]dnl
71 b4_locations_if([, [[YYLTYPE
*], [&yylloc
]]])m4_ifdef([b4_lex_param
], [, ])])dnl
72 m4_ifdef([b4_lex_param
], b4_lex_param
)))
80 # b4_int_type(MIN, MAX)
81 # ---------------------
82 # Return the smallest int type able to handle numbers ranging from
83 # MIN to MAX (included). Overwrite the version from c.m4, which
84 # uses only C89 types, so that the user can override the shorter
85 # types, and so that pre-C89 compilers are handled correctly.
86 m4_define([b4_int_type
],
87 [m4_if(b4_ints_in($@
, [0], [255]), [1], [yytype_uint8
],
88 b4_ints_in($@
, [-128], [127]), [1], [yytype_int8
],
90 b4_ints_in($@
, [0], [65535]), [1], [yytype_uint16
],
91 b4_ints_in($@
, [-32768], [32767]), [1], [yytype_int16
],
93 m4_eval([0 <= $
1]), [1], [unsigned int],
98 ## ----------------- ##
99 ## Semantic Values. ##
100 ## ----------------- ##
103 # b4_lhs_value([TYPE])
104 # --------------------
105 # Expansion of $<TYPE>$.
106 m4_define([b4_lhs_value
],
107 [(yyval
[]m4_ifval([$
1], [.$
1]))])
110 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
111 # --------------------------------------
112 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
114 m4_define([b4_rhs_value
],
115 [(yyvsp@
{($
2) - ($
1)@
}m4_ifval([$
3], [.$
3]))])
126 m4_define([b4_lhs_location
],
130 # b4_rhs_location(RULE-LENGTH, NUM)
131 # ---------------------------------
132 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
134 m4_define([b4_rhs_location
],
135 [(yylsp@
{($
2) - ($
1)@
})])
139 ## --------------------------------------------------------- ##
140 ## Defining symbol actions, e.g., printers and destructors. ##
141 ## --------------------------------------------------------- ##
143 # We do want M4 expansion after # for CPP macros.
146 @
output(b4_parser_file_name@
)
147 b4_copyright([Skeleton implementation
for Bison
's Yacc-like parsers in C],dnl '
148 [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])[
150 /* C LALR(1) parser skeleton written by Richard Stallman, by
151 simplifying the original so-called "semantic" parser. */
153 /* All symbols defined below should begin with yy or YY, to avoid
154 infringing on user name space. This should be done even for local
155 variables, as they might otherwise be expanded by user macros.
156 There are some unavoidable exceptions within include files to
157 define necessary library symbols; they are noted "INFRINGES ON
158 USER NAME SPACE" below. */
161 m4_ifdef([b4_percent_code_top
],
162 [[/* Copy the %code "top" blocks. */
163 ]b4_user_code([b4_percent_code_top
])])[]dnl
164 m4_if(b4_prefix
, [yy
], [],
165 [/* Substitute the variable and function names. */
166 #define yyparse b4_prefix[]parse
167 #define yylex b4_prefix[]lex
168 #define yyerror b4_prefix[]error
169 #define yylval b4_prefix[]lval
170 #define yychar b4_prefix[]char
171 #define yydebug b4_prefix[]debug
172 #define yynerrs b4_prefix[]nerrs
173 b4_locations_if([#define yylloc b4_prefix[]lloc])])[
175 /* Copy the first part of user declarations. */
176 ]b4_user_pre_prologue
[
178 /* Enabling traces. */
180 # define YYDEBUG ]b4_debug_flag[
183 /* Enabling verbose error messages. */
184 #ifdef YYERROR_VERBOSE
185 # undef YYERROR_VERBOSE
186 # define YYERROR_VERBOSE 1
188 # define YYERROR_VERBOSE ]b4_error_verbose_flag[
191 /* Enabling the token table. */
192 #ifndef YYTOKEN_TABLE
193 # define YYTOKEN_TABLE ]b4_token_table[
196 ]m4_ifdef([b4_percent_code_requires
],
197 [[/* Copy the %code "requires" blocks. */
198 ]b4_user_code([b4_percent_code_requires
])])[]dnl
200 b4_token_enums_defines(b4_tokens
)[
202 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
203 ]m4_ifdef([b4_stype
],
204 [[typedef union ]b4_union_name
[
207 # define YYSTYPE_IS_TRIVIAL 1]],
208 [m4_if(b4_tag_seen_flag
, 0,
209 [[typedef int YYSTYPE
;
210 # define YYSTYPE_IS_TRIVIAL 1]])])[
211 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
212 # define YYSTYPE_IS_DECLARED 1
215 ]b4_locations_if([#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
216 typedef struct YYLTYPE
223 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
224 # define YYLTYPE_IS_DECLARED 1
225 # define YYLTYPE_IS_TRIVIAL 1
228 m4_ifdef([b4_percent_code_provides
],
229 [[/* Copy the %code "provides" blocks. */
230 ]b4_user_code([b4_percent_code_provides
])])[]dnl
232 [/* Copy the second part of user declarations. */
233 ]b4_user_post_prologue
234 m4_ifdef([b4_percent_code
],
235 [[/* Copy the unqualified %code blocks. */
236 ]b4_user_code([b4_percent_code
])
244 typedef YYTYPE_UINT8 yytype_uint8
;
246 typedef unsigned char yytype_uint8
;
250 typedef YYTYPE_INT8 yytype_int8
;
252 typedef signed char yytype_int8
;
254 typedef short int yytype_int8
;
258 typedef YYTYPE_UINT16 yytype_uint16
;
260 typedef unsigned short int yytype_uint16
;
264 typedef YYTYPE_INT16 yytype_int16
;
266 typedef short int yytype_int16
;
270 # ifdef __SIZE_TYPE__
271 # define YYSIZE_T __SIZE_TYPE__
272 # elif defined size_t
273 # define YYSIZE_T size_t
274 # elif ! defined YYSIZE_T && ]b4_c_modern[
275 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
276 # define YYSIZE_T size_t
278 # define YYSIZE_T unsigned int
282 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
287 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
288 # define YY_(msgid) dgettext ("bison-runtime", msgid)
292 # define YY_(msgid) msgid
296 /* Suppress unused-variable warnings by "using" E. */
297 #if ! defined lint || defined __GNUC__
298 # define YYUSE(e) ((void) (e))
300 # define YYUSE(e) /* empty */
303 /* Identity function, used to suppress warnings about constant conditions. */
307 ]b4_c_function_def([YYID
], [static int], [[int yyi
], [yyi
]])[
313 #if ! defined yyoverflow || YYERROR_VERBOSE
315 /* The parser invokes alloca or malloc; define the necessary symbols. */
317 # ifdef YYSTACK_USE_ALLOCA
318 # if YYSTACK_USE_ALLOCA
320 # define YYSTACK_ALLOC __builtin_alloca
321 # elif defined __BUILTIN_VA_ARG_INCR
322 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
324 # define YYSTACK_ALLOC __alloca
325 # elif defined _MSC_VER
326 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
327 # define alloca _alloca
329 # define YYSTACK_ALLOC alloca
330 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && ]b4_c_modern[
331 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
340 # ifdef YYSTACK_ALLOC
341 /* Pacify GCC's `empty if-body' warning. */
342 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
343 # ifndef YYSTACK_ALLOC_MAXIMUM
344 /* The OS might guarantee only one guard page at the bottom of the stack,
345 and a page size can be as small as 4096 bytes. So we cannot safely
346 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
347 to allow for a few compiler-allocated temporary stack slots. */
348 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
351 # define YYSTACK_ALLOC YYMALLOC
352 # define YYSTACK_FREE YYFREE
353 # ifndef YYSTACK_ALLOC_MAXIMUM
354 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
356 # if (defined __cplusplus && ! defined _STDLIB_H \
357 && ! ((defined YYMALLOC || defined malloc) \
358 && (defined YYFREE || defined free)))
359 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
365 # define YYMALLOC malloc
366 # if ! defined malloc && ! defined _STDLIB_H && ]b4_c_modern[
367 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
372 # if ! defined free && ! defined _STDLIB_H && ]b4_c_modern[
373 void free (void *); /* INFRINGES ON USER NAME SPACE */
377 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
380 #if (! defined yyoverflow \
381 && (! defined __cplusplus \
382 || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
383 && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
385 /* A type that is properly aligned for any stack member. */
390 ]b4_locations_if([ YYLTYPE yyls
;
394 /* The size of the maximum gap between one aligned stack and the next. */
395 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
397 /* The size of an array large to enough to hold all stacks, each with
400 [# define YYSTACK_BYTES(N) \
401 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
402 + 2 * YYSTACK_GAP_MAXIMUM)],
403 [# define YYSTACK_BYTES(N) \
404 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
405 + YYSTACK_GAP_MAXIMUM)])[
407 /* Copy COUNT objects from FROM to TO. The source and destination do
410 # if defined __GNUC__ && 1 < __GNUC__
411 # define YYCOPY(To, From, Count) \
412 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
414 # define YYCOPY(To, From, Count) \
418 for (yyi = 0; yyi < (Count); yyi++) \
419 (To)[yyi] = (From)[yyi]; \
425 /* Relocate STACK from its old location to the new one. The
426 local variables YYSIZE and YYSTACKSIZE give the old and new number of
427 elements in the stack, and YYPTR gives the new location of the
428 stack. Advance YYPTR to a properly aligned location for the next
430 # define YYSTACK_RELOCATE(Stack) \
433 YYSIZE_T yynewbytes; \
434 YYCOPY (&yyptr->Stack, Stack, yysize); \
435 Stack = &yyptr->Stack; \
436 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
437 yyptr += yynewbytes / sizeof (*yyptr); \
443 /* YYFINAL -- State number of the termination state. */
444 #define YYFINAL ]b4_final_state_number[
445 /* YYLAST -- Last index in YYTABLE. */
446 #define YYLAST ]b4_last[
448 /* YYNTOKENS -- Number of terminals. */
449 #define YYNTOKENS ]b4_tokens_number[
450 /* YYNNTS -- Number of nonterminals. */
451 #define YYNNTS ]b4_nterms_number[
452 /* YYNRULES -- Number of rules. */
453 #define YYNRULES ]b4_rules_number[
454 /* YYNRULES -- Number of states. */
455 #define YYNSTATES ]b4_states_number[
457 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
458 #define YYUNDEFTOK ]b4_undef_token_number[
459 #define YYMAXUTOK ]b4_user_token_number_max[
461 #define YYTRANSLATE(YYX) \
462 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
464 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
465 static const ]b4_int_type_for([b4_translate
])[ yytranslate
[] =
471 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
473 static const ]b4_int_type_for([b4_prhs
])[ yyprhs
[] =
478 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
479 static const ]b4_int_type_for([b4_rhs
])[ yyrhs
[] =
484 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
485 static const ]b4_int_type_for([b4_rline
])[ yyrline
[] =
491 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
492 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
493 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
494 static const char *const yytname
[] =
501 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
503 static const ]b4_int_type_for([b4_toknum
])[ yytoknum
[] =
509 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
510 static const ]b4_int_type_for([b4_r1
])[ yyr1
[] =
515 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
516 static const ]b4_int_type_for([b4_r2
])[ yyr2
[] =
521 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
522 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
523 means the default is an error. */
524 static const ]b4_int_type_for([b4_defact
])[ yydefact
[] =
529 /* YYDEFGOTO[NTERM-NUM]. */
530 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto
[] =
535 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
537 #define YYPACT_NINF ]b4_pact_ninf[
538 static const ]b4_int_type_for([b4_pact
])[ yypact
[] =
543 /* YYPGOTO[NTERM-NUM]. */
544 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto
[] =
549 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
550 positive, shift that token. If negative, reduce the rule which
551 number is the opposite. If zero, do what YYDEFACT says.
552 If YYTABLE_NINF, syntax error. */
553 #define YYTABLE_NINF ]b4_table_ninf[
554 static const ]b4_int_type_for([b4_table
])[ yytable
[] =
559 static const ]b4_int_type_for([b4_check
])[ yycheck
[] =
564 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
565 symbol of state STATE-NUM. */
566 static const ]b4_int_type_for([b4_stos
])[ yystos
[] =
571 #define yyerrok (yyerrstatus = 0)
572 #define yyclearin (yychar = YYEMPTY)
576 #define YYACCEPT goto yyacceptlab
577 #define YYABORT goto yyabortlab
578 #define YYERROR goto yyerrorlab
581 /* Like YYERROR except do call yyerror. This remains here temporarily
582 to ease the transition to the new meaning of YYERROR, for GCC.
583 Once GCC version 2 has supplanted version 1, this can go. */
585 #define YYFAIL goto yyerrlab
587 #define YYRECOVERING() (!!yyerrstatus)
589 #define YYBACKUP(Token, Value) \
591 if (yychar == YYEMPTY && yylen == 1) \
595 yytoken = YYTRANSLATE (yychar); \
601 yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
608 #define YYERRCODE 256
611 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
612 If N is 0, then set CURRENT to the empty location which ends
613 the previous symbol: RHS[0] (always defined). */
615 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
616 #ifndef YYLLOC_DEFAULT
617 # define YYLLOC_DEFAULT(Current, Rhs, N) \
621 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
622 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
623 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
624 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
628 (Current).first_line = (Current).last_line = \
629 YYRHSLOC (Rhs, 0).last_line; \
630 (Current).first_column = (Current).last_column = \
631 YYRHSLOC (Rhs, 0).last_column; \
637 /* YY_LOCATION_PRINT -- Print the location on the stream.
638 This macro was not mandated originally: define only if we know
639 we won't break user code: when these are the locations we know. */
641 #ifndef YY_LOCATION_PRINT
642 # if YYLTYPE_IS_TRIVIAL
643 # define YY_LOCATION_PRINT(File, Loc) \
644 fprintf (File, "%d.%d-%d.%d", \
645 (Loc).first_line, (Loc).first_column, \
646 (Loc).last_line, (Loc).last_column)
648 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
653 /* YYLEX -- calling `yylex' with the right arguments. */
656 # define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM)
658 # define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
661 /* Enable debugging if requested. */
665 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
666 # define YYFPRINTF fprintf
669 # define YYDPRINTF(Args) \
675 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
679 YYFPRINTF (stderr, "%s ", Title); \
680 yy_symbol_print (stderr, \
681 Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
682 YYFPRINTF (stderr, "\n"); \
686 ]b4_yy_symbol_print_generate([b4_c_function_def
])[
688 /*------------------------------------------------------------------.
689 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
691 `------------------------------------------------------------------*/
693 ]b4_c_function_def([yy_stack_print
], [static void],
694 [[yytype_int16
*yybottom
], [yybottom
]],
695 [[yytype_int16
*yytop
], [yytop
]])[
697 YYFPRINTF (stderr
, "Stack now");
698 for (; yybottom
<= yytop
; yybottom
++)
700 int yybot
= *yybottom
;
701 YYFPRINTF (stderr
, " %d", yybot
);
703 YYFPRINTF (stderr
, "\n");
706 # define YY_STACK_PRINT(Bottom, Top) \
709 yy_stack_print ((Bottom), (Top)); \
713 /*------------------------------------------------.
714 | Report that the YYRULE is going to be reduced. |
715 `------------------------------------------------*/
717 ]b4_c_function_def([yy_reduce_print
], [static void],
718 [[YYSTYPE
*yyvsp
], [yyvsp
]],
719 b4_locations_if([[[YYLTYPE
*yylsp
], [yylsp
]],
720 ])[[int yyrule
], [yyrule
]]m4_ifset([b4_parse_param
], [,
723 int yynrhs
= yyr2
[yyrule
];
725 unsigned long int yylno
= yyrline
[yyrule
];
726 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
728 /* The symbols being reduced. */
729 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
731 fprintf (stderr
, " $%d = ", yyi
+ 1);
732 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
733 &]b4_rhs_value(yynrhs
, yyi
+ 1)[
734 ]b4_locations_if([, &]b4_rhs_location(yynrhs
, yyi
+ 1))[]dnl
736 fprintf (stderr
, "\n");
740 # define YY_REDUCE_PRINT(Rule) \
743 yy_reduce_print (yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
746 /* Nonzero means print parse trace. It is left uninitialized so that
747 multiple parsers can coexist. */
750 # define YYDPRINTF(Args)
751 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
752 # define YY_STACK_PRINT(Bottom, Top)
753 # define YY_REDUCE_PRINT(Rule)
754 #endif /* !YYDEBUG */
757 /* YYINITDEPTH -- initial size of the parser's stacks. */
759 # define YYINITDEPTH ]b4_stack_depth_init[
762 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
763 if the built-in stack extension method is used).
765 Do not make this value too large; the results are undefined if
766 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
767 evaluated with infinite-precision integer arithmetic. */
770 # define YYMAXDEPTH ]b4_stack_depth_max[
778 # if defined __GLIBC__ && defined _STRING_H
779 # define yystrlen strlen
781 /* Return the length of YYSTR. */
782 ]b4_c_function_def([yystrlen
], [static YYSIZE_T
],
783 [[const char *yystr
], [yystr
]])[
786 for (yylen
= 0; yystr
[yylen
]; yylen
++)
794 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
795 # define yystpcpy stpcpy
797 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
799 ]b4_c_function_def([yystpcpy
], [static char *],
800 [[char *yydest
], [yydest
]], [[const char *yysrc
], [yysrc
]])[
803 const char *yys
= yysrc
;
805 while ((*yyd
++ = *yys
++) != '\0')
814 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
815 quotes and backslashes, so that it's suitable for yyerror. The
816 heuristic is that double-quoting is unnecessary unless the string
817 contains an apostrophe, a comma, or backslash (other than
818 backslash-backslash). YYSTR is taken from yytname. If YYRES is
819 null, do not copy; instead, return the length of what the result
822 yytnamerr (char *yyres
, const char *yystr
)
827 char const *yyp
= yystr
;
834 goto do_not_strip_quotes
;
838 goto do_not_strip_quotes
;
851 do_not_strip_quotes
: ;
855 return yystrlen (yystr
);
857 return yystpcpy (yyres
, yystr
) - yyres
;
861 /* Copy into YYRESULT an error message about the unexpected token
862 YYCHAR while in state YYSTATE. Return the number of bytes copied,
863 including the terminating null byte. If YYRESULT is null, do not
864 copy anything; just return the number of bytes that would be
865 copied. As a special case, return 0 if an ordinary "syntax error"
866 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
869 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
871 int yyn
= yypact
[yystate
];
873 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
877 int yytype
= YYTRANSLATE (yychar
);
878 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
879 YYSIZE_T yysize
= yysize0
;
881 int yysize_overflow
= 0;
882 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
883 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
887 /* This is so xgettext sees the translatable formats that are
888 constructed on the fly. */
889 YY_("syntax error, unexpected %s");
890 YY_("syntax error, unexpected %s, expecting %s");
891 YY_("syntax error, unexpected %s, expecting %s or %s");
892 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
893 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
897 static char const yyunexpected
[] = "syntax error, unexpected %s";
898 static char const yyexpecting
[] = ", expecting %s";
899 static char const yyor
[] = " or %s";
900 char yyformat
[sizeof yyunexpected
901 + sizeof yyexpecting
- 1
902 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
903 * (sizeof yyor
- 1))];
904 char const *yyprefix
= yyexpecting
;
906 /* Start YYX at -YYN if negative to avoid negative indexes in
908 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
910 /* Stay within bounds of both yycheck and yytname. */
911 int yychecklim
= YYLAST
- yyn
+ 1;
912 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
915 yyarg
[0] = yytname
[yytype
];
916 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
918 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
919 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
921 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
925 yyformat
[sizeof yyunexpected
- 1] = '\0';
928 yyarg
[yycount
++] = yytname
[yyx
];
929 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
930 yysize_overflow
|= (yysize1
< yysize
);
932 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
937 yysize1
= yysize
+ yystrlen (yyf
);
938 yysize_overflow
|= (yysize1
< yysize
);
942 return YYSIZE_MAXIMUM
;
946 /* Avoid sprintf, as that infringes on the user's name space.
947 Don't have undefined behavior even if the translation
948 produced a string with the wrong number of "%s"s. */
949 char *yyp
= yyresult
;
951 while ((*yyp
= *yyf
) != '\0')
953 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
955 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
968 #endif /* YYERROR_VERBOSE */
971 ]b4_yydestruct_generate([b4_c_function_def
])[
974 /* Prevent warnings from -Wmissing-prototypes. */
977 ]b4_c_function_decl([yyparse
], [int],
978 [[void *YYPARSE_PARAM
], [YYPARSE_PARAM
]])[
979 #else /* ! YYPARSE_PARAM */
980 ]b4_c_function_decl([yyparse
], [int], b4_parse_param
)[
981 #endif /* ! YYPARSE_PARAM */
984 ]m4_divert_push([KILL
])# ======================== M4 code.
985 # b4_declare_parser_variables
986 # ---------------------------
987 # Declare the variables that are global, or local to YYPARSE if
989 m4_define([b4_declare_parser_variables
],
990 [/* The lookahead symbol. */
993 /* The semantic value of the lookahead symbol. */
996 /* Number of syntax errors so far. */
997 int yynerrs
;b4_locations_if([
998 /* Location data for the lookahead symbol. */
1001 m4_divert_pop([KILL
])dnl
# ====================== End of M4 code.
1004 [b4_declare_parser_variables
])
1011 #ifdef YYPARSE_PARAM
1012 b4_c_function_def([yyparse
], [int], [[void *YYPARSE_PARAM
], [YYPARSE_PARAM
]])
1013 #else /* ! YYPARSE_PARAM */
1014 b4_c_function_def([yyparse
], [int], b4_parse_param
)
1017 ]b4_pure_if([b4_declare_parser_variables
])[
1021 /* Number of tokens to shift before error messages enabled. */
1023 /* Lookahead token as an internal (translated) token number. */
1026 /* Buffer for error messages, and its allocated size. */
1028 char *yymsg
= yymsgbuf
;
1029 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1032 /* Three stacks and their tools:
1033 `yyss': related to states,
1034 `yyvs': related to semantic values,
1035 `yyls': related to locations.
1037 Refer to the stacks thru separate pointers, to allow yyoverflow
1038 to reallocate them elsewhere. */
1040 /* The state stack. */
1041 yytype_int16 yyssa
[YYINITDEPTH
];
1042 yytype_int16
*yyss
= yyssa
;
1043 yytype_int16
*yyssp
;
1045 /* The semantic value stack. */
1046 YYSTYPE yyvsa
[YYINITDEPTH
];
1047 YYSTYPE
*yyvs
= yyvsa
;
1051 [[ /* The location stack. */
1052 YYLTYPE yylsa
[YYINITDEPTH
];
1053 YYLTYPE
*yyls
= yylsa
;
1055 /* The locations where the error started and ended. */
1056 YYLTYPE yyerror_range
[2];]])[
1058 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[)
1060 YYSIZE_T yystacksize
= YYINITDEPTH
;
1062 /* The variables used to return semantic value and location from the
1065 ]b4_locations_if([ YYLTYPE yyloc
;])[
1067 /* The number of symbols on the RHS of the reduced rule.
1068 Keep to zero when no symbol should be popped. */
1071 YYDPRINTF ((stderr
, "Starting parse\n"));
1076 yychar
= YYEMPTY
; /* Cause a token to be read. */
1078 /* Initialize stack pointers.
1079 Waste one element of value and location stack
1080 so that they stay on the same level as the state stack.
1081 The wasted elements are never initialized. */
1085 ]b4_locations_if([[ yylsp
= yyls
;
1086 #if YYLTYPE_IS_TRIVIAL
1087 /* Initialize the default location before parsing starts. */
1088 yylloc
.first_line
= yylloc
.last_line
= ]b4_location_initial_line
[;
1089 yylloc
.first_column
= yylloc
.last_column
= ]b4_location_initial_column
[;
1092 m4_ifdef([b4_initial_action
], [
1093 m4_pushdef([b4_at_dollar
], [m4_define([b4_at_dollar_used
])yylloc
])dnl
1094 m4_pushdef([b4_dollar_dollar
], [m4_define([b4_dollar_dollar_used
])yylval
])dnl
1095 /* User initialization code. */
1096 b4_user_initial_action
1097 m4_popdef([b4_dollar_dollar
])dnl
1098 m4_popdef([b4_at_dollar
])])dnl
1099 m4_ifdef([b4_dollar_dollar_used
],[[ yyvsp
[0] = yylval
;
1101 m4_ifdef([b4_at_dollar_used
], [[ yylsp
[0] = yylloc
;
1105 /*------------------------------------------------------------.
1106 | yynewstate -- Push a new state, which is found in yystate. |
1107 `------------------------------------------------------------*/
1109 /* In all cases, when you get here, the value and location stacks
1110 have just been pushed. So pushing a state here evens the stacks. */
1116 if (yyss
+ yystacksize
- 1 <= yyssp
)
1118 /* Get the current used size of the three stacks, in elements. */
1119 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1123 /* Give user a chance to reallocate the stack. Use copies of
1124 these so that the &'s don't force the real ones into
1126 YYSTYPE
*yyvs1
= yyvs
;
1127 yytype_int16
*yyss1
= yyss
;
1128 ]b4_locations_if([ YYLTYPE
*yyls1
= yyls
;])[
1130 /* Each stack pointer address is followed by the size of the
1131 data in use in that stack, in bytes. This used to be a
1132 conditional around just the two extra args, but that might
1133 be undefined if yyoverflow is a macro. */
1134 yyoverflow (YY_("memory exhausted"),
1135 &yyss1
, yysize
* sizeof (*yyssp
),
1136 &yyvs1
, yysize
* sizeof (*yyvsp
),
1137 ]b4_locations_if([ &yyls1
, yysize
* sizeof (*yylsp
),])[
1139 ]b4_locations_if([ yyls
= yyls1
;])[
1143 #else /* no yyoverflow */
1144 # ifndef YYSTACK_RELOCATE
1145 goto yyexhaustedlab
;
1147 /* Extend the stack our own way. */
1148 if (YYMAXDEPTH
<= yystacksize
)
1149 goto yyexhaustedlab
;
1151 if (YYMAXDEPTH
< yystacksize
)
1152 yystacksize
= YYMAXDEPTH
;
1155 yytype_int16
*yyss1
= yyss
;
1156 union yyalloc
*yyptr
=
1157 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1159 goto yyexhaustedlab
;
1160 YYSTACK_RELOCATE (yyss
);
1161 YYSTACK_RELOCATE (yyvs
);
1162 ]b4_locations_if([ YYSTACK_RELOCATE (yyls
);])[
1163 # undef YYSTACK_RELOCATE
1165 YYSTACK_FREE (yyss1
);
1168 #endif /* no yyoverflow */
1170 yyssp
= yyss
+ yysize
- 1;
1171 yyvsp
= yyvs
+ yysize
- 1;
1172 ]b4_locations_if([ yylsp
= yyls
+ yysize
- 1;])[
1174 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1175 (unsigned long int) yystacksize
));
1177 if (yyss
+ yystacksize
- 1 <= yyssp
)
1181 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1183 if (yystate
== YYFINAL
)
1193 /* Do appropriate processing given the current state. Read a
1194 lookahead token if we need one and don't already have one. */
1196 /* First try to decide what to do without reference to lookahead token. */
1197 yyn
= yypact
[yystate
];
1198 if (yyn
== YYPACT_NINF
)
1201 /* Not known => get a lookahead token if don't already have one. */
1203 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1204 if (yychar
== YYEMPTY
)
1206 YYDPRINTF ((stderr
, "Reading a token: "));
1210 if (yychar
<= YYEOF
)
1212 yychar
= yytoken
= YYEOF
;
1213 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1217 yytoken
= YYTRANSLATE (yychar
);
1218 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1221 /* If the proper action on seeing token YYTOKEN is to reduce or to
1222 detect an error, take that action. */
1224 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1229 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1235 /* Count tokens shifted since error; after three, turn off error
1240 /* Shift the lookahead token. */
1241 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1243 /* Discard the shifted token. */
1248 ]b4_locations_if([ *++yylsp
= yylloc
;])[
1252 /*-----------------------------------------------------------.
1253 | yydefault -- do the default action for the current state. |
1254 `-----------------------------------------------------------*/
1256 yyn
= yydefact
[yystate
];
1262 /*-----------------------------.
1263 | yyreduce -- Do a reduction. |
1264 `-----------------------------*/
1266 /* yyn is the number of a rule to reduce with. */
1269 /* If YYLEN is nonzero, implement the default value of the action:
1272 Otherwise, the following line sets YYVAL to garbage.
1273 This behavior is undocumented and Bison
1274 users should not rely upon it. Assigning to YYVAL
1275 unconditionally makes the parser a bit smaller, and it avoids a
1276 GCC warning that YYVAL may be used uninitialized. */
1277 yyval
= yyvsp
[1-yylen
];
1280 [[ /* Default location. */
1281 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);]])[
1282 YY_REDUCE_PRINT (yyn
);
1288 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1292 YY_STACK_PRINT (yyss
, yyssp
);
1295 ]b4_locations_if([ *++yylsp
= yyloc
;])[
1297 /* Now `shift' the result of the reduction. Determine what state
1298 that goes to, based on the state we popped back to and the rule
1299 number reduced by. */
1303 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1304 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1305 yystate
= yytable
[yystate
];
1307 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1312 /*------------------------------------.
1313 | yyerrlab -- here on detecting error |
1314 `------------------------------------*/
1316 /* If not already recovering from an error, report this error. */
1320 #if ! YYERROR_VERBOSE
1321 yyerror (]b4_yyerror_args
[YY_("syntax error"));
1324 YYSIZE_T yysize
= yysyntax_error (0, yystate
, yychar
);
1325 if (yymsg_alloc
< yysize
&& yymsg_alloc
< YYSTACK_ALLOC_MAXIMUM
)
1327 YYSIZE_T yyalloc
= 2 * yysize
;
1328 if (! (yysize
<= yyalloc
&& yyalloc
<= YYSTACK_ALLOC_MAXIMUM
))
1329 yyalloc
= YYSTACK_ALLOC_MAXIMUM
;
1330 if (yymsg
!= yymsgbuf
)
1331 YYSTACK_FREE (yymsg
);
1332 yymsg
= (char *) YYSTACK_ALLOC (yyalloc
);
1334 yymsg_alloc
= yyalloc
;
1338 yymsg_alloc
= sizeof yymsgbuf
;
1342 if (0 < yysize
&& yysize
<= yymsg_alloc
)
1344 (void) yysyntax_error (yymsg
, yystate
, yychar
);
1345 yyerror (]b4_yyerror_args
[yymsg
);
1349 yyerror (]b4_yyerror_args
[YY_("syntax error"));
1351 goto yyexhaustedlab
;
1357 ]b4_locations_if([[ yyerror_range
[0] = yylloc
;]])[
1359 if (yyerrstatus
== 3)
1361 /* If just tried and failed to reuse lookahead token after an
1362 error, discard it. */
1364 if (yychar
<= YYEOF
)
1366 /* Return failure if at end of input. */
1367 if (yychar
== YYEOF
)
1372 yydestruct ("Error: discarding",
1373 yytoken
, &yylval
]b4_locations_if([, &yylloc
])[]b4_user_args
[);
1378 /* Else will try to reuse lookahead token after shifting the error
1383 /*---------------------------------------------------.
1384 | yyerrorlab -- error raised explicitly by YYERROR. |
1385 `---------------------------------------------------*/
1388 /* Pacify compilers like GCC when the user code never invokes
1389 YYERROR and the label yyerrorlab therefore never appears in user
1391 if (/*CONSTCOND*/ 0)
1394 ]b4_locations_if([[ yyerror_range
[0] = yylsp
[1-yylen
];
1395 ]])[ /* Do not reclaim the symbols of the rule which action triggered
1399 YY_STACK_PRINT (yyss
, yyssp
);
1404 /*-------------------------------------------------------------.
1405 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1406 `-------------------------------------------------------------*/
1408 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1412 yyn
= yypact
[yystate
];
1413 if (yyn
!= YYPACT_NINF
)
1416 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1424 /* Pop the current state because it cannot handle the error token. */
1428 ]b4_locations_if([[ yyerror_range
[0] = *yylsp
;]])[
1429 yydestruct ("Error: popping",
1430 yystos
[yystate
], yyvsp
]b4_locations_if([, yylsp
])[]b4_user_args
[);
1433 YY_STACK_PRINT (yyss
, yyssp
);
1438 yyerror_range
[1] = yylloc
;
1439 /* Using YYLLOC is tempting, but would change the location of
1440 the lookahead. YYLOC is available though. */
1441 YYLLOC_DEFAULT (yyloc
, (yyerror_range
- 1), 2);
1442 *++yylsp
= yyloc
;]])[
1444 /* Shift the error token. */
1445 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1451 /*-------------------------------------.
1452 | yyacceptlab -- YYACCEPT comes here. |
1453 `-------------------------------------*/
1458 /*-----------------------------------.
1459 | yyabortlab -- YYABORT comes here. |
1460 `-----------------------------------*/
1466 /*-------------------------------------------------.
1467 | yyexhaustedlab -- memory exhaustion comes here. |
1468 `-------------------------------------------------*/
1470 yyerror (]b4_yyerror_args
[YY_("memory exhausted"));
1476 if (yychar
!= YYEMPTY
)
1477 yydestruct ("Cleanup: discarding lookahead",
1478 yytoken
, &yylval
]b4_locations_if([, &yylloc
])[]b4_user_args
[);
1479 /* Do not reclaim the symbols of the rule which action triggered
1480 this YYABORT or YYACCEPT. */
1482 YY_STACK_PRINT (yyss
, yyssp
);
1483 while (yyssp
!= yyss
)
1485 yydestruct ("Cleanup: popping",
1486 yystos
[*yyssp
], yyvsp
]b4_locations_if([, yylsp
])[]b4_user_args
[);
1491 YYSTACK_FREE (yyss
);
1494 if (yymsg
!= yymsgbuf
)
1495 YYSTACK_FREE (yymsg
);
1497 /* Make sure YYID is used. */
1498 return YYID (yyresult
);
1504 [@
output(b4_spec_defines_file@
)
1505 b4_copyright([Skeleton interface
for Bison
's Yacc-like parsers in C],dnl '
1506 [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])
1508 m4_ifdef([b4_percent_code_requires
],
1509 [[/* Copy the %code "requires" blocks. */
1510 ]b4_user_code([b4_percent_code_requires
])])[]dnl
1512 b4_token_enums_defines(b4_tokens
)
1514 [#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1515 ]m4_ifdef([b4_stype
],
1516 [[typedef union ]b4_union_name
[
1519 # define YYSTYPE_IS_TRIVIAL 1]],
1520 [m4_if(b4_tag_seen_flag
, 0,
1521 [[typedef int YYSTYPE
;
1522 # define YYSTYPE_IS_TRIVIAL 1]])])[
1523 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1524 # define YYSTYPE_IS_DECLARED 1
1528 [extern YYSTYPE b4_prefix
[]lval
;])
1531 [#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
1532 typedef struct YYLTYPE
1539 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
1540 # define YYLTYPE_IS_DECLARED 1
1541 # define YYLTYPE_IS_TRIVIAL 1
1545 [extern YYLTYPE b4_prefix
[]lloc
;])
1546 )dnl b4_locations_if
1548 m4_ifdef([b4_percent_code_provides
],
1549 [[/* Copy the %code "provides" blocks. */
1550 ]b4_user_code([b4_percent_code_provides
])])[]