2 # Yacc compatible skeleton for Bison
4 # Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005,
5 # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
7 m4_pushdef([b4_copyright_years
],
8 [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010])
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 # Check the value of %define api.push-pull.
24 b4_percent_define_default([[api
.push
-pull
]], [[pull]])
25 b4_percent_define_check_values([[[[api
.push
-pull
]],
26 [[pull]], [[push]], [[both]]]])
27 b4_define_flag_if([pull
]) m4_define([b4_pull_flag
], [[1]])
28 b4_define_flag_if([push
]) m4_define([b4_push_flag
], [[1]])
29 m4_case(b4_percent_define_get([[api
.push
-pull
]]),
30 [pull
], [m4_define([b4_push_flag
], [[0]])],
31 [push
], [m4_define([b4_pull_flag
], [[0]])])
33 # Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
34 # tests function as written, don't let BISON_USE_PUSH_FOR_PULL modify Bison's
35 # behavior at all when push parsing is already requested.
36 b4_define_flag_if([use_push_for_pull
])
37 b4_use_push_for_pull_if([
38 b4_push_if([m4_define([b4_use_push_for_pull_flag
], [[0]])],
39 [m4_define([b4_push_flag
], [[1]])])])
41 # Check the value of %define parse.lac, where LAC stands for lookahead
43 b4_percent_define_default([[parse
.lac
]], [[none]])
44 b4_percent_define_default([[parse
.lac
.es
-capacity
]], [[20]])
45 b4_percent_define_check_values([[[[parse
.lac
]], [[full]], [[none]]]])
46 b4_define_flag_if([lac
])
47 m4_define([b4_lac_flag
],
48 [m4_if(b4_percent_define_get([[parse
.lac
]]),
49 [none
], [[0]], [[1]])])
51 m4_include(b4_pkgdatadir
/[c
.m4
])
53 ## ---------------- ##
55 ## ---------------- ##
58 m4_define_default([b4_stack_depth_max
], [10000])
59 m4_define_default([b4_stack_depth_init
], [200])
62 ## ------------------------ ##
63 ## Pure/impure interfaces. ##
64 ## ------------------------ ##
66 b4_percent_define_default([[api
.pure
]], [[false]])
67 b4_define_flag_if([pure
])
68 m4_define([b4_pure_flag
],
69 [b4_percent_define_flag_if([[api
.pure
]], [[1]], [[0]])])
71 # b4_yacc_pure_if(IF-TRUE, IF-FALSE)
72 # ----------------------------------
73 # Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise.
74 m4_define([b4_yacc_pure_if
],
75 [b4_pure_if([m4_ifset([b4_parse_param
],
82 # Arguments passed to yyerror: user args plus yylloc.
83 m4_define([b4_yyerror_args
],
84 [b4_yacc_pure_if([b4_locations_if([&yylloc
, ])])dnl
85 m4_ifset([b4_parse_param
], [b4_c_args(b4_parse_param
), ])])
90 # Accumulate in b4_lex_param all the yylex arguments.
91 # b4_lex_param arrives quoted twice, but we want to keep only one level.
92 m4_define([b4_lex_param
],
93 m4_dquote(b4_pure_if([[[[YYSTYPE
*]], [[&yylval
]]][]dnl
94 b4_locations_if([, [[YYLTYPE
*], [&yylloc
]]])m4_ifdef([b4_lex_param
], [, ])])dnl
95 m4_ifdef([b4_lex_param
], b4_lex_param
)))
102 # b4_int_type(MIN, MAX)
103 # ---------------------
104 # Return the smallest int type able to handle numbers ranging from
105 # MIN to MAX (included). Overwrite the version from c.m4, which
106 # uses only C89 types, so that the user can override the shorter
107 # types, and so that pre-C89 compilers are handled correctly.
108 m4_define([b4_int_type
],
109 [m4_if(b4_ints_in($@
, [0], [255]), [1], [yytype_uint8
],
110 b4_ints_in($@
, [-128], [127]), [1], [yytype_int8
],
112 b4_ints_in($@
, [0], [65535]), [1], [yytype_uint16
],
113 b4_ints_in($@
, [-32768], [32767]), [1], [yytype_int16
],
115 m4_eval([0 <= $
1]), [1], [unsigned int],
120 ## ----------------- ##
121 ## Semantic Values. ##
122 ## ----------------- ##
125 # b4_lhs_value([TYPE])
126 # --------------------
127 # Expansion of $<TYPE>$.
128 m4_define([b4_lhs_value
],
129 [b4_symbol_value(yyval
, [$
1])])
132 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
133 # --------------------------------------
134 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
136 m4_define([b4_rhs_value
],
137 [b4_symbol_value([yyvsp@
{b4_subtract([$
2], [$
1])@
}], [$
3])])
148 m4_define([b4_lhs_location
],
152 # b4_rhs_location(RULE-LENGTH, NUM)
153 # ---------------------------------
154 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
156 m4_define([b4_rhs_location
],
157 [(yylsp@
{b4_subtract([$
2], [$
1])@
})])
160 ## ------------------ ##
161 ## Parser variables. ##
162 ## ------------------ ##
164 # b4_declare_scanner_communication_variables
165 # ------------------------------------------
166 # Declare the variables that are global, or local to YYPARSE if
168 m4_define([b4_declare_scanner_communication_variables
], [[
169 /* The lookahead symbol. */
172 /* The semantic value of the lookahead symbol. */
173 YYSTYPE yylval
;]b4_locations_if([[
175 /* Location data for the lookahead symbol. */
176 YYLTYPE yylloc
;]])b4_pure_if([], [[
178 /* Number of syntax errors so far. */
182 # b4_declare_parser_state_variables
183 # ---------------------------------
184 # Declare all the variables that are needed to maintain the parser state
185 # between calls to yypush_parse.
186 m4_define([b4_declare_parser_state_variables
], [b4_pure_if([[
187 /* Number of syntax errors so far. */
191 /* Number of tokens to shift before error messages enabled. */
194 /* The stacks and their tools:
195 `yyss': related to states.
196 `yyvs': related to semantic values.]b4_locations_if([[
197 `yyls': related to locations.]])[
199 Refer to the stacks thru separate pointers, to allow yyoverflow
200 to reallocate them elsewhere. */
202 /* The state stack. */
203 yytype_int16 yyssa
[YYINITDEPTH
];
207 /* The semantic value stack. */
208 YYSTYPE yyvsa
[YYINITDEPTH
];
210 YYSTYPE
*yyvsp
;]b4_locations_if([[
212 /* The location stack. */
213 YYLTYPE yylsa
[YYINITDEPTH
];
217 /* The locations where the error started and ended. */
218 YYLTYPE yyerror_range
[3];]])[
220 YYSIZE_T yystacksize
;]])
223 ## --------------------------------------------------------- ##
224 ## Defining symbol actions, e.g., printers and destructors. ##
225 ## --------------------------------------------------------- ##
227 # We do want M4 expansion after # for CPP macros.
230 @
output(b4_parser_file_name@
)@
231 b4_copyright([Implementation
for Bison
's Yacc-like parsers in C])[
233 /* C LALR(1) parser skeleton written by Richard Stallman, by
234 simplifying the original so-called "semantic" parser. */
236 /* All symbols defined below should begin with yy or YY, to avoid
237 infringing on user name space. This should be done even for local
238 variables, as they might otherwise be expanded by user macros.
239 There are some unavoidable exceptions within include files to
240 define necessary library symbols; they are noted "INFRINGES ON
241 USER NAME SPACE" below. */
244 b4_percent_code_get([[top]])[]dnl
245 m4_if(b4_prefix, [yy], [],
246 [[/* Substitute the variable and function names. */]b4_pull_if([[
247 #define yyparse ]b4_prefix[parse]])b4_push_if([[
248 #define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[
249 #define yypull_parse ]b4_prefix[pull_parse]])[
250 #define yypstate_new ]b4_prefix[pstate_new
251 #define yypstate_delete ]b4_prefix[pstate_delete
252 #define yypstate ]b4_prefix[pstate]])[
253 #define yylex ]b4_prefix[lex
254 #define yyerror ]b4_prefix[error
255 #define yylval ]b4_prefix[lval
256 #define yychar ]b4_prefix[char
257 #define yydebug ]b4_prefix[debug
258 #define yynerrs ]b4_prefix[nerrs
259 ]b4_locations_if([[#define yylloc ]b4_prefix[lloc]])])[
261 /* Copy the first part of user declarations. */
262 ]b4_user_pre_prologue[
264 /* Enabling traces. */
266 # define YYDEBUG ]b4_parse_trace_if([1], [0])[
269 /* Enabling verbose error messages. */
270 #ifdef YYERROR_VERBOSE
271 # undef YYERROR_VERBOSE
272 # define YYERROR_VERBOSE 1
274 # define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
277 /* Enabling the token table. */
278 #ifndef YYTOKEN_TABLE
279 # define YYTOKEN_TABLE ]b4_token_table[
282 ]b4_percent_code_get([[requires]])[]dnl
284 b4_token_enums_defines(b4_tokens)[
286 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
287 ]m4_ifdef([b4_stype],
288 [[typedef union ]b4_union_name[
292 # define YYSTYPE_IS_TRIVIAL 1]],
293 [m4_if(b4_tag_seen_flag, 0,
294 [[typedef int YYSTYPE;
295 # define YYSTYPE_IS_TRIVIAL 1]])])[
296 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
297 # define YYSTYPE_IS_DECLARED 1
298 #endif]b4_locations_if([[
300 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
301 typedef struct YYLTYPE
308 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
309 # define YYLTYPE_IS_DECLARED 1
310 # define YYLTYPE_IS_TRIVIAL 1
311 #endif]])b4_push_if([[
314 # define YYPUSH_DECLS
316 typedef struct yypstate yypstate;
317 enum { YYPUSH_MORE = 4 };
319 ]b4_pull_if([b4_c_function_decl([[yyparse]], [[int]], b4_parse_param)
320 ])b4_c_function_decl([[yypush_parse]], [[int]],
321 [[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
322 [[[int yypushed_char]], [[yypushed_char]]],
323 [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
324 [[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
326 b4_pull_if([b4_c_function_decl([[yypull_parse]], [[int]],
327 [[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
329 b4_c_function_decl([[yypstate_new]], [[yypstate *]], [[[void]], []])
330 b4_c_function_decl([[yypstate_delete]], [[void]],
331 [[[yypstate *yyps]], [[yyps]]])[
334 b4_percent_code_get([[provides]])[]dnl
336 [/* Copy the second part of user declarations. */
337 ]b4_user_post_prologue
338 b4_percent_code_get[]dnl
345 typedef YYTYPE_UINT8 yytype_uint8;
347 typedef unsigned char yytype_uint8;
351 typedef YYTYPE_INT8 yytype_int8;
353 typedef signed char yytype_int8;
355 typedef short int yytype_int8;
359 typedef YYTYPE_UINT16 yytype_uint16;
361 typedef unsigned short int yytype_uint16;
365 typedef YYTYPE_INT16 yytype_int16;
367 typedef short int yytype_int16;
371 # ifdef __SIZE_TYPE__
372 # define YYSIZE_T __SIZE_TYPE__
373 # elif defined size_t
374 # define YYSIZE_T size_t
375 # elif ! defined YYSIZE_T && ]b4_c_modern[
376 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
377 # define YYSIZE_T size_t
379 # define YYSIZE_T unsigned int
383 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
386 # if defined YYENABLE_NLS && YYENABLE_NLS
388 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
389 # define YY_(msgid) dgettext ("bison-runtime", msgid)
393 # define YY_(msgid) msgid
397 /* Suppress unused-variable warnings by "using" E. */
398 #if ! defined lint || defined __GNUC__
399 # define YYUSE(e) ((void) (e))
401 # define YYUSE(e) /* empty */
404 /* Identity function, used to suppress warnings about constant conditions. */
408 ]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[
414 #if ! defined yyoverflow || YYERROR_VERBOSE
417 [[/* The parser invokes alloca or malloc; define the necessary symbols. */
419 # ifdef YYSTACK_USE_ALLOCA
420 # if YYSTACK_USE_ALLOCA
422 # define YYSTACK_ALLOC __builtin_alloca
423 # elif defined __BUILTIN_VA_ARG_INCR
424 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
426 # define YYSTACK_ALLOC __alloca
427 # elif defined _MSC_VER
428 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
429 # define alloca _alloca
431 # define YYSTACK_ALLOC alloca
432 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && ]b4_c_modern[
433 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
434 # ifndef EXIT_SUCCESS
435 # define EXIT_SUCCESS 0
443 [# ifdef YYSTACK_ALLOC
444 /* Pacify GCC's `empty
if-body
' warning. */
445 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
446 # ifndef YYSTACK_ALLOC_MAXIMUM
447 /* The OS might guarantee only one guard page at the bottom of the stack,
448 and a page size can be as small as 4096 bytes. So we cannot safely
449 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
450 to allow for a few compiler-allocated temporary stack slots. */
451 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
454 # define YYSTACK_ALLOC YYMALLOC
455 # define YYSTACK_FREE YYFREE
456 # ifndef YYSTACK_ALLOC_MAXIMUM
457 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
459 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
460 && ! ((defined YYMALLOC || defined malloc) \
461 && (defined YYFREE || defined free)))
462 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
463 # ifndef EXIT_SUCCESS
464 # define EXIT_SUCCESS 0
468 # define YYMALLOC malloc
469 # if ! defined malloc && ! defined EXIT_SUCCESS && ]b4_c_modern[
470 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
475 # if ! defined free && ! defined EXIT_SUCCESS && ]b4_c_modern[
476 void free (void *); /* INFRINGES ON USER NAME SPACE */
480 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
483 #if (! defined yyoverflow \
484 && (! defined __cplusplus \
485 || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
486 && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
488 /* A type that is properly aligned for any stack member. */
491 yytype_int16 yyss_alloc;
492 YYSTYPE yyvs_alloc;]b4_locations_if([
493 YYLTYPE yyls_alloc;])[
496 /* The size of the maximum gap between one aligned stack and the next. */
497 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
499 /* The size of an array large to enough to hold all stacks, each with
502 [# define YYSTACK_BYTES(N) \
503 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
504 + 2 * YYSTACK_GAP_MAXIMUM)],
505 [# define YYSTACK_BYTES(N) \
506 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
507 + YYSTACK_GAP_MAXIMUM)])[
509 /* Copy COUNT objects from FROM to TO. The source and destination do
512 # if defined __GNUC__ && 1 < __GNUC__
513 # define YYCOPY(To, From, Count) \
514 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
516 # define YYCOPY(To, From, Count) \
520 for (yyi = 0; yyi < (Count); yyi++) \
521 (To)[yyi] = (From)[yyi]; \
527 /* Relocate STACK from its old location to the new one. The
528 local variables YYSIZE and YYSTACKSIZE give the old and new number of
529 elements in the stack, and YYPTR gives the new location of the
530 stack. Advance YYPTR to a properly aligned location for the next
532 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
535 YYSIZE_T yynewbytes; \
536 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
537 Stack = &yyptr->Stack_alloc; \
538 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
539 yyptr += yynewbytes / sizeof (*yyptr); \
545 /* YYFINAL -- State number of the termination state. */
546 #define YYFINAL ]b4_final_state_number[
547 /* YYLAST -- Last index in YYTABLE. */
548 #define YYLAST ]b4_last[
550 /* YYNTOKENS -- Number of terminals. */
551 #define YYNTOKENS ]b4_tokens_number[
552 /* YYNNTS -- Number of nonterminals. */
553 #define YYNNTS ]b4_nterms_number[
554 /* YYNRULES -- Number of rules. */
555 #define YYNRULES ]b4_rules_number[
556 /* YYNSTATES -- Number of states. */
557 #define YYNSTATES ]b4_states_number[
559 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
560 by yylex, with out-of-bounds checking. */
561 #define YYUNDEFTOK ]b4_undef_token_number[
562 #define YYMAXUTOK ]b4_user_token_number_max[
564 #define YYTRANSLATE(YYX) \
565 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
567 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
568 as returned by yylex, without out-of-bounds checking. */
569 static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
575 ]b4_integral_parser_table_define([rline], [b4_rline],
576 [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
579 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
580 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
581 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
582 static const char *const yytname[] =
589 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
590 (internal) symbol number NUM (which must be that of a token). */
591 static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
597 #define YYPACT_NINF ]b4_pact_ninf[
599 #define yypact_value_is_default(yystate) \
600 ]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
602 #define YYTABLE_NINF ]b4_table_ninf[
604 #define yytable_value_is_error(yytable_value) \
605 ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
607 ]b4_parser_tables_define[
609 #define yyerrok (yyerrstatus = 0)
610 #define yyclearin (yychar = YYEMPTY)
614 #define YYACCEPT goto yyacceptlab
615 #define YYABORT goto yyabortlab
616 #define YYERROR goto yyerrorlab
619 /* Like YYERROR except do call yyerror. This remains here temporarily
620 to ease the transition to the new meaning of YYERROR, for GCC.
621 Once GCC version 2 has supplanted version 1, this can go. However,
622 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
623 in Bison 2.4.2's NEWS entry
, where a plan to phase it out is
626 #define YYFAIL goto yyerrlab
628 /* This is here to suppress warnings from the GCC cpp's
629 -Wunused-macros. Normally we don't worry about that warning, but
630 some users do, and we want to make it easy for users to remove
631 YYFAIL uses, which will produce warnings from Bison 2.5. */
634 #define YYRECOVERING() (!!yyerrstatus)
636 #define YYBACKUP(Token, Value) \
638 if (yychar == YYEMPTY && yylen == 1) \
642 YYPOPSTACK (1); \]b4_lac_if([[
643 YY_LAC_DISCARD ("YYBACKUP"); \
]])[
648 yyerror (]b4_yyerror_args
[YY_("syntax error: cannot back up")); \
655 #define YYERRCODE 256
658 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
659 If N is 0, then set CURRENT to the empty location which ends
660 the previous symbol: RHS[0] (always defined). */
662 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
663 #ifndef YYLLOC_DEFAULT
664 # define YYLLOC_DEFAULT(Current, Rhs, N) \
668 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
669 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
670 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
671 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
675 (Current).first_line = (Current).last_line = \
676 YYRHSLOC (Rhs, 0).last_line; \
677 (Current).first_column = (Current).last_column = \
678 YYRHSLOC (Rhs, 0).last_column; \
681 #endif]b4_locations_if([[
684 /* YY_LOCATION_PRINT -- Print the location on the stream.
685 This macro was not mandated originally: define only if we know
686 we won't break user code: when these are the locations we know. */
688 #ifndef YY_LOCATION_PRINT
689 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
690 # define YY_LOCATION_PRINT(File, Loc) \
691 fprintf (File, "%d.%d-%d.%d", \
692 (Loc).first_line, (Loc).first_column, \
693 (Loc).last_line, (Loc).last_column)
695 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
700 /* This macro is provided for backward compatibility. */
702 #ifndef YY_LOCATION_PRINT
703 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
707 /* YYLEX -- calling `yylex' with the right arguments. */
710 # define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM)
712 # define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
715 /* Enable debugging if requested. */
719 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
720 # define YYFPRINTF fprintf
723 # define YYDPRINTF(Args) \
729 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
733 YYFPRINTF (stderr, "%s ", Title); \
734 yy_symbol_print (stderr, \
735 Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
736 YYFPRINTF (stderr, "\n"); \
740 ]b4_yy_symbol_print_generate([b4_c_function_def
])[
742 /*------------------------------------------------------------------.
743 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
745 `------------------------------------------------------------------*/
747 ]b4_c_function_def([yy_stack_print
], [static void],
748 [[yytype_int16
*yybottom
], [yybottom
]],
749 [[yytype_int16
*yytop
], [yytop
]])[
751 YYFPRINTF (stderr
, "Stack now");
752 for (; yybottom
<= yytop
; yybottom
++)
754 int yybot
= *yybottom
;
755 YYFPRINTF (stderr
, " %d", yybot
);
757 YYFPRINTF (stderr
, "\n");
760 # define YY_STACK_PRINT(Bottom, Top) \
763 yy_stack_print ((Bottom), (Top)); \
767 /*------------------------------------------------.
768 | Report that the YYRULE is going to be reduced. |
769 `------------------------------------------------*/
771 ]b4_c_function_def([yy_reduce_print
], [static void],
772 [[yytype_int16
*yyssp
], [yyssp
]],
773 [[YYSTYPE
*yyvsp
], [yyvsp
]],
774 b4_locations_if([[[YYLTYPE
*yylsp
], [yylsp
]],
775 ])[[int yyrule
], [yyrule
]]m4_ifset([b4_parse_param
], [,
778 unsigned long int yylno
= yyrline
[yyrule
];
779 int yynrhs
= yyr2
[yyrule
];
781 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
783 /* The symbols being reduced. */
784 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
786 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
787 yy_symbol_print (stderr
,
788 yystos
[yyssp
[yyi
+ 1 - yynrhs
]],
789 &]b4_rhs_value(yynrhs
, yyi
+ 1)[
790 ]b4_locations_if([, &]b4_rhs_location(yynrhs
, yyi
+ 1))[]dnl
792 YYFPRINTF (stderr
, "\n");
796 # define YY_REDUCE_PRINT(Rule) \
799 yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
802 /* Nonzero means print parse trace. It is left uninitialized so that
803 multiple parsers can coexist. */
806 # define YYDPRINTF(Args)
807 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
808 # define YY_STACK_PRINT(Bottom, Top)
809 # define YY_REDUCE_PRINT(Rule)
810 #endif /* !YYDEBUG */
813 /* YYINITDEPTH -- initial size of the parser's stacks. */
815 # define YYINITDEPTH ]b4_stack_depth_init[
818 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
819 if the built-in stack extension method is used).
821 Do not make this value too large; the results are undefined if
822 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
823 evaluated with infinite-precision integer arithmetic. */
826 # define YYMAXDEPTH ]b4_stack_depth_max[
829 /* Establish the initial context for the current lookahead if no initial
830 context is currently established.
832 We define a context as a snapshot of the parser stacks. We define
833 the initial context for a lookahead as the context in which the
834 parser initially examines that lookahead in order to select a
835 syntactic action. Thus, if the lookahead eventually proves
836 syntactically unacceptable (possibly in a later context reached via a
837 series of reductions), the initial context can be used to determine
838 the exact set of tokens that would be syntactically acceptable in the
839 lookahead's place. Moreover, it is the context after which any
840 further semantic actions would be erroneous because they would be
841 determined by a syntactically unacceptable token.
843 YY_LAC_ESTABLISH should be invoked when a reduction is about to be
844 performed in an inconsistent state (which, for the purposes of LAC,
845 includes consistent states that don't know they're consistent because
846 their default reductions have been disabled). Iff there is a
847 lookahead token, it should also be invoked before reporting a syntax
848 error. This latter case is for the sake of the debugging output.
850 For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
851 follows. If no initial context is currently established for the
852 current lookahead, then check if that lookahead can eventually be
853 shifted if syntactic actions continue from the current context.
854 Report a syntax error if it cannot. */
855 #define YY_LAC_ESTABLISH \
857 if (!yy_lac_established) \
859 YYDPRINTF ((stderr, \
860 "LAC: initial context established for %s\n", \
861 yytname[yytoken])); \
862 yy_lac_established = 1; \
864 int yy_lac_status = \
865 yy_lac (yyssp, yytoken); \
866 if (yy_lac_status == 2) \
867 goto yyexhaustedlab; \
868 if (yy_lac_status == 1) \
874 /* Discard any previous initial lookahead context because of Event,
875 which may be a lookahead change or an invalidation of the currently
876 established initial context for the current lookahead.
878 The most common example of a lookahead change is a shift. An example
879 of both cases is syntax error recovery. That is, a syntax error
880 occurs when the lookahead is syntactically erroneous for the
881 currently established initial context, so error recovery manipulates
882 the parser stacks to try to find a new initial context in which the
883 current lookahead is syntactically acceptable. If it fails to find
884 such a context, it discards the lookahead. */
886 # define YY_LAC_DISCARD(Event) \
888 if (yy_lac_established) \
891 YYFPRINTF (stderr, "LAC: initial context discarded due to " \
893 yy_lac_established = 0; \
897 # define YY_LAC_DISCARD(Event) yy_lac_established = 0
900 /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
901 eventually (after perhaps some reductions) be shifted, and return 1
902 if not. Return 2 if memory is exhausted. */
904 yy_lac (yytype_int16
*yyssp
, int yytoken
)
906 yytype_int16
*yyes_prev
= yyssp
;
907 yytype_int16 yyes@
{]b4_percent_define_get([[parse
.lac
.es
-capacity
]])[@
};
908 yytype_int16
*yyesp
= yyes_prev
;
909 YYDPRINTF ((stderr
, "LAC: checking lookahead %s:", yytname
[yytoken
]));
910 if (yytoken
== YYUNDEFTOK
)
912 YYDPRINTF ((stderr
, " Always Err\n"));
917 int yyrule
= yypact
[*yyesp
];
918 if (yypact_value_is_default (yyrule
)
919 || (yyrule
+= yytoken
) < 0 || YYLAST
< yyrule
920 || yycheck
[yyrule
] != yytoken
)
922 yyrule
= yydefact
[*yyesp
];
925 YYDPRINTF ((stderr
, " Err\n"));
931 yyrule
= yytable
[yyrule
];
932 if (yytable_value_is_error (yyrule
))
934 YYDPRINTF ((stderr
, " Err\n"));
939 YYDPRINTF ((stderr
, " S%d\n", yyrule
));
945 YYSIZE_T yylen
= yyr2
[yyrule
];
946 YYDPRINTF ((stderr
, " R%d", yyrule
- 1));
947 if (yyesp
!= yyes_prev
)
949 YYSIZE_T yysize
= yyesp
- yyes
+ 1;
962 yyesp
= yyes_prev
-= yylen
;
967 int yylhs
= yyr1
[yyrule
] - YYNTOKENS
;
968 yystate
= yypgoto
[yylhs
] + *yyesp
;
969 if (yystate
< 0 || YYLAST
< yystate
970 || yycheck
[yystate
] != *yyesp
)
971 yystate
= yydefgoto
[yylhs
];
973 yystate
= yytable
[yystate
];
975 if (yyesp
== yyes_prev
)
982 if (yyesp
== yyes
+ (sizeof yyes
/ sizeof *yyes
) - 1)
984 YYDPRINTF ((stderr
, " (max stack size exceeded)\n"));
989 YYDPRINTF ((stderr
, " G%d", *yyesp
));
998 # if defined __GLIBC__ && defined _STRING_H
999 # define yystrlen strlen
1001 /* Return the length of YYSTR. */
1002 ]b4_c_function_def([yystrlen
], [static YYSIZE_T
],
1003 [[const char *yystr
], [yystr
]])[
1006 for (yylen
= 0; yystr
[yylen
]; yylen
++)
1014 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1015 # define yystpcpy stpcpy
1017 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1019 ]b4_c_function_def([yystpcpy
], [static char *],
1020 [[char *yydest
], [yydest
]], [[const char *yysrc
], [yysrc
]])[
1023 const char *yys
= yysrc
;
1025 while ((*yyd
++ = *yys
++) != '\0')
1034 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1035 quotes and backslashes, so that it's suitable for yyerror. The
1036 heuristic is that double-quoting is unnecessary unless the string
1037 contains an apostrophe, a comma, or backslash (other than
1038 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1039 null, do not copy; instead, return the length of what the result
1042 yytnamerr (char *yyres
, const char *yystr
)
1047 char const *yyp
= yystr
;
1054 goto do_not_strip_quotes
;
1058 goto do_not_strip_quotes
;
1071 do_not_strip_quotes
: ;
1075 return yystrlen (yystr
);
1077 return yystpcpy (yyres
, yystr
) - yyres
;
1081 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1082 about the unexpected token YYTOKEN for the state stack whose top is
1083 YYSSP.]b4_lac_if([[ In order to see if a particular token T is a
1084 valid looakhead, invoke yy_lac (YYSSP, T).]])[
1086 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1087 not large enough to hold the message. In that case, also set
1088 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1089 required number of bytes is too large to store]b4_lac_if([[ or if
1090 yy_lac returned 2]])[. */
1092 yysyntax_error (YYSIZE_T
*yymsg_alloc
, char **yymsg
,
1093 yytype_int16
*yyssp
, int yytoken
)
1095 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytoken
]);
1096 YYSIZE_T yysize
= yysize0
;
1098 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1099 /* Internationalized format string. */
1100 const char *yyformat
= 0;
1101 /* Arguments of yyformat. */
1102 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1103 /* Number of reported tokens (one for the "unexpected", one per
1107 /* There are many possibilities here to consider:
1108 - Assume YYFAIL is not used. It's too flawed to consider. See
1109 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1110 for details. YYERROR is fine as it does not invoke this
1112 - If this state is a consistent state with a default action, then
1113 the only way this function was invoked is if the default action
1114 is an error action. In that case, don't check for expected
1115 tokens because there are none.
1116 - The only way there can be no lookahead present (in yychar) is if
1117 this state is a consistent state with a default action. Thus,
1118 detecting the absence of a lookahead is sufficient to determine
1119 that there is no unexpected or expected token to report. In that
1120 case, just report a simple "syntax error".
1121 - Don't assume there isn't a lookahead just because this state is a
1122 consistent state with a default action. There might have been a
1123 previous inconsistent state, consistent state with a non-default
1124 action, or user semantic action that manipulated yychar.]b4_lac_if([[
1125 In the first two cases, it might appear that the current syntax
1126 error should have been detected in the previous state when yy_lac
1127 was invoked. However, at that time, there might have been a
1128 different syntax error that discarded a different initial context
1129 during error recovery, leaving behind the current lookahead.]], [[
1130 - Of course, the expected token list depends on states to have
1131 correct lookahead information, and it depends on the parser not
1132 to perform extra reductions after fetching a lookahead from the
1133 scanner and before detecting a syntax error. Thus, state merging
1134 (from LALR or IELR) and default reductions corrupt the expected
1135 token list. However, the list is correct for canonical LR with
1136 one exception: it will still contain any token that will not be
1137 accepted due to an error action in a later state.]])[
1139 if (yytoken
!= YYEMPTY
)
1141 int yyn
= yypact
[*yyssp
];]b4_lac_if([[
1142 YYDPRINTF ((stderr
, "Constructing syntax error message\n"));]])[
1143 yyarg
[yycount
++] = yytname
[yytoken
];
1144 if (!yypact_value_is_default (yyn
))
1146 /* Start YYX at -YYN if negative to avoid negative indexes in
1147 YYCHECK. In other words, skip the first -YYN actions for
1148 this state because they are default actions. */
1149 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1150 /* Stay within bounds of both yycheck and yytname. */
1151 int yychecklim
= YYLAST
- yyn
+ 1;
1152 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;]])[
1153 int yyx
;]b4_lac_if([[
1155 for (yyx
= 0; yyx
< YYNTOKENS
; ++yyx
)
1156 if (yyx
!= YYTERROR
&& yyx
!= YYUNDEFTOK
)
1159 int yy_lac_status
= yy_lac (yyssp
, yyx
);
1160 if (yy_lac_status
== 2)
1162 if (yy_lac_status
== 1)
1166 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1167 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
1168 && !yytable_value_is_error (yytable
[yyx
+ yyn
]))
1170 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1176 yyarg
[yycount
++] = yytname
[yyx
];
1177 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1178 if (! (yysize
<= yysize1
1179 && yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1186 YYFPRINTF (stderr
, "No expected tokens.\n");
1192 # define YYCASE_(N, S) \
1196 YYCASE_(0, YY_("syntax error"));
1197 YYCASE_(1, YY_("syntax error, unexpected %s"));
1198 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1199 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1200 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1201 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1205 yysize1
= yysize
+ yystrlen (yyformat
);
1206 if (! (yysize
<= yysize1
&& yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1210 if (*yymsg_alloc
< yysize
)
1212 *yymsg_alloc
= 2 * yysize
;
1213 if (! (yysize
<= *yymsg_alloc
1214 && *yymsg_alloc
<= YYSTACK_ALLOC_MAXIMUM
))
1215 *yymsg_alloc
= YYSTACK_ALLOC_MAXIMUM
;
1219 /* Avoid sprintf, as that infringes on the user's name space.
1220 Don't have undefined behavior even if the translation
1221 produced a string with the wrong number of "%s"s. */
1225 while ((*yyp
= *yyformat
) != '\0')
1226 if (*yyp
== '%' && yyformat
[1] == 's' && yyi
< yycount
)
1228 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1239 #endif /* YYERROR_VERBOSE */
1241 ]b4_yydestruct_generate([b4_c_function_def
])b4_push_if([], [[
1244 /* Prevent warnings from -Wmissing-prototypes. */
1245 #ifdef YYPARSE_PARAM
1246 ]b4_c_function_decl([yyparse
], [int],
1247 [[void *YYPARSE_PARAM
], [YYPARSE_PARAM
]])[
1248 #else /* ! YYPARSE_PARAM */
1249 ]b4_c_function_decl([yyparse
], [int], b4_parse_param
)[
1250 #endif /* ! YYPARSE_PARAM */]])b4_pure_if([], [
1252 b4_declare_scanner_communication_variables
])[]b4_push_if([[
1256 {]b4_declare_parser_state_variables
[
1257 /* Used to determine if this is the first time this instance has
1260 };]b4_pure_if([], [[
1262 static char yypstate_allocated
= 0;]])b4_pull_if([
1264 b4_c_function_def([[yyparse]], [[int]], b4_parse_param
)[
1266 return yypull_parse (0]m4_ifset([b4_parse_param
],
1267 [[, ]b4_c_args(b4_parse_param
)])[);
1270 ]b4_c_function_def([[yypull_parse]], [[int]],
1271 [[[yypstate
*yyps
]], [[yyps]]]m4_ifset([b4_parse_param
], [,
1275 yypstate
*yyps_local
;]b4_pure_if([[
1277 YYSTYPE yylval
;]b4_locations_if([[
1278 YYLTYPE yylloc
;]])])[
1281 yyps_local
= yypstate_new ();
1284 yyerror (]b4_yyerror_args
[YY_("memory exhausted"));]], [[
1285 if (!yypstate_allocated
)
1286 yyerror (]b4_yyerror_args
[YY_("memory exhausted"));]])[
1295 yypush_parse (yyps_local
]b4_pure_if([[, yychar
, &yylval
]b4_locations_if([[, &yylloc
]])])m4_ifset([b4_parse_param
], [, b4_c_args(b4_parse_param
)])[);
1296 } while (yystatus
== YYPUSH_MORE
);
1298 yypstate_delete (yyps_local
);
1302 /* Initialize the parser data structure. */
1303 ]b4_c_function_def([[yypstate_new]], [[yypstate
*]])[
1305 yypstate
*yyps
;]b4_pure_if([], [[
1306 if (yypstate_allocated
)
1308 yyps
= (yypstate
*) malloc (sizeof *yyps
);
1311 yyps
->yynew
= 1;]b4_pure_if([], [[
1312 yypstate_allocated
= 1;]])[
1316 ]b4_c_function_def([[yypstate_delete]], [[void]],
1317 [[[yypstate
*yyps
]], [[yyps]]])[
1320 /* If the stack was reallocated but the parse did not complete, then the
1321 stack still needs to be freed. */
1322 if (!yyps
->yynew
&& yyps
->yyss
!= yyps
->yyssa
)
1323 YYSTACK_FREE (yyps
->yyss
);
1325 free (yyps
);]b4_pure_if([], [[
1326 yypstate_allocated
= 0;]])[
1329 #define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs]])[
1330 #define yystate yyps->yystate
1331 #define yyerrstatus yyps->yyerrstatus
1332 #define yyssa yyps->yyssa
1333 #define yyss yyps->yyss
1334 #define yyssp yyps->yyssp
1335 #define yyvsa yyps->yyvsa
1336 #define yyvs yyps->yyvs
1337 #define yyvsp yyps->yyvsp]b4_locations_if([[
1338 #define yylsa yyps->yylsa
1339 #define yyls yyps->yyls
1340 #define yylsp yyps->yylsp
1341 #define yyerror_range yyps->yyerror_range]])[
1342 #define yystacksize yyps->yystacksize
1349 ]b4_c_function_def([[yypush_parse]], [[int]],
1350 [[[yypstate
*yyps
]], [[yyps]]]b4_pure_if([,
1351 [[[int yypushed_char]], [[yypushed_char]]],
1352 [[[YYSTYPE
const *yypushed_val
]], [[yypushed_val]]]b4_locations_if([,
1353 [[[YYLTYPE
const *yypushed_loc
]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param
], [,
1354 b4_parse_param
]))], [[
1361 #ifdef YYPARSE_PARAM
1362 ]b4_c_function_def([yyparse
], [int],
1363 [[void *YYPARSE_PARAM
], [YYPARSE_PARAM
]])[
1364 #else /* ! YYPARSE_PARAM */
1365 ]b4_c_function_def([yyparse
], [int], b4_parse_param
)[
1367 {]b4_pure_if([b4_declare_scanner_communication_variables
1368 ])b4_push_if([b4_pure_if([], [[
1369 int yypushed_char
= yychar
;
1370 YYSTYPE yypushed_val
= yylval
;]b4_locations_if([[
1371 YYLTYPE yypushed_loc
= yylloc
;]])
1373 [b4_declare_parser_state_variables
1375 int yy_lac_established
= 0;]])[
1378 /* Lookahead token as an internal (translated) token number. */
1380 /* The variables used to return semantic value and location from the
1382 YYSTYPE yyval
;]b4_locations_if([[
1386 /* Buffer for error messages, and its allocated size. */
1388 char *yymsg
= yymsgbuf
;
1389 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1392 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[)
1394 /* The number of symbols on the RHS of the reduced rule.
1395 Keep to zero when no symbol should be popped. */
1396 int yylen
= 0;]b4_push_if([[
1400 yyn
= yypact
[yystate
];
1401 goto yyread_pushed_token
;
1406 yyvs
= yyvsa
;]b4_locations_if([[
1408 yystacksize
= YYINITDEPTH
;
1410 YYDPRINTF ((stderr
, "Starting parse\n"));
1415 yychar
= YYEMPTY
; /* Cause a token to be read. */
1417 /* Initialize stack pointers.
1418 Waste one element of value and location stack
1419 so that they stay on the same level as the state stack.
1420 The wasted elements are never initialized. */
1422 yyvsp
= yyvs
;]b4_locations_if([[
1425 #if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1426 /* Initialize the default location before parsing starts. */
1427 yylloc
.first_line
= yylloc
.last_line
= ]b4_location_initial_line
[;
1428 yylloc
.first_column
= yylloc
.last_column
= ]b4_location_initial_column
[;
1430 m4_ifdef([b4_initial_action
],[
1431 m4_pushdef([b4_at_dollar
], [m4_define([b4_at_dollar_used
])yylloc
])dnl
1432 m4_pushdef([b4_dollar_dollar
], [m4_define([b4_dollar_dollar_used
])yylval
])dnl
1433 /* User initialization code. */
1434 b4_user_initial_action
1435 m4_popdef([b4_dollar_dollar
])dnl
1436 m4_popdef([b4_at_dollar
])])dnl
1437 m4_ifdef([b4_dollar_dollar_used
],[[ yyvsp
[0] = yylval
;
1439 m4_ifdef([b4_at_dollar_used
], [[ yylsp
[0] = yylloc
;
1443 /*------------------------------------------------------------.
1444 | yynewstate -- Push a new state, which is found in yystate. |
1445 `------------------------------------------------------------*/
1447 /* In all cases, when you get here, the value and location stacks
1448 have just been pushed. So pushing a state here evens the stacks. */
1454 if (yyss
+ yystacksize
- 1 <= yyssp
)
1456 /* Get the current used size of the three stacks, in elements. */
1457 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1461 /* Give user a chance to reallocate the stack. Use copies of
1462 these so that the &'s don't force the real ones into
1464 YYSTYPE
*yyvs1
= yyvs
;
1465 yytype_int16
*yyss1
= yyss
;]b4_locations_if([
1466 YYLTYPE
*yyls1
= yyls
;])[
1468 /* Each stack pointer address is followed by the size of the
1469 data in use in that stack, in bytes. This used to be a
1470 conditional around just the two extra args, but that might
1471 be undefined if yyoverflow is a macro. */
1472 yyoverflow (YY_("memory exhausted"),
1473 &yyss1
, yysize
* sizeof (*yyssp
),
1474 &yyvs1
, yysize
* sizeof (*yyvsp
),]b4_locations_if([
1475 &yyls1
, yysize
* sizeof (*yylsp
),])[
1482 #else /* no yyoverflow */
1483 # ifndef YYSTACK_RELOCATE
1484 goto yyexhaustedlab
;
1486 /* Extend the stack our own way. */
1487 if (YYMAXDEPTH
<= yystacksize
)
1488 goto yyexhaustedlab
;
1490 if (YYMAXDEPTH
< yystacksize
)
1491 yystacksize
= YYMAXDEPTH
;
1494 yytype_int16
*yyss1
= yyss
;
1495 union yyalloc
*yyptr
=
1496 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1498 goto yyexhaustedlab
;
1499 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1500 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);]b4_locations_if([
1501 YYSTACK_RELOCATE (yyls_alloc
, yyls
);])[
1502 # undef YYSTACK_RELOCATE
1504 YYSTACK_FREE (yyss1
);
1507 #endif /* no yyoverflow */
1509 yyssp
= yyss
+ yysize
- 1;
1510 yyvsp
= yyvs
+ yysize
- 1;]b4_locations_if([
1511 yylsp
= yyls
+ yysize
- 1;])[
1513 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1514 (unsigned long int) yystacksize
));
1516 if (yyss
+ yystacksize
- 1 <= yyssp
)
1520 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1522 if (yystate
== YYFINAL
)
1532 /* Do appropriate processing given the current state. Read a
1533 lookahead token if we need one and don't already have one. */
1535 /* First try to decide what to do without reference to lookahead token. */
1536 yyn
= yypact
[yystate
];
1537 if (yypact_value_is_default (yyn
))
1540 /* Not known => get a lookahead token if don't already have one. */
1542 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1543 if (yychar
== YYEMPTY
)
1546 {]b4_use_push_for_pull_if([], [[
1547 YYDPRINTF ((stderr
, "Return for a new token:\n"));]])[
1548 yyresult
= YYPUSH_MORE
;
1551 yyps
->yynew
= 0;]b4_pure_if([], [[
1552 /* Restoring the pushed token is only necessary for the first
1553 yypush_parse invocation since subsequent invocations don't overwrite
1554 it before jumping to yyread_pushed_token. */
1555 yychar
= yypushed_char
;
1556 yylval
= yypushed_val
;]b4_locations_if([[
1557 yylloc
= yypushed_loc
;]])])[
1558 yyread_pushed_token
:]])[
1559 YYDPRINTF ((stderr
, "Reading a token: "));]b4_push_if([b4_pure_if([[
1560 yychar
= yypushed_char
;
1562 yylval
= *yypushed_val
;]b4_locations_if([[
1564 yylloc
= *yypushed_loc
;]])])], [[
1568 if (yychar
<= YYEOF
)
1570 yychar
= yytoken
= YYEOF
;
1571 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1575 yytoken
= YYTRANSLATE (yychar
);
1576 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1579 /* If the proper action on seeing token YYTOKEN is to reduce or to
1580 detect an error, take that action. */
1582 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)]b4_lac_if([[
1591 if (yytable_value_is_error (yyn
))
1592 goto yyerrlab
;]b4_lac_if([[
1593 YY_LAC_ESTABLISH
;]])[
1598 /* Count tokens shifted since error; after three, turn off error
1603 /* Shift the lookahead token. */
1604 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1606 /* Discard the shifted token. */
1607 yychar
= YYEMPTY
;]b4_lac_if([[
1608 YY_LAC_DISCARD ("shift");]])[
1612 ]b4_locations_if([ *++yylsp
= yylloc
;])[
1616 /*-----------------------------------------------------------.
1617 | yydefault -- do the default action for the current state. |
1618 `-----------------------------------------------------------*/
1620 yyn
= yydefact
[yystate
];
1626 /*-----------------------------.
1627 | yyreduce -- Do a reduction. |
1628 `-----------------------------*/
1630 /* yyn is the number of a rule to reduce with. */
1633 /* If YYLEN is nonzero, implement the default value of the action:
1636 Otherwise, the following line sets YYVAL to garbage.
1637 This behavior is undocumented and Bison
1638 users should not rely upon it. Assigning to YYVAL
1639 unconditionally makes the parser a bit smaller, and it avoids a
1640 GCC warning that YYVAL may be used uninitialized. */
1641 yyval
= yyvsp
[1-yylen
];
1644 [[ /* Default location. */
1645 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);]])[
1646 YY_REDUCE_PRINT (yyn
);]b4_lac_if([[
1648 int yychar_backup
= yychar
;
1654 if (yychar_backup
!= yychar
)
1655 YY_LAC_DISCARD ("yychar change");
1662 /* User semantic actions sometimes alter yychar, and that requires
1663 that yytoken be updated with the new translation. We take the
1664 approach of translating immediately before every use of yytoken.
1665 One alternative is translating here after every semantic action,
1666 but that translation would be missed if the semantic action invokes
1667 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1668 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1669 incorrect destructor might then be invoked immediately. In the
1670 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1671 to an incorrect destructor call or verbose syntax error message
1672 before the lookahead is translated. */
1673 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1677 YY_STACK_PRINT (yyss
, yyssp
);
1679 *++yyvsp
= yyval
;]b4_locations_if([
1680 *++yylsp
= yyloc
;])[
1682 /* Now `shift' the result of the reduction. Determine what state
1683 that goes to, based on the state we popped back to and the rule
1684 number reduced by. */
1688 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1689 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1690 yystate
= yytable
[yystate
];
1692 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1697 /*------------------------------------.
1698 | yyerrlab -- here on detecting error |
1699 `------------------------------------*/
1701 /* Make sure we have latest lookahead translation. See comments at
1702 user semantic actions for why this is necessary. */
1703 yytoken
= yychar
== YYEMPTY
? YYEMPTY
: YYTRANSLATE (yychar
);
1705 /* If not already recovering from an error, report this error. */
1709 #if ! YYERROR_VERBOSE
1710 yyerror (]b4_yyerror_args
[YY_("syntax error"));
1712 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, yyssp, \
1715 char const *yymsgp
= YY_("syntax error");
1716 int yysyntax_error_status
;]b4_lac_if([[
1717 if (yychar
!= YYEMPTY
)
1718 YY_LAC_ESTABLISH
;]])[
1719 yysyntax_error_status
= YYSYNTAX_ERROR
;
1720 if (yysyntax_error_status
== 0)
1722 else if (yysyntax_error_status
== 1)
1724 if (yymsg
!= yymsgbuf
)
1725 YYSTACK_FREE (yymsg
);
1726 yymsg
= (char *) YYSTACK_ALLOC (yymsg_alloc
);
1730 yymsg_alloc
= sizeof yymsgbuf
;
1731 yysyntax_error_status
= 2;
1735 yysyntax_error_status
= YYSYNTAX_ERROR
;
1739 yyerror (]b4_yyerror_args
[yymsgp
);
1740 if (yysyntax_error_status
== 2)
1741 goto yyexhaustedlab
;
1743 # undef YYSYNTAX_ERROR
1747 ]b4_locations_if([[ yyerror_range
[1] = yylloc
;]])[
1749 if (yyerrstatus
== 3)
1751 /* If just tried and failed to reuse lookahead token after an
1752 error, discard it. */
1754 if (yychar
<= YYEOF
)
1756 /* Return failure if at end of input. */
1757 if (yychar
== YYEOF
)
1762 yydestruct ("Error: discarding",
1763 yytoken
, &yylval
]b4_locations_if([, &yylloc
])[]b4_user_args
[);
1768 /* Else will try to reuse lookahead token after shifting the error
1773 /*---------------------------------------------------.
1774 | yyerrorlab -- error raised explicitly by YYERROR. |
1775 `---------------------------------------------------*/
1778 /* Pacify compilers like GCC when the user code never invokes
1779 YYERROR and the label yyerrorlab therefore never appears in user
1781 if (/*CONSTCOND*/ 0)
1784 ]b4_locations_if([[ yyerror_range
[1] = yylsp
[1-yylen
];
1785 ]])[ /* Do not reclaim the symbols of the rule which action triggered
1789 YY_STACK_PRINT (yyss
, yyssp
);
1794 /*-------------------------------------------------------------.
1795 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1796 `-------------------------------------------------------------*/
1798 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1802 yyn
= yypact
[yystate
];
1803 if (!yypact_value_is_default (yyn
))
1806 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1814 /* Pop the current state because it cannot handle the error token. */
1818 ]b4_locations_if([[ yyerror_range
[1] = *yylsp
;]])[
1819 yydestruct ("Error: popping",
1820 yystos
[yystate
], yyvsp
]b4_locations_if([, yylsp
])[]b4_user_args
[);
1823 YY_STACK_PRINT (yyss
, yyssp
);
1826 /* If the stack popping above didn't lose the initial context for the
1827 current lookahead token, the shift below will for sure. */
1828 YY_LAC_DISCARD ("error recovery");]])[
1832 yyerror_range
[2] = yylloc
;
1833 /* Using YYLLOC is tempting, but would change the location of
1834 the lookahead. YYLOC is available though. */
1835 YYLLOC_DEFAULT (yyloc
, yyerror_range
, 2);
1836 *++yylsp
= yyloc
;]])[
1838 /* Shift the error token. */
1839 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1845 /*-------------------------------------.
1846 | yyacceptlab -- YYACCEPT comes here. |
1847 `-------------------------------------*/
1852 /*-----------------------------------.
1853 | yyabortlab -- YYABORT comes here. |
1854 `-----------------------------------*/
1859 #if ]b4_lac_if([[1]], [[!defined(yyoverflow) || YYERROR_VERBOSE]])[
1860 /*-------------------------------------------------.
1861 | yyexhaustedlab -- memory exhaustion comes here. |
1862 `-------------------------------------------------*/
1864 yyerror (]b4_yyerror_args
[YY_("memory exhausted"));
1870 if (yychar
!= YYEMPTY
)
1872 /* Make sure we have latest lookahead translation. See comments at
1873 user semantic actions for why this is necessary. */
1874 yytoken
= YYTRANSLATE (yychar
);
1875 yydestruct ("Cleanup: discarding lookahead",
1876 yytoken
, &yylval
]b4_locations_if([, &yylloc
])[]b4_user_args
[);
1878 /* Do not reclaim the symbols of the rule which action triggered
1879 this YYABORT or YYACCEPT. */
1881 YY_STACK_PRINT (yyss
, yyssp
);
1882 while (yyssp
!= yyss
)
1884 yydestruct ("Cleanup: popping",
1885 yystos
[*yyssp
], yyvsp
]b4_locations_if([, yylsp
])[]b4_user_args
[);
1890 YYSTACK_FREE (yyss
);
1891 #endif]b4_push_if([[
1896 if (yymsg
!= yymsgbuf
)
1897 YYSTACK_FREE (yymsg
);
1899 /* Make sure YYID is used. */
1900 return YYID (yyresult
);
1905 [@
output(b4_spec_defines_file@
)@
1906 b4_copyright([Interface
for Bison
's Yacc-like parsers in C])dnl
1908 b4_percent_code_get([[requires]])[]dnl
1910 b4_token_enums_defines(b4_tokens)
1912 [#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1913 ]m4_ifdef([b4_stype],
1914 [[typedef union ]b4_union_name[
1918 # define YYSTYPE_IS_TRIVIAL 1]],
1919 [m4_if(b4_tag_seen_flag, 0,
1920 [[typedef int YYSTYPE;
1921 # define YYSTYPE_IS_TRIVIAL 1]])])[
1922 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1923 # define YYSTYPE_IS_DECLARED 1
1926 ]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;]])
1929 [#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
1930 typedef struct YYLTYPE
1937 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
1938 # define YYLTYPE_IS_DECLARED 1
1939 # define YYLTYPE_IS_TRIVIAL 1
1942 ]b4_pure_if([], [[extern YYLTYPE ]b4_prefix[lloc;]])
1943 )dnl b4_locations_if
1945 #ifndef YYPUSH_DECLS
1946 # define YYPUSH_DECLS
1947 struct ]b4_prefix[pstate;
1948 typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
1949 enum { YYPUSH_MORE = 4 };
1950 ]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
1951 ])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
1952 [[b4_prefix[pstate *yyps]], [[yyps]]]b4_pure_if([,
1953 [[[int yypushed_char]], [[yypushed_char]]],
1954 [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
1955 [[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
1957 b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
1958 [[b4_prefix[pstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
1960 b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
1962 b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
1963 [[b4_prefix[pstate *yyps]], [[yyps]]])[
1966 b4_percent_code_get([[provides]])[]dnl
1969 m4_popdef([b4_copyright_years])