3 # Yacc compatible skeleton for Bison
5 # Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005,
6 # 2006, 2007, 2008, 2009, 2010 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 3 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, see <http://www.gnu.org/licenses/>.
21 # Check the value of %define api.push-pull.
22 b4_percent_define_default([[api
.push
-pull
]], [[pull]])
23 b4_percent_define_check_values([[[[api
.push
-pull
]],
24 [[pull]], [[push]], [[both]]]])
25 b4_define_flag_if([pull
]) m4_define([b4_pull_flag
], [[1]])
26 b4_define_flag_if([push
]) m4_define([b4_push_flag
], [[1]])
27 m4_case(b4_percent_define_get([[api
.push
-pull
]]),
28 [pull
], [m4_define([b4_push_flag
], [[0]])],
29 [push
], [m4_define([b4_pull_flag
], [[0]])])
31 # Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
32 # tests function as written, don't let BISON_USE_PUSH_FOR_PULL modify Bison's
33 # behavior at all when push parsing is already requested.
34 b4_define_flag_if([use_push_for_pull
])
35 b4_use_push_for_pull_if([
36 b4_push_if([m4_define([b4_use_push_for_pull_flag
], [[0]])],
37 [m4_define([b4_push_flag
], [[1]])])])
39 # Check the value of %define parse.lac, where LAC stands for lookahead
41 b4_percent_define_default([[parse
.lac
]], [[none]])
42 b4_percent_define_default([[parse
.lac
.es
-capacity
]], [[20]])
43 b4_percent_define_check_values([[[[parse
.lac
]], [[full]], [[none]]]])
44 b4_define_flag_if([lac
])
45 m4_define([b4_lac_flag
],
46 [m4_if(b4_percent_define_get([[parse
.lac
]]),
47 [none
], [[0]], [[1]])])
49 m4_include(b4_pkgdatadir
/[c
.m4
])
51 ## ---------------- ##
53 ## ---------------- ##
56 m4_define_default([b4_stack_depth_max
], [10000])
57 m4_define_default([b4_stack_depth_init
], [200])
60 ## ------------------------ ##
61 ## Pure/impure interfaces. ##
62 ## ------------------------ ##
64 b4_percent_define_default([[api
.pure
]], [[false]])
65 b4_define_flag_if([pure
])
66 m4_define([b4_pure_flag
],
67 [b4_percent_define_flag_if([[api
.pure
]], [[1]], [[0]])])
69 # b4_yacc_pure_if(IF-TRUE, IF-FALSE)
70 # ----------------------------------
71 # Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise.
72 m4_define([b4_yacc_pure_if
],
73 [b4_pure_if([m4_ifset([b4_parse_param
],
80 # Arguments passed to yyerror: user args plus yylloc.
81 m4_define([b4_yyerror_args
],
82 [b4_yacc_pure_if([b4_locations_if([&yylloc
, ])])dnl
83 m4_ifset([b4_parse_param
], [b4_c_args(b4_parse_param
), ])])
88 # Accumulate in b4_lex_param all the yylex arguments.
89 # b4_lex_param arrives quoted twice, but we want to keep only one level.
90 m4_define([b4_lex_param
],
91 m4_dquote(b4_pure_if([[[[YYSTYPE
*]], [[&yylval
]]][]dnl
92 b4_locations_if([, [[YYLTYPE
*], [&yylloc
]]])m4_ifdef([b4_lex_param
], [, ])])dnl
93 m4_ifdef([b4_lex_param
], b4_lex_param
)))
100 # b4_int_type(MIN, MAX)
101 # ---------------------
102 # Return the smallest int type able to handle numbers ranging from
103 # MIN to MAX (included). Overwrite the version from c.m4, which
104 # uses only C89 types, so that the user can override the shorter
105 # types, and so that pre-C89 compilers are handled correctly.
106 m4_define([b4_int_type
],
107 [m4_if(b4_ints_in($@
, [0], [255]), [1], [yytype_uint8
],
108 b4_ints_in($@
, [-128], [127]), [1], [yytype_int8
],
110 b4_ints_in($@
, [0], [65535]), [1], [yytype_uint16
],
111 b4_ints_in($@
, [-32768], [32767]), [1], [yytype_int16
],
113 m4_eval([0 <= $
1]), [1], [unsigned int],
118 ## ----------------- ##
119 ## Semantic Values. ##
120 ## ----------------- ##
123 # b4_lhs_value([TYPE])
124 # --------------------
125 # Expansion of $<TYPE>$.
126 m4_define([b4_lhs_value
],
127 [(yyval
[]m4_ifval([$
1], [.$
1]))])
130 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
131 # --------------------------------------
132 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
134 m4_define([b4_rhs_value
],
135 [(yyvsp@
{($
2) - ($
1)@
}m4_ifval([$
3], [.$
3]))])
146 m4_define([b4_lhs_location
],
150 # b4_rhs_location(RULE-LENGTH, NUM)
151 # ---------------------------------
152 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
154 m4_define([b4_rhs_location
],
155 [(yylsp@
{($
2) - ($
1)@
})])
158 ## ------------------ ##
159 ## Parser variables. ##
160 ## ------------------ ##
162 # b4_declare_scanner_communication_variables
163 # ------------------------------------------
164 # Declare the variables that are global, or local to YYPARSE if
166 m4_define([b4_declare_scanner_communication_variables
], [[
167 /* The lookahead symbol. */
170 /* The semantic value of the lookahead symbol. */
171 YYSTYPE yylval
;]b4_locations_if([[
173 /* Location data for the lookahead symbol. */
174 YYLTYPE yylloc
;]])b4_pure_if([], [[
176 /* Number of syntax errors so far. */
180 # b4_declare_parser_state_variables
181 # ---------------------------------
182 # Declare all the variables that are needed to maintain the parser state
183 # between calls to yypush_parse.
184 m4_define([b4_declare_parser_state_variables
], [b4_pure_if([[
185 /* Number of syntax errors so far. */
189 /* Number of tokens to shift before error messages enabled. */
192 /* The stacks and their tools:
193 `yyss': related to states.
194 `yyvs': related to semantic values.]b4_locations_if([[
195 `yyls': related to locations.]])[
197 Refer to the stacks thru separate pointers, to allow yyoverflow
198 to reallocate them elsewhere. */
200 /* The state stack. */
201 yytype_int16 yyssa
[YYINITDEPTH
];
205 /* The semantic value stack. */
206 YYSTYPE yyvsa
[YYINITDEPTH
];
208 YYSTYPE
*yyvsp
;]b4_locations_if([[
210 /* The location stack. */
211 YYLTYPE yylsa
[YYINITDEPTH
];
215 /* The locations where the error started and ended. */
216 YYLTYPE yyerror_range
[3];]])[
218 YYSIZE_T yystacksize
;]])
221 ## --------------------------------------------------------- ##
222 ## Defining symbol actions, e.g., printers and destructors. ##
223 ## --------------------------------------------------------- ##
225 # We do want M4 expansion after # for CPP macros.
228 @
output(b4_parser_file_name@
)@
229 b4_copyright([Skeleton implementation
for Bison
's Yacc-like parsers in C],
230 [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010])[
232 /* C LALR(1) parser skeleton written by Richard Stallman, by
233 simplifying the original so-called "semantic" parser. */
235 /* All symbols defined below should begin with yy or YY, to avoid
236 infringing on user name space. This should be done even for local
237 variables, as they might otherwise be expanded by user macros.
238 There are some unavoidable exceptions within include files to
239 define necessary library symbols; they are noted "INFRINGES ON
240 USER NAME SPACE" below. */
243 b4_percent_code_get([[top]])[]dnl
244 m4_if(b4_prefix, [yy], [],
245 [[/* Substitute the variable and function names. */]b4_pull_if([[
246 #define yyparse ]b4_prefix[parse]])b4_push_if([[
247 #define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[
248 #define yypull_parse ]b4_prefix[pull_parse]])[
249 #define yypstate_new ]b4_prefix[pstate_new
250 #define yypstate_delete ]b4_prefix[pstate_delete
251 #define yypstate ]b4_prefix[pstate]])[
252 #define yylex ]b4_prefix[lex
253 #define yyerror ]b4_prefix[error
254 #define yylval ]b4_prefix[lval
255 #define yychar ]b4_prefix[char
256 #define yydebug ]b4_prefix[debug
257 #define yynerrs ]b4_prefix[nerrs
258 ]b4_locations_if([[#define yylloc ]b4_prefix[lloc]])])[
260 /* Copy the first part of user declarations. */
261 ]b4_user_pre_prologue[
263 /* Enabling traces. */
265 # define YYDEBUG ]b4_debug_flag[
268 /* Enabling verbose error messages. */
269 #ifdef YYERROR_VERBOSE
270 # undef YYERROR_VERBOSE
271 # define YYERROR_VERBOSE 1
273 # define YYERROR_VERBOSE ]b4_error_verbose_flag[
276 /* Enabling the token table. */
277 #ifndef YYTOKEN_TABLE
278 # define YYTOKEN_TABLE ]b4_token_table[
281 ]b4_percent_code_get([[requires]])[]dnl
283 b4_token_enums_defines(b4_tokens)[
285 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
286 ]m4_ifdef([b4_stype],
287 [[typedef union ]b4_union_name[
291 # define YYSTYPE_IS_TRIVIAL 1]],
292 [m4_if(b4_tag_seen_flag, 0,
293 [[typedef int YYSTYPE;
294 # define YYSTYPE_IS_TRIVIAL 1]])])[
295 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
296 # define YYSTYPE_IS_DECLARED 1
297 #endif]b4_locations_if([[
299 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
300 typedef struct YYLTYPE
307 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
308 # define YYLTYPE_IS_DECLARED 1
309 # define YYLTYPE_IS_TRIVIAL 1
310 #endif]])b4_push_if([[
313 # define YYPUSH_DECLS
315 typedef struct yypstate yypstate;
316 enum { YYPUSH_MORE = 4 };
318 ]b4_pull_if([b4_c_function_decl([[yyparse]], [[int]], b4_parse_param)
319 ])b4_c_function_decl([[yypush_parse]], [[int]],
320 [[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
321 [[[int yypushed_char]], [[yypushed_char]]],
322 [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
323 [[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
325 b4_pull_if([b4_c_function_decl([[yypull_parse]], [[int]],
326 [[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
328 b4_c_function_decl([[yypstate_new]], [[yypstate *]], [[[void]], []])
329 b4_c_function_decl([[yypstate_delete]], [[void]],
330 [[[yypstate *yyps]], [[yyps]]])[
333 b4_percent_code_get([[provides]])[]dnl
335 [/* Copy the second part of user declarations. */
336 ]b4_user_post_prologue
337 b4_percent_code_get[]dnl
344 typedef YYTYPE_UINT8 yytype_uint8;
346 typedef unsigned char yytype_uint8;
350 typedef YYTYPE_INT8 yytype_int8;
352 typedef signed char yytype_int8;
354 typedef short int yytype_int8;
358 typedef YYTYPE_UINT16 yytype_uint16;
360 typedef unsigned short int yytype_uint16;
364 typedef YYTYPE_INT16 yytype_int16;
366 typedef short int yytype_int16;
370 # ifdef __SIZE_TYPE__
371 # define YYSIZE_T __SIZE_TYPE__
372 # elif defined size_t
373 # define YYSIZE_T size_t
374 # elif ! defined YYSIZE_T && ]b4_c_modern[
375 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
376 # define YYSIZE_T size_t
378 # define YYSIZE_T unsigned int
382 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
385 # if defined YYENABLE_NLS && YYENABLE_NLS
387 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
388 # define YY_(msgid) dgettext ("bison-runtime", msgid)
392 # define YY_(msgid) msgid
396 /* Suppress unused-variable warnings by "using" E. */
397 #if ! defined lint || defined __GNUC__
398 # define YYUSE(e) ((void) (e))
400 # define YYUSE(e) /* empty */
403 /* Identity function, used to suppress warnings about constant conditions. */
407 ]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[
413 #if ! defined yyoverflow || YYERROR_VERBOSE
416 [[/* The parser invokes alloca or malloc; define the necessary symbols. */
418 # ifdef YYSTACK_USE_ALLOCA
419 # if YYSTACK_USE_ALLOCA
421 # define YYSTACK_ALLOC __builtin_alloca
422 # elif defined __BUILTIN_VA_ARG_INCR
423 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
425 # define YYSTACK_ALLOC __alloca
426 # elif defined _MSC_VER
427 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
428 # define alloca _alloca
430 # define YYSTACK_ALLOC alloca
431 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && ]b4_c_modern[
432 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
433 # ifndef EXIT_SUCCESS
434 # define EXIT_SUCCESS 0
442 [# ifdef YYSTACK_ALLOC
443 /* Pacify GCC's `empty
if-body
' warning. */
444 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
445 # ifndef YYSTACK_ALLOC_MAXIMUM
446 /* The OS might guarantee only one guard page at the bottom of the stack,
447 and a page size can be as small as 4096 bytes. So we cannot safely
448 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
449 to allow for a few compiler-allocated temporary stack slots. */
450 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
453 # define YYSTACK_ALLOC YYMALLOC
454 # define YYSTACK_FREE YYFREE
455 # ifndef YYSTACK_ALLOC_MAXIMUM
456 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
458 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
459 && ! ((defined YYMALLOC || defined malloc) \
460 && (defined YYFREE || defined free)))
461 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
462 # ifndef EXIT_SUCCESS
463 # define EXIT_SUCCESS 0
467 # define YYMALLOC malloc
468 # if ! defined malloc && ! defined EXIT_SUCCESS && ]b4_c_modern[
469 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
474 # if ! defined free && ! defined EXIT_SUCCESS && ]b4_c_modern[
475 void free (void *); /* INFRINGES ON USER NAME SPACE */
479 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
482 #if (! defined yyoverflow \
483 && (! defined __cplusplus \
484 || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
485 && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
487 /* A type that is properly aligned for any stack member. */
490 yytype_int16 yyss_alloc;
491 YYSTYPE yyvs_alloc;]b4_locations_if([
492 YYLTYPE yyls_alloc;])[
495 /* The size of the maximum gap between one aligned stack and the next. */
496 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
498 /* The size of an array large to enough to hold all stacks, each with
501 [# define YYSTACK_BYTES(N) \
502 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
503 + 2 * YYSTACK_GAP_MAXIMUM)],
504 [# define YYSTACK_BYTES(N) \
505 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
506 + YYSTACK_GAP_MAXIMUM)])[
508 /* Copy COUNT objects from FROM to TO. The source and destination do
511 # if defined __GNUC__ && 1 < __GNUC__
512 # define YYCOPY(To, From, Count) \
513 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
515 # define YYCOPY(To, From, Count) \
519 for (yyi = 0; yyi < (Count); yyi++) \
520 (To)[yyi] = (From)[yyi]; \
526 /* Relocate STACK from its old location to the new one. The
527 local variables YYSIZE and YYSTACKSIZE give the old and new number of
528 elements in the stack, and YYPTR gives the new location of the
529 stack. Advance YYPTR to a properly aligned location for the next
531 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
534 YYSIZE_T yynewbytes; \
535 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
536 Stack = &yyptr->Stack_alloc; \
537 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
538 yyptr += yynewbytes / sizeof (*yyptr); \
544 /* YYFINAL -- State number of the termination state. */
545 #define YYFINAL ]b4_final_state_number[
546 /* YYLAST -- Last index in YYTABLE. */
547 #define YYLAST ]b4_last[
549 /* YYNTOKENS -- Number of terminals. */
550 #define YYNTOKENS ]b4_tokens_number[
551 /* YYNNTS -- Number of nonterminals. */
552 #define YYNNTS ]b4_nterms_number[
553 /* YYNRULES -- Number of rules. */
554 #define YYNRULES ]b4_rules_number[
555 /* YYNRULES -- Number of states. */
556 #define YYNSTATES ]b4_states_number[
558 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
559 #define YYUNDEFTOK ]b4_undef_token_number[
560 #define YYMAXUTOK ]b4_user_token_number_max[
562 #define YYTRANSLATE(YYX) \
563 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
565 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
566 static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
572 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
574 static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
579 /* YYRHS -- A `-1'-separated list of the rules
' RHS. */
580 static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
585 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
586 static const ]b4_int_type_for([b4_rline])[ yyrline[] =
592 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
593 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
594 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
595 static const char *const yytname[] =
602 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
604 static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
610 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
611 static const ]b4_int_type_for([b4_r1])[ yyr1[] =
616 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
617 static const ]b4_int_type_for([b4_r2])[ yyr2[] =
622 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
623 Performed when YYTABLE doesn't specify something
else to
do. Zero
624 means the
default is an error
. */
625 static const ]b4_int_type_for([b4_defact
])[ yydefact
[] =
630 /* YYDEFGOTO[NTERM-NUM]. */
631 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto
[] =
636 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
638 #define YYPACT_NINF ]b4_pact_ninf[
639 static const ]b4_int_type_for([b4_pact
])[ yypact
[] =
644 /* YYPGOTO[NTERM-NUM]. */
645 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto
[] =
650 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
651 positive, shift that token. If negative, reduce the rule which
652 number is the opposite. If YYTABLE_NINF, syntax error. */
653 #define YYTABLE_NINF ]b4_table_ninf[
654 static const ]b4_int_type_for([b4_table
])[ yytable
[] =
659 #define yypact_value_is_default(yystate) \
660 ]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
662 #define yytable_value_is_error(yytable_value) \
663 ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
665 static const ]b4_int_type_for([b4_check
])[ yycheck
[] =
670 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
671 symbol of state STATE-NUM. */
672 static const ]b4_int_type_for([b4_stos
])[ yystos
[] =
677 #define yyerrok (yyerrstatus = 0)
678 #define yyclearin (yychar = YYEMPTY)
682 #define YYACCEPT goto yyacceptlab
683 #define YYABORT goto yyabortlab
684 #define YYERROR goto yyerrorlab
687 /* Like YYERROR except do call yyerror. This remains here temporarily
688 to ease the transition to the new meaning of YYERROR, for GCC.
689 Once GCC version 2 has supplanted version 1, this can go. However,
690 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
691 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
694 #define YYFAIL goto yyerrlab
696 /* This is here to suppress warnings from the GCC cpp's
697 -Wunused-macros. Normally we don't worry about that warning, but
698 some users do, and we want to make it easy for users to remove
699 YYFAIL uses, which will produce warnings from Bison 2.5. */
702 #define YYRECOVERING() (!!yyerrstatus)
704 #define YYBACKUP(Token, Value) \
706 if (yychar == YYEMPTY && yylen == 1) \
710 YYPOPSTACK (1); \]b4_lac_if([[
711 YY_LAC_DISCARD ("YYBACKUP"); \
]])[
716 yyerror (]b4_yyerror_args
[YY_("syntax error: cannot back up")); \
723 #define YYERRCODE 256
726 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
727 If N is 0, then set CURRENT to the empty location which ends
728 the previous symbol: RHS[0] (always defined). */
730 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
731 #ifndef YYLLOC_DEFAULT
732 # define YYLLOC_DEFAULT(Current, Rhs, N) \
736 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
737 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
738 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
739 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
743 (Current).first_line = (Current).last_line = \
744 YYRHSLOC (Rhs, 0).last_line; \
745 (Current).first_column = (Current).last_column = \
746 YYRHSLOC (Rhs, 0).last_column; \
749 #endif]b4_locations_if([[
752 /* YY_LOCATION_PRINT -- Print the location on the stream.
753 This macro was not mandated originally: define only if we know
754 we won't break user code: when these are the locations we know. */
756 #ifndef YY_LOCATION_PRINT
757 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
758 # define YY_LOCATION_PRINT(File, Loc) \
759 fprintf (File, "%d.%d-%d.%d", \
760 (Loc).first_line, (Loc).first_column, \
761 (Loc).last_line, (Loc).last_column)
763 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
768 /* This macro is provided for backward compatibility. */
770 #ifndef YY_LOCATION_PRINT
771 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
775 /* YYLEX -- calling `yylex' with the right arguments. */
778 # define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM)
780 # define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
783 /* Enable debugging if requested. */
787 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
788 # define YYFPRINTF fprintf
791 # define YYDPRINTF(Args) \
797 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
801 YYFPRINTF (stderr, "%s ", Title); \
802 yy_symbol_print (stderr, \
803 Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
804 YYFPRINTF (stderr, "\n"); \
808 ]b4_yy_symbol_print_generate([b4_c_function_def
])[
810 /*------------------------------------------------------------------.
811 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
813 `------------------------------------------------------------------*/
815 ]b4_c_function_def([yy_stack_print
], [static void],
816 [[yytype_int16
*yybottom
], [yybottom
]],
817 [[yytype_int16
*yytop
], [yytop
]])[
819 YYFPRINTF (stderr
, "Stack now");
820 for (; yybottom
<= yytop
; yybottom
++)
822 int yybot
= *yybottom
;
823 YYFPRINTF (stderr
, " %d", yybot
);
825 YYFPRINTF (stderr
, "\n");
828 # define YY_STACK_PRINT(Bottom, Top) \
831 yy_stack_print ((Bottom), (Top)); \
835 /*------------------------------------------------.
836 | Report that the YYRULE is going to be reduced. |
837 `------------------------------------------------*/
839 ]b4_c_function_def([yy_reduce_print
], [static void],
840 [[YYSTYPE
*yyvsp
], [yyvsp
]],
841 b4_locations_if([[[YYLTYPE
*yylsp
], [yylsp
]],
842 ])[[int yyrule
], [yyrule
]]m4_ifset([b4_parse_param
], [,
845 int yynrhs
= yyr2
[yyrule
];
847 unsigned long int yylno
= yyrline
[yyrule
];
848 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
850 /* The symbols being reduced. */
851 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
853 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
854 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
855 &]b4_rhs_value(yynrhs
, yyi
+ 1)[
856 ]b4_locations_if([, &]b4_rhs_location(yynrhs
, yyi
+ 1))[]dnl
858 YYFPRINTF (stderr
, "\n");
862 # define YY_REDUCE_PRINT(Rule) \
865 yy_reduce_print (yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
868 /* Nonzero means print parse trace. It is left uninitialized so that
869 multiple parsers can coexist. */
872 # define YYDPRINTF(Args)
873 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
874 # define YY_STACK_PRINT(Bottom, Top)
875 # define YY_REDUCE_PRINT(Rule)
876 #endif /* !YYDEBUG */
879 /* YYINITDEPTH -- initial size of the parser's stacks. */
881 # define YYINITDEPTH ]b4_stack_depth_init[
884 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
885 if the built-in stack extension method is used).
887 Do not make this value too large; the results are undefined if
888 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
889 evaluated with infinite-precision integer arithmetic. */
892 # define YYMAXDEPTH ]b4_stack_depth_max[
895 /* Establish the initial context for the current lookahead if no initial
896 context is currently established.
898 We define a context as a snapshot of the parser stacks. We define
899 the initial context for a lookahead as the context in which the
900 parser initially examines that lookahead in order to select a
901 syntactic action. Thus, if the lookahead eventually proves
902 syntactically unacceptable (possibly in a later context reached via a
903 series of reductions), the initial context can be used to determine
904 the exact set of tokens that would be syntactically acceptable in the
905 lookahead's place. Moreover, it is the context after which any
906 further semantic actions would be erroneous because they would be
907 determined by a syntactically unacceptable token.
909 YY_LAC_ESTABLISH should be invoked when a reduction is about to be
910 performed in an inconsistent state (which, for the purposes of LAC,
911 includes consistent states that don't know they're consistent because
912 their default reductions have been disabled). Iff there is a
913 lookahead token, it should also be invoked before reporting a syntax
914 error. This latter case is for the sake of the debugging output.
916 For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
917 follows. If no initial context is currently established for the
918 current lookahead, then check if that lookahead can eventually be
919 shifted if syntactic actions continue from the current context.
920 Report a syntax error if it cannot. */
921 #define YY_LAC_ESTABLISH \
923 if (!yy_lac_established) \
925 YYDPRINTF ((stderr, \
926 "LAC: initial context established for %s\n", \
927 yytname[yytoken])); \
928 yy_lac_established = 1; \
930 int yy_lac_status = \
931 yy_lac (yyssp, yytoken); \
932 if (yy_lac_status == 2) \
933 goto yyexhaustedlab; \
934 if (yy_lac_status == 1) \
940 /* Discard any previous initial lookahead context because of Event,
941 which may be a lookahead change or an invalidation of the currently
942 established initial context for the current lookahead.
944 The most common example of a lookahead change is a shift. An example
945 of both cases is syntax error recovery. That is, a syntax error
946 occurs when the lookahead is syntactically erroneous for the
947 currently established initial context, so error recovery manipulates
948 the parser stacks to try to find a new initial context in which the
949 current lookahead is syntactically acceptable. If it fails to find
950 such a context, it discards the lookahead. */
952 # define YY_LAC_DISCARD(Event) \
954 if (yy_lac_established) \
957 YYFPRINTF (stderr, "LAC: initial context discarded due to " \
959 yy_lac_established = 0; \
963 # define YY_LAC_DISCARD(Event) yy_lac_established = 0
966 /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
967 eventually (after perhaps some reductions) be shifted, and return 1
968 if not. Return 2 if memory is exhausted. */
970 yy_lac (yytype_int16
*yyssp
, int yytoken
)
972 yytype_int16
*yyes_prev
= yyssp
;
973 yytype_int16 yyes@
{]b4_percent_define_get([[parse
.lac
.es
-capacity
]])[@
};
974 yytype_int16
*yyesp
= yyes_prev
;
975 YYDPRINTF ((stderr
, "LAC: checking lookahead %s:", yytname
[yytoken
]));
976 if (yytoken
== YYUNDEFTOK
)
978 YYDPRINTF ((stderr
, " Always Err\n"));
983 int yyrule
= yypact
[*yyesp
];
984 if (yypact_value_is_default (yyrule
)
985 || (yyrule
+= yytoken
) < 0 || YYLAST
< yyrule
986 || yycheck
[yyrule
] != yytoken
)
988 yyrule
= yydefact
[*yyesp
];
991 YYDPRINTF ((stderr
, " Err\n"));
997 yyrule
= yytable
[yyrule
];
998 if (yytable_value_is_error (yyrule
))
1000 YYDPRINTF ((stderr
, " Err\n"));
1005 YYDPRINTF ((stderr
, " S%d\n", yyrule
));
1011 YYSIZE_T yylen
= yyr2
[yyrule
];
1012 YYDPRINTF ((stderr
, " R%d", yyrule
- 1));
1013 if (yyesp
!= yyes_prev
)
1015 YYSIZE_T yysize
= yyesp
- yyes
+ 1;
1028 yyesp
= yyes_prev
-= yylen
;
1033 int yylhs
= yyr1
[yyrule
] - YYNTOKENS
;
1034 yystate
= yypgoto
[yylhs
] + *yyesp
;
1035 if (yystate
< 0 || YYLAST
< yystate
1036 || yycheck
[yystate
] != *yyesp
)
1037 yystate
= yydefgoto
[yylhs
];
1039 yystate
= yytable
[yystate
];
1041 if (yyesp
== yyes_prev
)
1048 if (yyesp
== yyes
+ (sizeof yyes
/ sizeof *yyes
) - 1)
1050 YYDPRINTF ((stderr
, " (max stack size exceeded)\n"));
1055 YYDPRINTF ((stderr
, " G%d", *yyesp
));
1064 # if defined __GLIBC__ && defined _STRING_H
1065 # define yystrlen strlen
1067 /* Return the length of YYSTR. */
1068 ]b4_c_function_def([yystrlen
], [static YYSIZE_T
],
1069 [[const char *yystr
], [yystr
]])[
1072 for (yylen
= 0; yystr
[yylen
]; yylen
++)
1080 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1081 # define yystpcpy stpcpy
1083 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1085 ]b4_c_function_def([yystpcpy
], [static char *],
1086 [[char *yydest
], [yydest
]], [[const char *yysrc
], [yysrc
]])[
1089 const char *yys
= yysrc
;
1091 while ((*yyd
++ = *yys
++) != '\0')
1100 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1101 quotes and backslashes, so that it's suitable for yyerror. The
1102 heuristic is that double-quoting is unnecessary unless the string
1103 contains an apostrophe, a comma, or backslash (other than
1104 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1105 null, do not copy; instead, return the length of what the result
1108 yytnamerr (char *yyres
, const char *yystr
)
1113 char const *yyp
= yystr
;
1120 goto do_not_strip_quotes
;
1124 goto do_not_strip_quotes
;
1137 do_not_strip_quotes
: ;
1141 return yystrlen (yystr
);
1143 return yystpcpy (yyres
, yystr
) - yyres
;
1147 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1148 about the unexpected token YYTOKEN for the state stack whose top is
1149 YYSSP.]b4_lac_if([[ In order to see if a particular token T is a
1150 valid looakhead, invoke yy_lac (YYSSP, T).]])[
1152 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1153 not large enough to hold the message. In that case, also set
1154 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1155 required number of bytes is too large to store]b4_lac_if([[ or if
1156 yy_lac returned 2]])[. */
1158 yysyntax_error (YYSIZE_T
*yymsg_alloc
, char **yymsg
,
1159 yytype_int16
*yyssp
, int yytoken
)
1161 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytoken
]);
1162 YYSIZE_T yysize
= yysize0
;
1164 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1165 /* Internationalized format string. */
1166 const char *yyformat
= 0;
1167 /* Arguments of yyformat. */
1168 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1169 /* Number of reported tokens (one for the "unexpected", one per
1173 /* There are many possibilities here to consider:
1174 - Assume YYFAIL is not used. It's too flawed to consider. See
1175 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1176 for details. YYERROR is fine as it does not invoke this
1178 - If this state is a consistent state with a default action, then
1179 the only way this function was invoked is if the default action
1180 is an error action. In that case, don't check for expected
1181 tokens because there are none.
1182 - The only way there can be no lookahead present (in yychar) is if
1183 this state is a consistent state with a default action. Thus,
1184 detecting the absence of a lookahead is sufficient to determine
1185 that there is no unexpected or expected token to report. In that
1186 case, just report a simple "syntax error".
1187 - Don't assume there isn't a lookahead just because this state is a
1188 consistent state with a default action. There might have been a
1189 previous inconsistent state, consistent state with a non-default
1190 action, or user semantic action that manipulated yychar.]b4_lac_if([[
1191 In the first two cases, it might appear that the current syntax
1192 error should have been detected in the previous state when yy_lac
1193 was invoked. However, at that time, there might have been a
1194 different syntax error that discarded a different initial context
1195 during error recovery, leaving behind the current lookahead.]], [[
1196 - Of course, the expected token list depends on states to have
1197 correct lookahead information, and it depends on the parser not
1198 to perform extra reductions after fetching a lookahead from the
1199 scanner and before detecting a syntax error. Thus, state merging
1200 (from LALR or IELR) and default reductions corrupt the expected
1201 token list. However, the list is correct for canonical LR with
1202 one exception: it will still contain any token that will not be
1203 accepted due to an error action in a later state.]])[
1205 if (yytoken
!= YYEMPTY
)
1207 int yyn
= yypact
[*yyssp
];]b4_lac_if([[
1208 YYDPRINTF ((stderr
, "Constructing syntax error message\n"));]])[
1209 yyarg
[yycount
++] = yytname
[yytoken
];
1210 if (!yypact_value_is_default (yyn
))
1212 /* Start YYX at -YYN if negative to avoid negative indexes in
1213 YYCHECK. In other words, skip the first -YYN actions for
1214 this state because they are default actions. */
1215 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1216 /* Stay within bounds of both yycheck and yytname. */
1217 int yychecklim
= YYLAST
- yyn
+ 1;
1218 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;]])[
1219 int yyx
;]b4_lac_if([[
1221 for (yyx
= 0; yyx
< YYNTOKENS
; ++yyx
)
1222 if (yyx
!= YYTERROR
&& yyx
!= YYUNDEFTOK
)
1225 int yy_lac_status
= yy_lac (yyssp
, yyx
);
1226 if (yy_lac_status
== 2)
1228 if (yy_lac_status
== 1)
1232 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1233 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
1234 && !yytable_value_is_error (yytable
[yyx
+ yyn
]))
1236 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1242 yyarg
[yycount
++] = yytname
[yyx
];
1243 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1244 if (! (yysize
<= yysize1
1245 && yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1252 YYFPRINTF (stderr
, "No expected tokens.\n");
1258 # define YYCASE_(N, S) \
1262 YYCASE_(0, YY_("syntax error"));
1263 YYCASE_(1, YY_("syntax error, unexpected %s"));
1264 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1265 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1266 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1267 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1271 yysize1
= yysize
+ yystrlen (yyformat
);
1272 if (! (yysize
<= yysize1
&& yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1276 if (*yymsg_alloc
< yysize
)
1278 *yymsg_alloc
= 2 * yysize
;
1279 if (! (yysize
<= *yymsg_alloc
1280 && *yymsg_alloc
<= YYSTACK_ALLOC_MAXIMUM
))
1281 *yymsg_alloc
= YYSTACK_ALLOC_MAXIMUM
;
1285 /* Avoid sprintf, as that infringes on the user's name space.
1286 Don't have undefined behavior even if the translation
1287 produced a string with the wrong number of "%s"s. */
1291 while ((*yyp
= *yyformat
) != '\0')
1292 if (*yyp
== '%' && yyformat
[1] == 's' && yyi
< yycount
)
1294 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1305 #endif /* YYERROR_VERBOSE */
1307 ]b4_yydestruct_generate([b4_c_function_def
])b4_push_if([], [[
1310 /* Prevent warnings from -Wmissing-prototypes. */
1311 #ifdef YYPARSE_PARAM
1312 ]b4_c_function_decl([yyparse
], [int],
1313 [[void *YYPARSE_PARAM
], [YYPARSE_PARAM
]])[
1314 #else /* ! YYPARSE_PARAM */
1315 ]b4_c_function_decl([yyparse
], [int], b4_parse_param
)[
1316 #endif /* ! YYPARSE_PARAM */]])b4_pure_if([], [
1318 b4_declare_scanner_communication_variables
])[]b4_push_if([[
1322 {]b4_declare_parser_state_variables
[
1323 /* Used to determine if this is the first time this instance has
1326 };]b4_pure_if([], [[
1328 static char yypstate_allocated
= 0;]])b4_pull_if([
1330 b4_c_function_def([[yyparse]], [[int]], b4_parse_param
)[
1332 return yypull_parse (0]m4_ifset([b4_parse_param
],
1333 [[, ]b4_c_args(b4_parse_param
)])[);
1336 ]b4_c_function_def([[yypull_parse]], [[int]],
1337 [[[yypstate
*yyps
]], [[yyps]]]m4_ifset([b4_parse_param
], [,
1341 yypstate
*yyps_local
;]b4_pure_if([[
1343 YYSTYPE yylval
;]b4_locations_if([[
1344 YYLTYPE yylloc
;]])])[
1347 yyps_local
= yypstate_new ();
1350 yyerror (]b4_yyerror_args
[YY_("memory exhausted"));]], [[
1351 if (!yypstate_allocated
)
1352 yyerror (]b4_yyerror_args
[YY_("memory exhausted"));]])[
1361 yypush_parse (yyps_local
]b4_pure_if([[, yychar
, &yylval
]b4_locations_if([[, &yylloc
]])])m4_ifset([b4_parse_param
], [, b4_c_args(b4_parse_param
)])[);
1362 } while (yystatus
== YYPUSH_MORE
);
1364 yypstate_delete (yyps_local
);
1368 /* Initialize the parser data structure. */
1369 ]b4_c_function_def([[yypstate_new]], [[yypstate
*]])[
1371 yypstate
*yyps
;]b4_pure_if([], [[
1372 if (yypstate_allocated
)
1374 yyps
= (yypstate
*) malloc (sizeof *yyps
);
1377 yyps
->yynew
= 1;]b4_pure_if([], [[
1378 yypstate_allocated
= 1;]])[
1382 ]b4_c_function_def([[yypstate_delete]], [[void]],
1383 [[[yypstate
*yyps
]], [[yyps]]])[
1386 /* If the stack was reallocated but the parse did not complete, then the
1387 stack still needs to be freed. */
1388 if (!yyps
->yynew
&& yyps
->yyss
!= yyps
->yyssa
)
1389 YYSTACK_FREE (yyps
->yyss
);
1391 free (yyps
);]b4_pure_if([], [[
1392 yypstate_allocated
= 0;]])[
1395 #define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs]])[
1396 #define yystate yyps->yystate
1397 #define yyerrstatus yyps->yyerrstatus
1398 #define yyssa yyps->yyssa
1399 #define yyss yyps->yyss
1400 #define yyssp yyps->yyssp
1401 #define yyvsa yyps->yyvsa
1402 #define yyvs yyps->yyvs
1403 #define yyvsp yyps->yyvsp]b4_locations_if([[
1404 #define yylsa yyps->yylsa
1405 #define yyls yyps->yyls
1406 #define yylsp yyps->yylsp
1407 #define yyerror_range yyps->yyerror_range]])[
1408 #define yystacksize yyps->yystacksize
1415 ]b4_c_function_def([[yypush_parse]], [[int]],
1416 [[[yypstate
*yyps
]], [[yyps]]]b4_pure_if([,
1417 [[[int yypushed_char]], [[yypushed_char]]],
1418 [[[YYSTYPE
const *yypushed_val
]], [[yypushed_val]]]b4_locations_if([,
1419 [[[YYLTYPE
const *yypushed_loc
]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param
], [,
1420 b4_parse_param
]))], [[
1427 #ifdef YYPARSE_PARAM
1428 ]b4_c_function_def([yyparse
], [int],
1429 [[void *YYPARSE_PARAM
], [YYPARSE_PARAM
]])[
1430 #else /* ! YYPARSE_PARAM */
1431 ]b4_c_function_def([yyparse
], [int], b4_parse_param
)[
1433 {]b4_pure_if([b4_declare_scanner_communication_variables
1434 ])b4_push_if([b4_pure_if([], [[
1435 int yypushed_char
= yychar
;
1436 YYSTYPE yypushed_val
= yylval
;]b4_locations_if([[
1437 YYLTYPE yypushed_loc
= yylloc
;]])
1439 [b4_declare_parser_state_variables
1441 int yy_lac_established
= 0;]])[
1444 /* Lookahead token as an internal (translated) token number. */
1446 /* The variables used to return semantic value and location from the
1448 YYSTYPE yyval
;]b4_locations_if([[
1452 /* Buffer for error messages, and its allocated size. */
1454 char *yymsg
= yymsgbuf
;
1455 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1458 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[)
1460 /* The number of symbols on the RHS of the reduced rule.
1461 Keep to zero when no symbol should be popped. */
1462 int yylen
= 0;]b4_push_if([[
1466 yyn
= yypact
[yystate
];
1467 goto yyread_pushed_token
;
1472 yyvs
= yyvsa
;]b4_locations_if([[
1474 yystacksize
= YYINITDEPTH
;
1476 YYDPRINTF ((stderr
, "Starting parse\n"));
1481 yychar
= YYEMPTY
; /* Cause a token to be read. */
1483 /* Initialize stack pointers.
1484 Waste one element of value and location stack
1485 so that they stay on the same level as the state stack.
1486 The wasted elements are never initialized. */
1488 yyvsp
= yyvs
;]b4_locations_if([[
1491 #if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1492 /* Initialize the default location before parsing starts. */
1493 yylloc
.first_line
= yylloc
.last_line
= ]b4_location_initial_line
[;
1494 yylloc
.first_column
= yylloc
.last_column
= ]b4_location_initial_column
[;
1496 m4_ifdef([b4_initial_action
],[
1497 m4_pushdef([b4_at_dollar
], [m4_define([b4_at_dollar_used
])yylloc
])dnl
1498 m4_pushdef([b4_dollar_dollar
], [m4_define([b4_dollar_dollar_used
])yylval
])dnl
1499 /* User initialization code. */
1500 b4_user_initial_action
1501 m4_popdef([b4_dollar_dollar
])dnl
1502 m4_popdef([b4_at_dollar
])])dnl
1503 m4_ifdef([b4_dollar_dollar_used
],[[ yyvsp
[0] = yylval
;
1505 m4_ifdef([b4_at_dollar_used
], [[ yylsp
[0] = yylloc
;
1509 /*------------------------------------------------------------.
1510 | yynewstate -- Push a new state, which is found in yystate. |
1511 `------------------------------------------------------------*/
1513 /* In all cases, when you get here, the value and location stacks
1514 have just been pushed. So pushing a state here evens the stacks. */
1520 if (yyss
+ yystacksize
- 1 <= yyssp
)
1522 /* Get the current used size of the three stacks, in elements. */
1523 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1527 /* Give user a chance to reallocate the stack. Use copies of
1528 these so that the &'s don't force the real ones into
1530 YYSTYPE
*yyvs1
= yyvs
;
1531 yytype_int16
*yyss1
= yyss
;]b4_locations_if([
1532 YYLTYPE
*yyls1
= yyls
;])[
1534 /* Each stack pointer address is followed by the size of the
1535 data in use in that stack, in bytes. This used to be a
1536 conditional around just the two extra args, but that might
1537 be undefined if yyoverflow is a macro. */
1538 yyoverflow (YY_("memory exhausted"),
1539 &yyss1
, yysize
* sizeof (*yyssp
),
1540 &yyvs1
, yysize
* sizeof (*yyvsp
),]b4_locations_if([
1541 &yyls1
, yysize
* sizeof (*yylsp
),])[
1548 #else /* no yyoverflow */
1549 # ifndef YYSTACK_RELOCATE
1550 goto yyexhaustedlab
;
1552 /* Extend the stack our own way. */
1553 if (YYMAXDEPTH
<= yystacksize
)
1554 goto yyexhaustedlab
;
1556 if (YYMAXDEPTH
< yystacksize
)
1557 yystacksize
= YYMAXDEPTH
;
1560 yytype_int16
*yyss1
= yyss
;
1561 union yyalloc
*yyptr
=
1562 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1564 goto yyexhaustedlab
;
1565 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1566 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);]b4_locations_if([
1567 YYSTACK_RELOCATE (yyls_alloc
, yyls
);])[
1568 # undef YYSTACK_RELOCATE
1570 YYSTACK_FREE (yyss1
);
1573 #endif /* no yyoverflow */
1575 yyssp
= yyss
+ yysize
- 1;
1576 yyvsp
= yyvs
+ yysize
- 1;]b4_locations_if([
1577 yylsp
= yyls
+ yysize
- 1;])[
1579 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1580 (unsigned long int) yystacksize
));
1582 if (yyss
+ yystacksize
- 1 <= yyssp
)
1586 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1588 if (yystate
== YYFINAL
)
1598 /* Do appropriate processing given the current state. Read a
1599 lookahead token if we need one and don't already have one. */
1601 /* First try to decide what to do without reference to lookahead token. */
1602 yyn
= yypact
[yystate
];
1603 if (yypact_value_is_default (yyn
))
1606 /* Not known => get a lookahead token if don't already have one. */
1608 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1609 if (yychar
== YYEMPTY
)
1612 {]b4_use_push_for_pull_if([], [[
1613 YYDPRINTF ((stderr
, "Return for a new token:\n"));]])[
1614 yyresult
= YYPUSH_MORE
;
1617 yyps
->yynew
= 0;]b4_pure_if([], [[
1618 /* Restoring the pushed token is only necessary for the first
1619 yypush_parse invocation since subsequent invocations don't overwrite
1620 it before jumping to yyread_pushed_token. */
1621 yychar
= yypushed_char
;
1622 yylval
= yypushed_val
;]b4_locations_if([[
1623 yylloc
= yypushed_loc
;]])])[
1624 yyread_pushed_token
:]])[
1625 YYDPRINTF ((stderr
, "Reading a token: "));]b4_push_if([b4_pure_if([[
1626 yychar
= yypushed_char
;
1628 yylval
= *yypushed_val
;]b4_locations_if([[
1630 yylloc
= *yypushed_loc
;]])])], [[
1634 if (yychar
<= YYEOF
)
1636 yychar
= yytoken
= YYEOF
;
1637 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1641 yytoken
= YYTRANSLATE (yychar
);
1642 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1645 /* If the proper action on seeing token YYTOKEN is to reduce or to
1646 detect an error, take that action. */
1648 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)]b4_lac_if([[
1657 if (yytable_value_is_error (yyn
))
1658 goto yyerrlab
;]b4_lac_if([[
1659 YY_LAC_ESTABLISH
;]])[
1664 /* Count tokens shifted since error; after three, turn off error
1669 /* Shift the lookahead token. */
1670 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1672 /* Discard the shifted token. */
1673 yychar
= YYEMPTY
;]b4_lac_if([[
1674 YY_LAC_DISCARD ("shift");]])[
1678 ]b4_locations_if([ *++yylsp
= yylloc
;])[
1682 /*-----------------------------------------------------------.
1683 | yydefault -- do the default action for the current state. |
1684 `-----------------------------------------------------------*/
1686 yyn
= yydefact
[yystate
];
1692 /*-----------------------------.
1693 | yyreduce -- Do a reduction. |
1694 `-----------------------------*/
1696 /* yyn is the number of a rule to reduce with. */
1699 /* If YYLEN is nonzero, implement the default value of the action:
1702 Otherwise, the following line sets YYVAL to garbage.
1703 This behavior is undocumented and Bison
1704 users should not rely upon it. Assigning to YYVAL
1705 unconditionally makes the parser a bit smaller, and it avoids a
1706 GCC warning that YYVAL may be used uninitialized. */
1707 yyval
= yyvsp
[1-yylen
];
1710 [[ /* Default location. */
1711 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);]])[
1712 YY_REDUCE_PRINT (yyn
);]b4_lac_if([[
1714 int yychar_backup
= yychar
;
1720 if (yychar_backup
!= yychar
)
1721 YY_LAC_DISCARD ("yychar change");
1728 /* User semantic actions sometimes alter yychar, and that requires
1729 that yytoken be updated with the new translation. We take the
1730 approach of translating immediately before every use of yytoken.
1731 One alternative is translating here after every semantic action,
1732 but that translation would be missed if the semantic action invokes
1733 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1734 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1735 incorrect destructor might then be invoked immediately. In the
1736 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1737 to an incorrect destructor call or verbose syntax error message
1738 before the lookahead is translated. */
1739 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1743 YY_STACK_PRINT (yyss
, yyssp
);
1745 *++yyvsp
= yyval
;]b4_locations_if([
1746 *++yylsp
= yyloc
;])[
1748 /* Now `shift' the result of the reduction. Determine what state
1749 that goes to, based on the state we popped back to and the rule
1750 number reduced by. */
1754 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1755 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1756 yystate
= yytable
[yystate
];
1758 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1763 /*------------------------------------.
1764 | yyerrlab -- here on detecting error |
1765 `------------------------------------*/
1767 /* Make sure we have latest lookahead translation. See comments at
1768 user semantic actions for why this is necessary. */
1769 yytoken
= yychar
== YYEMPTY
? YYEMPTY
: YYTRANSLATE (yychar
);
1771 /* If not already recovering from an error, report this error. */
1775 #if ! YYERROR_VERBOSE
1776 yyerror (]b4_yyerror_args
[YY_("syntax error"));
1778 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, yyssp, \
1781 char const *yymsgp
= YY_("syntax error");
1782 int yysyntax_error_status
;]b4_lac_if([[
1783 if (yychar
!= YYEMPTY
)
1784 YY_LAC_ESTABLISH
;]])[
1785 yysyntax_error_status
= YYSYNTAX_ERROR
;
1786 if (yysyntax_error_status
== 0)
1788 else if (yysyntax_error_status
== 1)
1790 if (yymsg
!= yymsgbuf
)
1791 YYSTACK_FREE (yymsg
);
1792 yymsg
= (char *) YYSTACK_ALLOC (yymsg_alloc
);
1796 yymsg_alloc
= sizeof yymsgbuf
;
1797 yysyntax_error_status
= 2;
1801 yysyntax_error_status
= YYSYNTAX_ERROR
;
1805 yyerror (]b4_yyerror_args
[yymsgp
);
1806 if (yysyntax_error_status
== 2)
1807 goto yyexhaustedlab
;
1809 # undef YYSYNTAX_ERROR
1813 ]b4_locations_if([[ yyerror_range
[1] = yylloc
;]])[
1815 if (yyerrstatus
== 3)
1817 /* If just tried and failed to reuse lookahead token after an
1818 error, discard it. */
1820 if (yychar
<= YYEOF
)
1822 /* Return failure if at end of input. */
1823 if (yychar
== YYEOF
)
1828 yydestruct ("Error: discarding",
1829 yytoken
, &yylval
]b4_locations_if([, &yylloc
])[]b4_user_args
[);
1834 /* Else will try to reuse lookahead token after shifting the error
1839 /*---------------------------------------------------.
1840 | yyerrorlab -- error raised explicitly by YYERROR. |
1841 `---------------------------------------------------*/
1844 /* Pacify compilers like GCC when the user code never invokes
1845 YYERROR and the label yyerrorlab therefore never appears in user
1847 if (/*CONSTCOND*/ 0)
1850 ]b4_locations_if([[ yyerror_range
[1] = yylsp
[1-yylen
];
1851 ]])[ /* Do not reclaim the symbols of the rule which action triggered
1855 YY_STACK_PRINT (yyss
, yyssp
);
1860 /*-------------------------------------------------------------.
1861 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1862 `-------------------------------------------------------------*/
1864 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1868 yyn
= yypact
[yystate
];
1869 if (!yypact_value_is_default (yyn
))
1872 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1880 /* Pop the current state because it cannot handle the error token. */
1884 ]b4_locations_if([[ yyerror_range
[1] = *yylsp
;]])[
1885 yydestruct ("Error: popping",
1886 yystos
[yystate
], yyvsp
]b4_locations_if([, yylsp
])[]b4_user_args
[);
1889 YY_STACK_PRINT (yyss
, yyssp
);
1892 /* If the stack popping above didn't lose the initial context for the
1893 current lookahead token, the shift below will for sure. */
1894 YY_LAC_DISCARD ("error recovery");]])[
1898 yyerror_range
[2] = yylloc
;
1899 /* Using YYLLOC is tempting, but would change the location of
1900 the lookahead. YYLOC is available though. */
1901 YYLLOC_DEFAULT (yyloc
, yyerror_range
, 2);
1902 *++yylsp
= yyloc
;]])[
1904 /* Shift the error token. */
1905 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1911 /*-------------------------------------.
1912 | yyacceptlab -- YYACCEPT comes here. |
1913 `-------------------------------------*/
1918 /*-----------------------------------.
1919 | yyabortlab -- YYABORT comes here. |
1920 `-----------------------------------*/
1925 #if ]b4_lac_if([[1]], [[!defined(yyoverflow) || YYERROR_VERBOSE]])[
1926 /*-------------------------------------------------.
1927 | yyexhaustedlab -- memory exhaustion comes here. |
1928 `-------------------------------------------------*/
1930 yyerror (]b4_yyerror_args
[YY_("memory exhausted"));
1936 if (yychar
!= YYEMPTY
)
1938 /* Make sure we have latest lookahead translation. See comments at
1939 user semantic actions for why this is necessary. */
1940 yytoken
= YYTRANSLATE (yychar
);
1941 yydestruct ("Cleanup: discarding lookahead",
1942 yytoken
, &yylval
]b4_locations_if([, &yylloc
])[]b4_user_args
[);
1944 /* Do not reclaim the symbols of the rule which action triggered
1945 this YYABORT or YYACCEPT. */
1947 YY_STACK_PRINT (yyss
, yyssp
);
1948 while (yyssp
!= yyss
)
1950 yydestruct ("Cleanup: popping",
1951 yystos
[*yyssp
], yyvsp
]b4_locations_if([, yylsp
])[]b4_user_args
[);
1956 YYSTACK_FREE (yyss
);
1957 #endif]b4_push_if([[
1962 if (yymsg
!= yymsgbuf
)
1963 YYSTACK_FREE (yymsg
);
1965 /* Make sure YYID is used. */
1966 return YYID (yyresult
);
1972 [@
output(b4_spec_defines_file@
)@
1973 b4_copyright([Skeleton interface
for Bison
's Yacc-like parsers in C],
1974 [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010])
1976 b4_percent_code_get([[requires]])[]dnl
1978 b4_token_enums_defines(b4_tokens)
1980 [#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1981 ]m4_ifdef([b4_stype],
1982 [[typedef union ]b4_union_name[
1986 # define YYSTYPE_IS_TRIVIAL 1]],
1987 [m4_if(b4_tag_seen_flag, 0,
1988 [[typedef int YYSTYPE;
1989 # define YYSTYPE_IS_TRIVIAL 1]])])[
1990 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1991 # define YYSTYPE_IS_DECLARED 1
1994 ]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;]])
1997 [#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
1998 typedef struct YYLTYPE
2005 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
2006 # define YYLTYPE_IS_DECLARED 1
2007 # define YYLTYPE_IS_TRIVIAL 1
2010 ]b4_pure_if([], [[extern YYLTYPE ]b4_prefix[lloc;]])
2011 )dnl b4_locations_if
2013 #ifndef YYPUSH_DECLS
2014 # define YYPUSH_DECLS
2015 struct ]b4_prefix[pstate;
2016 typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
2017 enum { YYPUSH_MORE = 4 };
2018 ]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
2019 ])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
2020 [[b4_prefix[pstate *yyps]], [[yyps]]]b4_pure_if([,
2021 [[[int yypushed_char]], [[yypushed_char]]],
2022 [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
2023 [[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
2025 b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
2026 [[b4_prefix[pstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
2028 b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
2030 b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
2031 [[b4_prefix[pstate *yyps]], [[yyps]]])[
2034 b4_percent_code_get([[provides]])[]dnl