3 # GLR skeleton for Bison
5 # Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # If we are loaded by glr.cc, do not override c++.m4 definitions by
23 m4_if(b4_skeleton
, ["glr.c"],
24 [m4_include(b4_skeletonsdir
/[c
.m4
])])
27 ## ---------------- ##
29 ## ---------------- ##
32 m4_define_default([b4_stack_depth_max
], [10000])
33 m4_define_default([b4_stack_depth_init
], [200])
37 ## ------------------------ ##
38 ## Pure/impure interfaces. ##
39 ## ------------------------ ##
41 b4_define_flag_if([pure
])
42 # If glr.cc is including this file and thus has already set b4_pure_flag,
43 # do not change the value of b4_pure_flag, and do not record a use of api.pure.
44 m4_ifndef([b4_pure_flag
],
45 [b4_percent_define_default([[api
.pure
]], [[false]])
46 m4_define([b4_pure_flag
],
47 [b4_percent_define_flag_if([[api
.pure
]], [[1]], [[0]])])])
51 # Optional effective arguments passed to yyerror: user args plus yylloc, and
53 m4_define([b4_yyerror_args
],
54 [b4_pure_if([b4_locations_if([yylocp
, ])])dnl
55 m4_ifset([b4_parse_param
], [b4_args(b4_parse_param
), ])])
60 # Same as above, but on the lookahead, hence &yylloc instead of yylocp.
61 m4_define([b4_lyyerror_args
],
62 [b4_pure_if([b4_locations_if([&yylloc
, ])])dnl
63 m4_ifset([b4_parse_param
], [b4_args(b4_parse_param
), ])])
68 # Same as b4_yyerror_args, but with a leading comma.
69 m4_define([b4_pure_args
],
70 [b4_pure_if([b4_locations_if([, yylocp
])])[]b4_user_args
])
75 # Same as above, but on the lookahead, hence &yylloc instead of yylocp.
76 m4_define([b4_lpure_args
],
77 [b4_pure_if([b4_locations_if([, &yylloc
])])[]b4_user_args
])
83 # Arguments passed to yyerror: user formals plus yylocp with leading comma.
84 m4_define([b4_pure_formals
],
85 [b4_pure_if([b4_locations_if([, YYLTYPE
*yylocp
])])[]b4_user_formals
])
88 # b4_locuser_formals(LOC = yylocp)
89 # --------------------------------
90 # User formal arguments, possibly preceded by location argument.
91 m4_define([b4_locuser_formals
],
92 [b4_locations_if([, YYLTYPE
*m4_default([$
1], [yylocp
])])[]b4_user_formals
])
95 # b4_locuser_args(LOC = yylocp)
96 # -----------------------------
97 m4_define([b4_locuser_args
],
98 [b4_locations_if([, m4_default([$
1], [yylocp
])])[]b4_user_args
])
102 ## ----------------- ##
103 ## Semantic Values. ##
104 ## ----------------- ##
107 # b4_lhs_value(SYMBOL-NUM, [TYPE])
108 # --------------------------------
110 m4_define([b4_lhs_value
],
111 [b4_symbol_value([(*yyvalp
)], [$
1], [$
2])])
114 # b4_rhs_data(RULE-LENGTH, POS)
115 # -----------------------------
117 m4_define([b4_rhs_data
],
118 [YY_CAST (yyGLRStackItem
const *, yyvsp
)@
{YYFILL (b4_subtract([$
2], [$
1]))@
}.yystate
])
121 # b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
122 # --------------------------------------------------
123 # Expansion of $$ or $<TYPE>$, for symbol SYMBOL-NUM.
124 m4_define([b4_rhs_value
],
125 [b4_symbol_value([b4_rhs_data([$
1], [$
2]).yysemantics
.yysval
], [$
3], [$
4])])
136 m4_define([b4_lhs_location
],
140 # b4_rhs_location(RULE-LENGTH, NUM)
141 # ---------------------------------
142 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
144 m4_define([b4_rhs_location
],
145 [(b4_rhs_data([$
1], [$
2]).yyloc
)])
152 # b4_shared_declarations
153 # ----------------------
154 # Declaration that might either go into the header (if --defines)
155 # or open coded in the parser body. glr.cc has its own definition.
156 m4_if(b4_skeleton
, ["glr.c"],
157 [m4_define([b4_shared_declarations
],
159 ]b4_percent_code_get([[requires
]])[
161 ]b4_declare_yylstype
[
162 int ]b4_prefix
[parse (]m4_ifset([b4_parse_param
], [b4_formals(b4_parse_param
)], [void])[);
163 ]b4_percent_code_get([[provides
]])[]dnl
171 # Unfortunately the order of generation between the header and the
172 # implementation file matters (for glr.c) because of the current
173 # implementation of api.value.type=union. In that case we still use a
174 # union for YYSTYPE, but we generate the contents of this union when
175 # setting up YYSTYPE. This is needed for other aspects, such as
176 # defining yy_symbol_value_print, since we need to now the name of the
177 # members of this union.
179 # To avoid this issue, just generate the header before the
180 # implementation file. But we should also make them more independent.
182 # ----------------- #
184 # ----------------- #
186 # glr.cc produces its own header.
189 [b4_output_begin([b4_spec_header_file
])
190 b4_copyright([Skeleton interface
for Bison GLR parsers in C
],
191 [2002-2015, 2018-2020])[
192 ]b4_cpp_guard_open([b4_spec_mapped_header_file
])[
193 ]b4_shared_declarations
[
194 ]b4_cpp_guard_close([b4_spec_mapped_header_file
])[
199 # ------------------------- #
200 # The implementation file. #
201 # ------------------------- #
203 b4_output_begin([b4_parser_file_name
])
204 b4_copyright([Skeleton implementation
for Bison GLR parsers in C
],
205 [2002-2015, 2018-2020])[
206 /* C GLR parser skeleton written by Paul Hilfinger. */
211 ]b4_percent_code_get([[top
]])[
212 ]m4_if(b4_api_prefix
, [yy
], [],
213 [[/* Substitute the type names. */
214 #define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
215 #define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
216 ]m4_if(b4_prefix
, [yy
], [],
217 [[/* Substitute the variable and function names. */
218 #define ]b4_glr_cc_if([yy_parse_impl], [yyparse])[ ]b4_prefix[]b4_glr_cc_if([_parse_impl], [parse])[
219 #define yylex ]b4_prefix[lex
220 #define yyerror ]b4_prefix[error
221 #define yydebug ]b4_prefix[debug]]b4_pure_if([], [[
222 #define yylval ]b4_prefix[lval
223 #define yychar ]b4_prefix[char
224 #define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
225 #define yylloc ]b4_prefix[lloc]])]))[
227 ]b4_user_pre_prologue
[
231 ]b4_defines_if([[#include "@basename(]b4_spec_header_file[@)"]],
232 [b4_shared_declarations
])[
234 ]b4_glr_cc_if([b4_glr_cc_setup
],
235 [b4_declare_symbol_enum
])[
237 /* Default (constant) value used for initialization for null
238 right-hand sides. Unlike the standard yacc.c template, here we set
239 the default value of $$ to a zeroed-out value. Since the default
240 value is undefined, this behavior is technically correct. */
241 static YYSTYPE yyval_default
;]b4_locations_if([[
242 static YYLTYPE yyloc_default
][]b4_yyloc_default
;])[
244 ]b4_user_post_prologue
[
245 ]b4_percent_code_get
[]dnl
253 ]b4_c99_int_type_define
[
254 ]b4_sizes_types_define
[
257 # if defined YYENABLE_NLS && YYENABLE_NLS
259 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
260 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
264 # define YY_(Msgid) Msgid
267 ]b4_has_translations_if([
269 # define N_(Msgid) Msgid
277 # define YYMALLOC malloc
280 # define YYREALLOC realloc
286 # define yyfalse false
288 /* When we move to stdbool, get rid of the various casts to yybool. */
289 typedef signed char yybool
;
296 # define YYJMP_BUF jmp_buf
297 # define YYSETJMP(Env) setjmp (Env)
298 /* Pacify Clang and ICC. */
299 # define YYLONGJMP(Env, Val) \
301 longjmp (Env, Val); \
306 ]b4_attribute_define([noreturn
])[
308 ]b4_parse_assert_if([[#ifdef NDEBUG
309 # define YY_ASSERT(E) ((void) (0 && (E)))
311 # include <assert.h> /* INFRINGES ON USER NAME SPACE */
312 # define YY_ASSERT(E) assert (E)
315 [[#define YY_ASSERT(E) ((void) (0 && (E)))]])[
317 /* YYFINAL -- State number of the termination state. */
318 #define YYFINAL ]b4_final_state_number[
319 /* YYLAST -- Last index in YYTABLE. */
320 #define YYLAST ]b4_last[
322 /* YYNTOKENS -- Number of terminals. */
323 #define YYNTOKENS ]b4_tokens_number[
324 /* YYNNTS -- Number of nonterminals. */
325 #define YYNNTS ]b4_nterms_number[
326 /* YYNRULES -- Number of rules. */
327 #define YYNRULES ]b4_rules_number[
328 /* YYNSTATES -- Number of states. */
329 #define YYNSTATES ]b4_states_number[
330 /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
331 #define YYMAXRHS ]b4_r2_max[
332 /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
333 accessed by $0, $-1, etc., in any rule. */
334 #define YYMAXLEFT ]b4_max_left_semantic_context[
336 /* YYMAXUTOK -- Last valid token kind. */
337 #define YYMAXUTOK ]b4_code_max[
339 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
340 as returned by yylex, with out-of-bounds checking. */
341 ]b4_api_token_raw_if(dnl
342 [[#define YYTRANSLATE(YYX) YY_CAST (yysymbol_kind_t, YYX)]],
343 [[#define YYTRANSLATE(YYX) \
344 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
345 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
346 : ]b4_symbol_prefix[YYUNDEF)
348 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
349 as returned by yylex. */
350 static const ]b4_int_type_for([b4_translate
])[ yytranslate
[] =
355 #if ]b4_api_PREFIX[DEBUG
356 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
357 static const ]b4_int_type_for([b4_rline
])[ yyrline
[] =
363 #define YYPACT_NINF (]b4_pact_ninf[)
364 #define YYTABLE_NINF (]b4_table_ninf[)
366 ]b4_parser_tables_define
[
368 /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
369 static const ]b4_int_type_for([b4_dprec
])[ yydprec
[] =
374 /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
375 static const ]b4_int_type_for([b4_merger
])[ yymerger
[] =
380 /* YYIMMEDIATE[RULE-NUM] -- True iff rule #RULE-NUM is not to be deferred, as
381 in the case of predicates. */
382 static const yybool yyimmediate
[] =
387 /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
388 list of conflicting reductions corresponding to action entry for
389 state STATE-NUM in yytable. 0 means no conflicts. The list in
390 yyconfl is terminated by a rule number of 0. */
391 static const ]b4_int_type_for([b4_conflict_list_heads
])[ yyconflp
[] =
393 ]b4_conflict_list_heads
[
396 /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
397 0, pointed into by YYCONFLP. */
398 ]dnl Do
not use b4_int_type_for here
, since there are places where
399 dnl pointers onto yyconfl are taken
, whose type is
"short*".
400 dnl We probably ought to introduce a type
for confl
.
401 [static const short yyconfl
[] =
403 ]b4_conflicting_rules
[
407 ]b4_yylloc_default_define
[
408 # define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
414 #define yynerrs (yystackp->yyerrcnt)
416 #define yychar (yystackp->yyrawchar)
418 #define yylval (yystackp->yyval)
420 #define yylloc (yystackp->yyloc)
421 m4_if(b4_prefix
[], [yy
], [],
422 [#define b4_prefix[]nerrs yynerrs
423 #define b4_prefix[]char yychar
424 #define b4_prefix[]lval yylval
425 #define b4_prefix[]lloc yylloc])],
426 [YYSTYPE yylval
;]b4_locations_if([[
432 enum { YYENOMEM
= -2 };
434 typedef enum { yyok
, yyaccept
, yyabort
, yyerr
} YYRESULTTAG
;
438 YYRESULTTAG yychk_flag = YYE; \
439 if (yychk_flag != yyok) \
443 /* YYINITDEPTH -- initial size of the parser's stacks. */
445 # define YYINITDEPTH ]b4_stack_depth_init[
448 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
449 if the built-in stack extension method is used).
451 Do not make this value too large; the results are undefined if
452 SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
453 evaluated with infinite-precision integer arithmetic. */
456 # define YYMAXDEPTH ]b4_stack_depth_max[
459 /* Minimum number of free items on the stack allowed after an
460 allocation. This is to allow allocation and initialization
461 to be completed by functions that call yyexpandGLRStack before the
462 stack is expanded, thus insuring that all necessary pointers get
463 properly redirected to new data. */
466 #ifndef YYSTACKEXPANDABLE
467 # define YYSTACKEXPANDABLE 1
470 #if YYSTACKEXPANDABLE
471 # define YY_RESERVE_GLRSTACK(Yystack) \
473 if (Yystack->yyspaceLeft < YYHEADROOM) \
474 yyexpandGLRStack (Yystack); \
477 # define YY_RESERVE_GLRSTACK(Yystack) \
479 if (Yystack->yyspaceLeft < YYHEADROOM) \
480 yyMemoryExhausted (Yystack); \
484 /** State numbers. */
485 typedef int yy_state_t
;
488 typedef int yyRuleNum
;
490 /** Item references. */
491 typedef short yyItemNum
;
493 typedef struct yyGLRState yyGLRState
;
494 typedef struct yyGLRStateSet yyGLRStateSet
;
495 typedef struct yySemanticOption yySemanticOption
;
496 typedef union yyGLRStackItem yyGLRStackItem
;
497 typedef struct yyGLRStack yyGLRStack
;
500 /** Type tag: always true. */
502 /** Type tag for yysemantics. If true, yysval applies, otherwise
503 * yyfirstVal applies. */
505 /** Number of corresponding LALR(1) machine state. */
506 yy_state_t yylrState
;
507 /** Preceding state in this stack */
509 /** Source position of the last token produced by my symbol */
512 /** First in a chain of alternative reductions producing the
513 * nonterminal corresponding to this state, threaded through
515 yySemanticOption
* yyfirstVal
;
516 /** Semantic value for this state. */
518 } yysemantics
;]b4_locations_if([[
519 /** Source location for this state. */
523 struct yyGLRStateSet
{
524 yyGLRState
** yystates
;
525 /** During nondeterministic operation, yylookaheadNeeds tracks which
526 * stacks have actually needed the current lookahead. During deterministic
527 * operation, yylookaheadNeeds[0] is not maintained since it would merely
528 * duplicate yychar != ]b4_symbol(-2, id)[. */
529 yybool
* yylookaheadNeeds
;
531 YYPTRDIFF_T yycapacity
;
534 struct yySemanticOption
{
535 /** Type tag: always false. */
537 /** Rule number for this reduction */
539 /** The last RHS state in the list of states to be reduced. */
541 /** The lookahead for this reduction. */
543 YYSTYPE yyval
;]b4_locations_if([[
545 /** Next sibling in chain of options. To facilitate merging,
546 * options are chained in decreasing order by address. */
547 yySemanticOption
* yynext
;
550 /** Type of the items in the GLR stack. The yyisState field
551 * indicates which item of the union is valid. */
552 union yyGLRStackItem
{
554 yySemanticOption yyoption
;
559 ]b4_locations_if([[ /* To compute the location of the error token. */
560 yyGLRStackItem yyerror_range
[3];]])[
565 YYSTYPE yyval
;]b4_locations_if([[
568 YYJMP_BUF yyexception_buffer
;
569 yyGLRStackItem
* yyitems
;
570 yyGLRStackItem
* yynextFree
;
571 YYPTRDIFF_T yyspaceLeft
;
572 yyGLRState
* yysplitPoint
;
573 yyGLRState
* yylastDeleted
;
574 yyGLRStateSet yytops
;
577 #if YYSTACKEXPANDABLE
578 static void yyexpandGLRStack (yyGLRStack
* yystackp
);
581 _Noreturn
static void
582 yyFail (yyGLRStack
* yystackp
]b4_pure_formals
[, const char* yymsg
)
584 if (yymsg
!= YY_NULLPTR
)
585 yyerror (]b4_yyerror_args
[yymsg
);
586 YYLONGJMP (yystackp
->yyexception_buffer
, 1);
589 _Noreturn
static void
590 yyMemoryExhausted (yyGLRStack
* yystackp
)
592 YYLONGJMP (yystackp
->yyexception_buffer
, 2);
595 /** Accessing symbol of state YYSTATE. */
596 static inline yysymbol_kind_t
597 yy_accessing_symbol (yy_state_t yystate
)
599 return YY_CAST (yysymbol_kind_t
, yystos
[yystate
]);
602 #if ]b4_parse_error_case([simple], [b4_api_PREFIX[DEBUG || ]b4_token_table_flag], [[1]])[
603 /* The user-facing name of the symbol whose (internal) number is
604 YYSYMBOL. No bounds checking. */
605 static const char *yysymbol_name (yysymbol_kind_t yysymbol
) YY_ATTRIBUTE_UNUSED
;
607 ]b4_parse_error_bmatch([simple\
|verbose
],
608 [[/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
609 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
610 static const char *const yytname
[] =
616 yysymbol_name (yysymbol_kind_t yysymbol
)
618 return yytname
[yysymbol
];
620 [[static const char *
621 yysymbol_name (yysymbol_kind_t yysymbol
)
623 static const char *const yy_sname
[] =
626 };]b4_has_translations_if([[
627 /* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
628 internationalizable. */
629 static ]b4_int_type_for([b4_translatable
])[ yytranslatable
[] =
633 return (yysymbol
< YYNTOKENS
&& yytranslatable
[yysymbol
]
634 ? _(yy_sname
[yysymbol
])
635 : yy_sname
[yysymbol
]);]], [[
636 return yy_sname
[yysymbol
];]])[
640 #if ]b4_api_PREFIX[DEBUG
643 # define YYFPRINTF fprintf
646 # define YY_FPRINTF \
647 YY_IGNORE_USELESS_CAST_BEGIN YY_FPRINTF_
649 # define YY_FPRINTF_(Args) \
652 YY_IGNORE_USELESS_CAST_END \
655 # define YY_DPRINTF \
656 YY_IGNORE_USELESS_CAST_BEGIN YY_DPRINTF_
658 # define YY_DPRINTF_(Args) \
662 YY_IGNORE_USELESS_CAST_END \
665 ]b4_yy_location_print_define
[
667 ]b4_yy_symbol_print_define
[
669 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
673 YY_FPRINTF ((stderr, "%s ", Title)); \
674 yy_symbol_print (stderr, Kind, Value]b4_locuser_args([Location])[); \
675 YY_FPRINTF ((stderr, "\n")); \
679 /* Nonzero means print parse trace. It is left uninitialized so that
680 multiple parsers can coexist. */
683 static void yypstack (yyGLRStack
* yystackp
, YYPTRDIFF_T yyk
)
685 static void yypdumpstack (yyGLRStack
* yystackp
)
688 #else /* !]b4_api_PREFIX[DEBUG */
690 # define YY_DPRINTF(Args) do {} while (yyfalse)
691 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
693 #endif /* !]b4_api_PREFIX[DEBUG */
695 ]b4_parse_error_case(
699 # define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
702 ]b4_parse_error_bmatch(
705 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
706 # define yystpcpy stpcpy
708 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
711 yystpcpy (char *yydest
, const char *yysrc
)
714 const char *yys
= yysrc
;
716 while ((*yyd
++ = *yys
++) != '\0')
724 ]b4_parse_error_case(
727 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
728 quotes and backslashes, so that it's suitable for yyerror. The
729 heuristic is that double-quoting is unnecessary unless the string
730 contains an apostrophe, a comma, or backslash (other than
731 backslash-backslash). YYSTR is taken from yytname. If YYRES is
732 null, do not copy; instead, return the length of what the result
735 yytnamerr (char *yyres
, const char *yystr
)
740 char const *yyp
= yystr
;
747 goto do_not_strip_quotes
;
751 goto do_not_strip_quotes
;
767 do_not_strip_quotes
: ;
771 return yystpcpy (yyres
, yystr
) - yyres
;
773 return yystrlen (yystr
);
778 /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
779 * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
780 * containing the pointer to the next state in the chain. */
781 static void yyfillin (yyGLRStackItem
*, int, int) YY_ATTRIBUTE_UNUSED
;
783 yyfillin (yyGLRStackItem
*yyvsp
, int yylow0
, int yylow1
)
786 yyGLRState
*s
= yyvsp
[yylow0
].yystate
.yypred
;
787 for (i
= yylow0
-1; i
>= yylow1
; i
-= 1)
789 #if ]b4_api_PREFIX[DEBUG
790 yyvsp
[i
].yystate
.yylrState
= s
->yylrState
;
792 yyvsp
[i
].yystate
.yyresolved
= s
->yyresolved
;
794 yyvsp
[i
].yystate
.yysemantics
.yysval
= s
->yysemantics
.yysval
;
796 /* The effect of using yysval or yyloc (in an immediate rule) is
798 yyvsp
[i
].yystate
.yysemantics
.yyfirstVal
= YY_NULLPTR
;]b4_locations_if([[
799 yyvsp
[i
].yystate
.yyloc
= s
->yyloc
;]])[
800 s
= yyvsp
[i
].yystate
.yypred
= s
->yypred
;
804 ]m4_define([b4_yygetToken_call
],
805 [[yygetToken (&yychar
][]b4_pure_if([, yystackp
])[]b4_user_args
[)]])[
806 /** If yychar is empty, fetch the next token. */
807 static inline yysymbol_kind_t
808 yygetToken (int *yycharp
][]b4_pure_if([, yyGLRStack
* yystackp
])[]b4_user_formals
[)
810 yysymbol_kind_t yytoken
;
811 ]b4_parse_param_use()dnl
812 [ if (*yycharp
== ]b4_symbol(-2, id
)[)
814 YY_DPRINTF ((stderr
, "Reading a token\n"));]b4_glr_cc_if([[
818 #endif // YY_EXCEPTIONS
822 catch (const ]b4_namespace_ref
[::]b4_parser_class
[::syntax_error
& yyexc
)
824 YY_DPRINTF ((stderr
, "Caught exception: %s\n", yyexc
.what()));]b4_locations_if([
825 yylloc
= yyexc
.location
;])[
826 yyerror (]b4_lyyerror_args
[yyexc
.what ());
827 // Map errors caught in the scanner to the undefined token,
828 // so that error handling is started. However, record this
829 // with this special value of yychar.
830 *yycharp
= ]b4_symbol(1, id
)[;
832 #endif // YY_EXCEPTIONS]], [[
833 *yycharp
= ]b4_lex
[;]])[
835 if (*yycharp
<= ]b4_symbol(0, [id
])[)
837 *yycharp
= ]b4_symbol(0, [id
])[;
838 yytoken
= ]b4_symbol_prefix
[YYEOF
;
839 YY_DPRINTF ((stderr
, "Now at end of input.\n"));
843 yytoken
= YYTRANSLATE (*yycharp
);
844 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
849 /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
850 * YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
851 * For convenience, always return YYLOW1. */
852 static inline int yyfill (yyGLRStackItem
*, int *, int, yybool
)
855 yyfill (yyGLRStackItem
*yyvsp
, int *yylow
, int yylow1
, yybool yynormal
)
857 if (!yynormal
&& yylow1
< *yylow
)
859 yyfillin (yyvsp
, *yylow
, yylow1
);
865 /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
866 * and top stack item YYVSP. YYLVALP points to place to put semantic
867 * value ($$), and yylocp points to place for location information
868 * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
869 * yyerr for YYERROR, yyabort for YYABORT. */
871 yyuserAction (yyRuleNum yyn
, int yyrhslen
, yyGLRStackItem
* yyvsp
,
872 yyGLRStack
* yystackp
,
873 YYSTYPE
* yyvalp
]b4_locuser_formals
[)
875 yybool yynormal YY_ATTRIBUTE_UNUSED
= yystackp
->yysplitPoint
== YY_NULLPTR
;
877 ]b4_parse_param_use([yyvalp
], [yylocp
])dnl
880 # define yyerrok (yystackp->yyerrState = 0)
882 # define YYACCEPT return yyaccept
884 # define YYABORT return yyabort
886 # define YYERROR return yyerrok, yyerr
888 # define YYRECOVERING() (yystackp->yyerrState != 0)
890 # define yyclearin (yychar = ]b4_symbol(-2, id)[)
892 # define YYFILL(N) yyfill (yyvsp, &yylow, (N), yynormal)
894 # define YYBACKUP(Token, Value) \
895 return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
900 *yyvalp
= yyval_default
;
902 *yyvalp
= yyvsp
[YYFILL (1-yyrhslen
)].yystate
.yysemantics
.yysval
;]b4_locations_if([[
903 /* Default location. */
904 YYLLOC_DEFAULT ((*yylocp
), (yyvsp
- yyrhslen
), yyrhslen
);
905 yystackp
->yyerror_range
[1].yystate
.yyloc
= *yylocp
;
908 typedef ]b4_namespace_ref
[::]b4_parser_class
[::syntax_error syntax_error
;
911 #endif // YY_EXCEPTIONS]])[
919 catch (const syntax_error
& yyexc
)
921 YY_DPRINTF ((stderr
, "Caught exception: %s\n", yyexc
.what()));]b4_locations_if([
922 *yylocp
= yyexc
.location
;])[
923 yyerror (]b4_yyerror_args
[yyexc
.what ());
926 #endif // YY_EXCEPTIONS]])[
940 yyuserMerge (int yyn
, YYSTYPE
* yy0
, YYSTYPE
* yy1
)
952 /* Bison grammar-table manipulation. */
954 ]b4_yydestruct_define
[
956 /** Number of symbols composing the right hand side of rule #RULE. */
958 yyrhsLength (yyRuleNum yyrule
)
964 yydestroyGLRState (char const *yymsg
, yyGLRState
*yys
]b4_user_formals
[)
967 yydestruct (yymsg
, yy_accessing_symbol (yys
->yylrState
),
968 &yys
->yysemantics
.yysval
]b4_locuser_args([&yys
->yyloc
])[);
971 #if ]b4_api_PREFIX[DEBUG
974 if (yys
->yysemantics
.yyfirstVal
)
975 YY_FPRINTF ((stderr
, "%s unresolved", yymsg
));
977 YY_FPRINTF ((stderr
, "%s incomplete", yymsg
));
978 YY_SYMBOL_PRINT ("", yy_accessing_symbol (yys
->yylrState
), YY_NULLPTR
, &yys
->yyloc
);
982 if (yys
->yysemantics
.yyfirstVal
)
984 yySemanticOption
*yyoption
= yys
->yysemantics
.yyfirstVal
;
987 for (yyrh
= yyoption
->yystate
, yyn
= yyrhsLength (yyoption
->yyrule
);
989 yyrh
= yyrh
->yypred
, yyn
-= 1)
990 yydestroyGLRState (yymsg
, yyrh
]b4_user_args
[);
995 /** Left-hand-side symbol for rule #YYRULE. */
996 static inline yysymbol_kind_t
997 yylhsNonterm (yyRuleNum yyrule
)
999 return YY_CAST (yysymbol_kind_t
, yyr1
[yyrule
]);
1002 #define yypact_value_is_default(Yyn) \
1003 ]b4_table_value_equals([[pact]], [[Yyn]], [b4_pact_ninf], [YYPACT_NINF])[
1005 /** True iff LR state YYSTATE has only a default reduction (regardless
1007 static inline yybool
1008 yyisDefaultedState (yy_state_t yystate
)
1010 return yypact_value_is_default (yypact
[yystate
]);
1013 /** The default reduction for YYSTATE, assuming it has one. */
1014 static inline yyRuleNum
1015 yydefaultAction (yy_state_t yystate
)
1017 return yydefact
[yystate
];
1020 #define yytable_value_is_error(Yyn) \
1021 ]b4_table_value_equals([[table]], [[Yyn]], [b4_table_ninf], [YYTABLE_NINF])[
1023 /** The action to take in YYSTATE on seeing YYTOKEN.
1025 * R < 0: Reduce on rule -R.
1027 * R > 0: Shift to state R.
1028 * Set *YYCONFLICTS to a pointer into yyconfl to a 0-terminated list
1029 * of conflicting reductions.
1032 yygetLRActions (yy_state_t yystate
, yysymbol_kind_t yytoken
, const short** yyconflicts
)
1034 int yyindex
= yypact
[yystate
] + yytoken
;
1035 if (yytoken
== ]b4_symbol(1, kind
)[)
1037 // This is the error token.
1038 *yyconflicts
= yyconfl
;
1041 else if (yyisDefaultedState (yystate
)
1042 || yyindex
< 0 || YYLAST
< yyindex
|| yycheck
[yyindex
] != yytoken
)
1044 *yyconflicts
= yyconfl
;
1045 return -yydefact
[yystate
];
1047 else if (! yytable_value_is_error (yytable
[yyindex
]))
1049 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
1050 return yytable
[yyindex
];
1054 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
1059 /** Compute post-reduction state.
1060 * \param yystate the current state
1061 * \param yysym the nonterminal to push on the stack
1063 static inline yy_state_t
1064 yyLRgotoState (yy_state_t yystate
, yysymbol_kind_t yysym
)
1066 int yyr
= yypgoto
[yysym
- YYNTOKENS
] + yystate
;
1067 if (0 <= yyr
&& yyr
<= YYLAST
&& yycheck
[yyr
] == yystate
)
1068 return yytable
[yyr
];
1070 return yydefgoto
[yysym
- YYNTOKENS
];
1073 static inline yybool
1074 yyisShiftAction (int yyaction
)
1076 return 0 < yyaction
;
1079 static inline yybool
1080 yyisErrorAction (int yyaction
)
1082 return yyaction
== 0;
1087 /** Return a fresh GLRStackItem in YYSTACKP. The item is an LR state
1088 * if YYISSTATE, and otherwise a semantic option. Callers should call
1089 * YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
1092 static inline yyGLRStackItem
*
1093 yynewGLRStackItem (yyGLRStack
* yystackp
, yybool yyisState
)
1095 yyGLRStackItem
* yynewItem
= yystackp
->yynextFree
;
1096 yystackp
->yyspaceLeft
-= 1;
1097 yystackp
->yynextFree
+= 1;
1098 yynewItem
->yystate
.yyisState
= yyisState
;
1102 /** Add a new semantic action that will execute the action for rule
1103 * YYRULE on the semantic values in YYRHS to the list of
1104 * alternative actions for YYSTATE. Assumes that YYRHS comes from
1105 * stack #YYK of *YYSTACKP. */
1107 yyaddDeferredAction (yyGLRStack
* yystackp
, YYPTRDIFF_T yyk
, yyGLRState
* yystate
,
1108 yyGLRState
* yyrhs
, yyRuleNum yyrule
)
1110 yySemanticOption
* yynewOption
=
1111 &yynewGLRStackItem (yystackp
, yyfalse
)->yyoption
;
1112 YY_ASSERT (!yynewOption
->yyisState
);
1113 yynewOption
->yystate
= yyrhs
;
1114 yynewOption
->yyrule
= yyrule
;
1115 if (yystackp
->yytops
.yylookaheadNeeds
[yyk
])
1117 yynewOption
->yyrawchar
= yychar
;
1118 yynewOption
->yyval
= yylval
;]b4_locations_if([
1119 yynewOption
->yyloc
= yylloc
;])[
1122 yynewOption
->yyrawchar
= ]b4_symbol(-2, id
)[;
1123 yynewOption
->yynext
= yystate
->yysemantics
.yyfirstVal
;
1124 yystate
->yysemantics
.yyfirstVal
= yynewOption
;
1126 YY_RESERVE_GLRSTACK (yystackp
);
1131 /** Initialize YYSET to a singleton set containing an empty stack. */
1133 yyinitStateSet (yyGLRStateSet
* yyset
)
1136 yyset
->yycapacity
= 16;
1138 = YY_CAST (yyGLRState
**,
1139 YYMALLOC (YY_CAST (YYSIZE_T
, yyset
->yycapacity
)
1140 * sizeof yyset
->yystates
[0]));
1141 if (! yyset
->yystates
)
1143 yyset
->yystates
[0] = YY_NULLPTR
;
1144 yyset
->yylookaheadNeeds
1146 YYMALLOC (YY_CAST (YYSIZE_T
, yyset
->yycapacity
)
1147 * sizeof yyset
->yylookaheadNeeds
[0]));
1148 if (! yyset
->yylookaheadNeeds
)
1150 YYFREE (yyset
->yystates
);
1153 memset (yyset
->yylookaheadNeeds
,
1155 YY_CAST (YYSIZE_T
, yyset
->yycapacity
) * sizeof yyset
->yylookaheadNeeds
[0]);
1159 static void yyfreeStateSet (yyGLRStateSet
* yyset
)
1161 YYFREE (yyset
->yystates
);
1162 YYFREE (yyset
->yylookaheadNeeds
);
1165 /** Initialize *YYSTACKP to a single empty stack, with total maximum
1166 * capacity for all stacks of YYSIZE. */
1168 yyinitGLRStack (yyGLRStack
* yystackp
, YYPTRDIFF_T yysize
)
1170 yystackp
->yyerrState
= 0;
1172 yystackp
->yyspaceLeft
= yysize
;
1174 = YY_CAST (yyGLRStackItem
*,
1175 YYMALLOC (YY_CAST (YYSIZE_T
, yysize
)
1176 * sizeof yystackp
->yynextFree
[0]));
1177 if (!yystackp
->yyitems
)
1179 yystackp
->yynextFree
= yystackp
->yyitems
;
1180 yystackp
->yysplitPoint
= YY_NULLPTR
;
1181 yystackp
->yylastDeleted
= YY_NULLPTR
;
1182 return yyinitStateSet (&yystackp
->yytops
);
1186 #if YYSTACKEXPANDABLE
1187 # define YYRELOC(YYFROMITEMS, YYTOITEMS, YYX, YYTYPE) \
1189 - ((YYFROMITEMS) - YY_REINTERPRET_CAST (yyGLRStackItem*, (YYX))))->YYTYPE
1191 /** If *YYSTACKP is expandable, extend it. WARNING: Pointers into the
1192 stack from outside should be considered invalid after this call.
1193 We always expand when there are 1 or fewer items left AFTER an
1194 allocation, so that we can avoid having external pointers exist
1195 across an allocation. */
1197 yyexpandGLRStack (yyGLRStack
* yystackp
)
1199 yyGLRStackItem
* yynewItems
;
1200 yyGLRStackItem
* yyp0
, *yyp1
;
1201 YYPTRDIFF_T yynewSize
;
1203 YYPTRDIFF_T yysize
= yystackp
->yynextFree
- yystackp
->yyitems
;
1204 if (YYMAXDEPTH
- YYHEADROOM
< yysize
)
1205 yyMemoryExhausted (yystackp
);
1206 yynewSize
= 2*yysize
;
1207 if (YYMAXDEPTH
< yynewSize
)
1208 yynewSize
= YYMAXDEPTH
;
1210 = YY_CAST (yyGLRStackItem
*,
1211 YYMALLOC (YY_CAST (YYSIZE_T
, yynewSize
)
1212 * sizeof yynewItems
[0]));
1214 yyMemoryExhausted (yystackp
);
1215 for (yyp0
= yystackp
->yyitems
, yyp1
= yynewItems
, yyn
= yysize
;
1217 yyn
-= 1, yyp0
+= 1, yyp1
+= 1)
1220 if (*YY_REINTERPRET_CAST (yybool
*, yyp0
))
1222 yyGLRState
* yys0
= &yyp0
->yystate
;
1223 yyGLRState
* yys1
= &yyp1
->yystate
;
1224 if (yys0
->yypred
!= YY_NULLPTR
)
1226 YYRELOC (yyp0
, yyp1
, yys0
->yypred
, yystate
);
1227 if (! yys0
->yyresolved
&& yys0
->yysemantics
.yyfirstVal
!= YY_NULLPTR
)
1228 yys1
->yysemantics
.yyfirstVal
=
1229 YYRELOC (yyp0
, yyp1
, yys0
->yysemantics
.yyfirstVal
, yyoption
);
1233 yySemanticOption
* yyv0
= &yyp0
->yyoption
;
1234 yySemanticOption
* yyv1
= &yyp1
->yyoption
;
1235 if (yyv0
->yystate
!= YY_NULLPTR
)
1236 yyv1
->yystate
= YYRELOC (yyp0
, yyp1
, yyv0
->yystate
, yystate
);
1237 if (yyv0
->yynext
!= YY_NULLPTR
)
1238 yyv1
->yynext
= YYRELOC (yyp0
, yyp1
, yyv0
->yynext
, yyoption
);
1241 if (yystackp
->yysplitPoint
!= YY_NULLPTR
)
1242 yystackp
->yysplitPoint
= YYRELOC (yystackp
->yyitems
, yynewItems
,
1243 yystackp
->yysplitPoint
, yystate
);
1245 for (yyn
= 0; yyn
< yystackp
->yytops
.yysize
; yyn
+= 1)
1246 if (yystackp
->yytops
.yystates
[yyn
] != YY_NULLPTR
)
1247 yystackp
->yytops
.yystates
[yyn
] =
1248 YYRELOC (yystackp
->yyitems
, yynewItems
,
1249 yystackp
->yytops
.yystates
[yyn
], yystate
);
1250 YYFREE (yystackp
->yyitems
);
1251 yystackp
->yyitems
= yynewItems
;
1252 yystackp
->yynextFree
= yynewItems
+ yysize
;
1253 yystackp
->yyspaceLeft
= yynewSize
- yysize
;
1258 yyfreeGLRStack (yyGLRStack
* yystackp
)
1260 YYFREE (yystackp
->yyitems
);
1261 yyfreeStateSet (&yystackp
->yytops
);
1264 /** Assuming that YYS is a GLRState somewhere on *YYSTACKP, update the
1265 * splitpoint of *YYSTACKP, if needed, so that it is at least as deep as
1268 yyupdateSplit (yyGLRStack
* yystackp
, yyGLRState
* yys
)
1270 if (yystackp
->yysplitPoint
!= YY_NULLPTR
&& yystackp
->yysplitPoint
> yys
)
1271 yystackp
->yysplitPoint
= yys
;
1274 /** Invalidate stack #YYK in *YYSTACKP. */
1276 yymarkStackDeleted (yyGLRStack
* yystackp
, YYPTRDIFF_T yyk
)
1278 if (yystackp
->yytops
.yystates
[yyk
] != YY_NULLPTR
)
1279 yystackp
->yylastDeleted
= yystackp
->yytops
.yystates
[yyk
];
1280 yystackp
->yytops
.yystates
[yyk
] = YY_NULLPTR
;
1283 /** Undelete the last stack in *YYSTACKP that was marked as deleted. Can
1284 only be done once after a deletion, and only when all other stacks have
1287 yyundeleteLastStack (yyGLRStack
* yystackp
)
1289 if (yystackp
->yylastDeleted
== YY_NULLPTR
|| yystackp
->yytops
.yysize
!= 0)
1291 yystackp
->yytops
.yystates
[0] = yystackp
->yylastDeleted
;
1292 yystackp
->yytops
.yysize
= 1;
1293 YY_DPRINTF ((stderr
, "Restoring last deleted stack as stack #0.\n"));
1294 yystackp
->yylastDeleted
= YY_NULLPTR
;
1298 yyremoveDeletes (yyGLRStack
* yystackp
)
1300 YYPTRDIFF_T yyi
, yyj
;
1302 while (yyj
< yystackp
->yytops
.yysize
)
1304 if (yystackp
->yytops
.yystates
[yyi
] == YY_NULLPTR
)
1307 YY_DPRINTF ((stderr
, "Removing dead stacks.\n"));
1308 yystackp
->yytops
.yysize
-= 1;
1312 yystackp
->yytops
.yystates
[yyj
] = yystackp
->yytops
.yystates
[yyi
];
1313 /* In the current implementation, it's unnecessary to copy
1314 yystackp->yytops.yylookaheadNeeds[yyi] since, after
1315 yyremoveDeletes returns, the parser immediately either enters
1316 deterministic operation or shifts a token. However, it doesn't
1317 hurt, and the code might evolve to need it. */
1318 yystackp
->yytops
.yylookaheadNeeds
[yyj
] =
1319 yystackp
->yytops
.yylookaheadNeeds
[yyi
];
1321 YY_DPRINTF ((stderr
, "Rename stack %ld -> %ld.\n",
1322 YY_CAST (long, yyi
), YY_CAST (long, yyj
)));
1329 /** Shift to a new state on stack #YYK of *YYSTACKP, corresponding to LR
1330 * state YYLRSTATE, at input position YYPOSN, with (resolved) semantic
1331 * value *YYVALP and source location *YYLOCP. */
1333 yyglrShift (yyGLRStack
* yystackp
, YYPTRDIFF_T yyk
, yy_state_t yylrState
,
1335 YYSTYPE
* yyvalp
]b4_locations_if([, YYLTYPE
* yylocp
])[)
1337 yyGLRState
* yynewState
= &yynewGLRStackItem (yystackp
, yytrue
)->yystate
;
1339 yynewState
->yylrState
= yylrState
;
1340 yynewState
->yyposn
= yyposn
;
1341 yynewState
->yyresolved
= yytrue
;
1342 yynewState
->yypred
= yystackp
->yytops
.yystates
[yyk
];
1343 yynewState
->yysemantics
.yysval
= *yyvalp
;]b4_locations_if([
1344 yynewState
->yyloc
= *yylocp
;])[
1345 yystackp
->yytops
.yystates
[yyk
] = yynewState
;
1347 YY_RESERVE_GLRSTACK (yystackp
);
1350 /** Shift stack #YYK of *YYSTACKP, to a new state corresponding to LR
1351 * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
1352 * semantic value of YYRHS under the action for YYRULE. */
1354 yyglrShiftDefer (yyGLRStack
* yystackp
, YYPTRDIFF_T yyk
, yy_state_t yylrState
,
1355 YYPTRDIFF_T yyposn
, yyGLRState
* yyrhs
, yyRuleNum yyrule
)
1357 yyGLRState
* yynewState
= &yynewGLRStackItem (yystackp
, yytrue
)->yystate
;
1358 YY_ASSERT (yynewState
->yyisState
);
1360 yynewState
->yylrState
= yylrState
;
1361 yynewState
->yyposn
= yyposn
;
1362 yynewState
->yyresolved
= yyfalse
;
1363 yynewState
->yypred
= yystackp
->yytops
.yystates
[yyk
];
1364 yynewState
->yysemantics
.yyfirstVal
= YY_NULLPTR
;
1365 yystackp
->yytops
.yystates
[yyk
] = yynewState
;
1367 /* Invokes YY_RESERVE_GLRSTACK. */
1368 yyaddDeferredAction (yystackp
, yyk
, yynewState
, yyrhs
, yyrule
);
1371 #if !]b4_api_PREFIX[DEBUG
1372 # define YY_REDUCE_PRINT(Args)
1374 # define YY_REDUCE_PRINT(Args) \
1377 yy_reduce_print Args; \
1380 /*----------------------------------------------------------------------.
1381 | Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. |
1382 `----------------------------------------------------------------------*/
1385 yy_reduce_print (yybool yynormal
, yyGLRStackItem
* yyvsp
, YYPTRDIFF_T yyk
,
1386 yyRuleNum yyrule
]b4_user_formals
[)
1388 int yynrhs
= yyrhsLength (yyrule
);]b4_locations_if([
1391 YY_FPRINTF ((stderr
, "Reducing stack %ld by rule %d (line %d):\n",
1392 YY_CAST (long, yyk
), yyrule
- 1, yyrline
[yyrule
]));
1394 yyfillin (yyvsp
, 1, -yynrhs
);
1395 /* The symbols being reduced. */
1396 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
1398 YY_FPRINTF ((stderr
, " $%d = ", yyi
+ 1));
1399 yy_symbol_print (stderr
,
1400 yy_accessing_symbol (yyvsp
[yyi
- yynrhs
+ 1].yystate
.yylrState
),
1401 &yyvsp
[yyi
- yynrhs
+ 1].yystate
.yysemantics
.yysval
]b4_locations_if([,
1402 &]b4_rhs_location(yynrhs
, yyi
+ 1))[]dnl
1404 if (!yyvsp
[yyi
- yynrhs
+ 1].yystate
.yyresolved
)
1405 YY_FPRINTF ((stderr
, " (unresolved)"));
1406 YY_FPRINTF ((stderr
, "\n"));
1411 /** Pop the symbols consumed by reduction #YYRULE from the top of stack
1412 * #YYK of *YYSTACKP, and perform the appropriate semantic action on their
1413 * semantic values. Assumes that all ambiguities in semantic values
1414 * have been previously resolved. Set *YYVALP to the resulting value,
1415 * and *YYLOCP to the computed location (if any). Return value is as
1416 * for userAction. */
1417 static inline YYRESULTTAG
1418 yydoAction (yyGLRStack
* yystackp
, YYPTRDIFF_T yyk
, yyRuleNum yyrule
,
1419 YYSTYPE
* yyvalp
]b4_locuser_formals
[)
1421 int yynrhs
= yyrhsLength (yyrule
);
1423 if (yystackp
->yysplitPoint
== YY_NULLPTR
)
1425 /* Standard special case: single stack. */
1426 yyGLRStackItem
* yyrhs
1427 = YY_REINTERPRET_CAST (yyGLRStackItem
*, yystackp
->yytops
.yystates
[yyk
]);
1428 YY_ASSERT (yyk
== 0);
1429 yystackp
->yynextFree
-= yynrhs
;
1430 yystackp
->yyspaceLeft
+= yynrhs
;
1431 yystackp
->yytops
.yystates
[0] = & yystackp
->yynextFree
[-1].yystate
;
1432 YY_REDUCE_PRINT ((yytrue
, yyrhs
, yyk
, yyrule
]b4_user_args
[));
1433 return yyuserAction (yyrule
, yynrhs
, yyrhs
, yystackp
,
1434 yyvalp
]b4_locuser_args
[);
1438 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1439 yyGLRState
* yys
= yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
1440 = yystackp
->yytops
.yystates
[yyk
];
1441 int yyi
;]b4_locations_if([[
1443 /* Set default location. */
1444 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
- 1].yystate
.yyloc
= yys
->yyloc
;]])[
1445 for (yyi
= 0; yyi
< yynrhs
; yyi
+= 1)
1450 yyupdateSplit (yystackp
, yys
);
1451 yystackp
->yytops
.yystates
[yyk
] = yys
;
1452 YY_REDUCE_PRINT ((yyfalse
, yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1, yyk
, yyrule
]b4_user_args
[));
1453 return yyuserAction (yyrule
, yynrhs
, yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1454 yystackp
, yyvalp
]b4_locuser_args
[);
1458 /** Pop items off stack #YYK of *YYSTACKP according to grammar rule YYRULE,
1459 * and push back on the resulting nonterminal symbol. Perform the
1460 * semantic action associated with YYRULE and store its value with the
1461 * newly pushed state, if YYFORCEEVAL or if *YYSTACKP is currently
1462 * unambiguous. Otherwise, store the deferred semantic action with
1463 * the new state. If the new state would have an identical input
1464 * position, LR state, and predecessor to an existing state on the stack,
1465 * it is identified with that existing state, eliminating stack #YYK from
1466 * *YYSTACKP. In this case, the semantic value is
1467 * added to the options for the existing state's semantic value.
1469 static inline YYRESULTTAG
1470 yyglrReduce (yyGLRStack
* yystackp
, YYPTRDIFF_T yyk
, yyRuleNum yyrule
,
1471 yybool yyforceEval
]b4_user_formals
[)
1473 YYPTRDIFF_T yyposn
= yystackp
->yytops
.yystates
[yyk
]->yyposn
;
1475 if (yyforceEval
|| yystackp
->yysplitPoint
== YY_NULLPTR
)
1477 YYSTYPE yysval
;]b4_locations_if([[
1480 YYRESULTTAG yyflag
= yydoAction (yystackp
, yyk
, yyrule
, &yysval
]b4_locuser_args([&yyloc
])[);
1481 if (yyflag
== yyerr
&& yystackp
->yysplitPoint
!= YY_NULLPTR
)
1482 YY_DPRINTF ((stderr
,
1483 "Parse on stack %ld rejected by rule %d (line %d).\n",
1484 YY_CAST (long, yyk
), yyrule
- 1, yyrline
[yyrule
- 1]));
1487 YY_SYMBOL_PRINT ("-> $$ =", yylhsNonterm (yyrule
), &yysval
, &yyloc
);
1488 yyglrShift (yystackp
, yyk
,
1489 yyLRgotoState (yystackp
->yytops
.yystates
[yyk
]->yylrState
,
1490 yylhsNonterm (yyrule
)),
1491 yyposn
, &yysval
]b4_locations_if([, &yyloc
])[);
1497 yyGLRState
* yys
, *yys0
= yystackp
->yytops
.yystates
[yyk
];
1498 yy_state_t yynewLRState
;
1500 for (yys
= yystackp
->yytops
.yystates
[yyk
], yyn
= yyrhsLength (yyrule
);
1506 yyupdateSplit (yystackp
, yys
);
1507 yynewLRState
= yyLRgotoState (yys
->yylrState
, yylhsNonterm (yyrule
));
1508 YY_DPRINTF ((stderr
,
1509 "Reduced stack %ld by rule %d (line %d); action deferred. "
1510 "Now in state %d.\n",
1511 YY_CAST (long, yyk
), yyrule
- 1, yyrline
[yyrule
- 1],
1513 for (yyi
= 0; yyi
< yystackp
->yytops
.yysize
; yyi
+= 1)
1514 if (yyi
!= yyk
&& yystackp
->yytops
.yystates
[yyi
] != YY_NULLPTR
)
1516 yyGLRState
*yysplit
= yystackp
->yysplitPoint
;
1517 yyGLRState
*yyp
= yystackp
->yytops
.yystates
[yyi
];
1518 while (yyp
!= yys
&& yyp
!= yysplit
&& yyp
->yyposn
>= yyposn
)
1520 if (yyp
->yylrState
== yynewLRState
&& yyp
->yypred
== yys
)
1522 yyaddDeferredAction (yystackp
, yyk
, yyp
, yys0
, yyrule
);
1523 yymarkStackDeleted (yystackp
, yyk
);
1524 YY_DPRINTF ((stderr
, "Merging stack %ld into stack %ld.\n",
1525 YY_CAST (long, yyk
), YY_CAST (long, yyi
)));
1531 yystackp
->yytops
.yystates
[yyk
] = yys
;
1532 yyglrShiftDefer (yystackp
, yyk
, yynewLRState
, yyposn
, yys0
, yyrule
);
1538 yysplitStack (yyGLRStack
* yystackp
, YYPTRDIFF_T yyk
)
1540 if (yystackp
->yysplitPoint
== YY_NULLPTR
)
1542 YY_ASSERT (yyk
== 0);
1543 yystackp
->yysplitPoint
= yystackp
->yytops
.yystates
[yyk
];
1545 if (yystackp
->yytops
.yycapacity
<= yystackp
->yytops
.yysize
)
1547 YYPTRDIFF_T state_size
= YYSIZEOF (yystackp
->yytops
.yystates
[0]);
1548 YYPTRDIFF_T half_max_capacity
= YYSIZE_MAXIMUM
/ 2 / state_size
;
1549 if (half_max_capacity
< yystackp
->yytops
.yycapacity
)
1550 yyMemoryExhausted (yystackp
);
1551 yystackp
->yytops
.yycapacity
*= 2;
1554 yyGLRState
** yynewStates
1555 = YY_CAST (yyGLRState
**,
1556 YYREALLOC (yystackp
->yytops
.yystates
,
1557 (YY_CAST (YYSIZE_T
, yystackp
->yytops
.yycapacity
)
1558 * sizeof yynewStates
[0])));
1559 if (yynewStates
== YY_NULLPTR
)
1560 yyMemoryExhausted (yystackp
);
1561 yystackp
->yytops
.yystates
= yynewStates
;
1565 yybool
* yynewLookaheadNeeds
1567 YYREALLOC (yystackp
->yytops
.yylookaheadNeeds
,
1568 (YY_CAST (YYSIZE_T
, yystackp
->yytops
.yycapacity
)
1569 * sizeof yynewLookaheadNeeds
[0])));
1570 if (yynewLookaheadNeeds
== YY_NULLPTR
)
1571 yyMemoryExhausted (yystackp
);
1572 yystackp
->yytops
.yylookaheadNeeds
= yynewLookaheadNeeds
;
1575 yystackp
->yytops
.yystates
[yystackp
->yytops
.yysize
]
1576 = yystackp
->yytops
.yystates
[yyk
];
1577 yystackp
->yytops
.yylookaheadNeeds
[yystackp
->yytops
.yysize
]
1578 = yystackp
->yytops
.yylookaheadNeeds
[yyk
];
1579 yystackp
->yytops
.yysize
+= 1;
1580 return yystackp
->yytops
.yysize
- 1;
1583 /** True iff YYY0 and YYY1 represent identical options at the top level.
1584 * That is, they represent the same rule applied to RHS symbols
1585 * that produce the same terminal symbols. */
1587 yyidenticalOptions (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1589 if (yyy0
->yyrule
== yyy1
->yyrule
)
1591 yyGLRState
*yys0
, *yys1
;
1593 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1594 yyn
= yyrhsLength (yyy0
->yyrule
);
1596 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1597 if (yys0
->yyposn
!= yys1
->yyposn
)
1605 /** Assuming identicalOptions (YYY0,YYY1), destructively merge the
1606 * alternative semantic values for the RHS-symbols of YYY1 and YYY0. */
1608 yymergeOptionSets (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1610 yyGLRState
*yys0
, *yys1
;
1612 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1613 yyn
= yyrhsLength (yyy0
->yyrule
);
1615 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1619 else if (yys0
->yyresolved
)
1621 yys1
->yyresolved
= yytrue
;
1622 yys1
->yysemantics
.yysval
= yys0
->yysemantics
.yysval
;
1624 else if (yys1
->yyresolved
)
1626 yys0
->yyresolved
= yytrue
;
1627 yys0
->yysemantics
.yysval
= yys1
->yysemantics
.yysval
;
1631 yySemanticOption
** yyz0p
= &yys0
->yysemantics
.yyfirstVal
;
1632 yySemanticOption
* yyz1
= yys1
->yysemantics
.yyfirstVal
;
1635 if (yyz1
== *yyz0p
|| yyz1
== YY_NULLPTR
)
1637 else if (*yyz0p
== YY_NULLPTR
)
1642 else if (*yyz0p
< yyz1
)
1644 yySemanticOption
* yyz
= *yyz0p
;
1646 yyz1
= yyz1
->yynext
;
1647 (*yyz0p
)->yynext
= yyz
;
1649 yyz0p
= &(*yyz0p
)->yynext
;
1651 yys1
->yysemantics
.yyfirstVal
= yys0
->yysemantics
.yyfirstVal
;
1656 /** Y0 and Y1 represent two possible actions to take in a given
1657 * parsing state; return 0 if no combination is possible,
1658 * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
1660 yypreference (yySemanticOption
* y0
, yySemanticOption
* y1
)
1662 yyRuleNum r0
= y0
->yyrule
, r1
= y1
->yyrule
;
1663 int p0
= yydprec
[r0
], p1
= yydprec
[r1
];
1667 if (yymerger
[r0
] == 0 || yymerger
[r0
] != yymerger
[r1
])
1672 if (p0
== 0 || p1
== 0)
1681 static YYRESULTTAG
yyresolveValue (yyGLRState
* yys
,
1682 yyGLRStack
* yystackp
]b4_user_formals
[);
1685 /** Resolve the previous YYN states starting at and including state YYS
1686 * on *YYSTACKP. If result != yyok, some states may have been left
1687 * unresolved possibly with empty semantic option chains. Regardless
1688 * of whether result = yyok, each state has been left with consistent
1689 * data so that yydestroyGLRState can be invoked if necessary. */
1691 yyresolveStates (yyGLRState
* yys
, int yyn
,
1692 yyGLRStack
* yystackp
]b4_user_formals
[)
1696 YY_ASSERT (yys
->yypred
);
1697 YYCHK (yyresolveStates (yys
->yypred
, yyn
-1, yystackp
]b4_user_args
[));
1698 if (! yys
->yyresolved
)
1699 YYCHK (yyresolveValue (yys
, yystackp
]b4_user_args
[));
1704 /** Resolve the states for the RHS of YYOPT on *YYSTACKP, perform its
1705 * user action, and return the semantic value and location in *YYVALP
1706 * and *YYLOCP. Regardless of whether result = yyok, all RHS states
1707 * have been destroyed (assuming the user action destroys all RHS
1708 * semantic values if invoked). */
1710 yyresolveAction (yySemanticOption
* yyopt
, yyGLRStack
* yystackp
,
1711 YYSTYPE
* yyvalp
]b4_locuser_formals
[)
1713 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1714 int yynrhs
= yyrhsLength (yyopt
->yyrule
);
1715 YYRESULTTAG yyflag
=
1716 yyresolveStates (yyopt
->yystate
, yynrhs
, yystackp
]b4_user_args
[);
1720 for (yys
= yyopt
->yystate
; yynrhs
> 0; yys
= yys
->yypred
, yynrhs
-= 1)
1721 yydestroyGLRState ("Cleanup: popping", yys
]b4_user_args
[);
1725 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
= yyopt
->yystate
;]b4_locations_if([[
1727 /* Set default location. */
1728 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
- 1].yystate
.yyloc
= yyopt
->yystate
->yyloc
;]])[
1730 int yychar_current
= yychar
;
1731 YYSTYPE yylval_current
= yylval
;]b4_locations_if([
1732 YYLTYPE yylloc_current
= yylloc
;])[
1733 yychar
= yyopt
->yyrawchar
;
1734 yylval
= yyopt
->yyval
;]b4_locations_if([
1735 yylloc
= yyopt
->yyloc
;])[
1736 yyflag
= yyuserAction (yyopt
->yyrule
, yynrhs
,
1737 yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1738 yystackp
, yyvalp
]b4_locuser_args
[);
1739 yychar
= yychar_current
;
1740 yylval
= yylval_current
;]b4_locations_if([
1741 yylloc
= yylloc_current
;])[
1746 #if ]b4_api_PREFIX[DEBUG
1748 yyreportTree (yySemanticOption
* yyx
, int yyindent
)
1750 int yynrhs
= yyrhsLength (yyx
->yyrule
);
1753 yyGLRState
* yystates
[1 + YYMAXRHS
];
1754 yyGLRState yyleftmost_state
;
1756 for (yyi
= yynrhs
, yys
= yyx
->yystate
; 0 < yyi
; yyi
-= 1, yys
= yys
->yypred
)
1757 yystates
[yyi
] = yys
;
1758 if (yys
== YY_NULLPTR
)
1760 yyleftmost_state
.yyposn
= 0;
1761 yystates
[0] = &yyleftmost_state
;
1766 if (yyx
->yystate
->yyposn
< yys
->yyposn
+ 1)
1767 YY_FPRINTF ((stderr
, "%*s%s -> <Rule %d, empty>\n",
1768 yyindent
, "", yysymbol_name (yylhsNonterm (yyx
->yyrule
)),
1771 YY_FPRINTF ((stderr
, "%*s%s -> <Rule %d, tokens %ld .. %ld>\n",
1772 yyindent
, "", yysymbol_name (yylhsNonterm (yyx
->yyrule
)),
1773 yyx
->yyrule
- 1, YY_CAST (long, yys
->yyposn
+ 1),
1774 YY_CAST (long, yyx
->yystate
->yyposn
)));
1775 for (yyi
= 1; yyi
<= yynrhs
; yyi
+= 1)
1777 if (yystates
[yyi
]->yyresolved
)
1779 if (yystates
[yyi
-1]->yyposn
+1 > yystates
[yyi
]->yyposn
)
1780 YY_FPRINTF ((stderr
, "%*s%s <empty>\n", yyindent
+2, "",
1781 yysymbol_name (yy_accessing_symbol (yystates
[yyi
]->yylrState
))));
1783 YY_FPRINTF ((stderr
, "%*s%s <tokens %ld .. %ld>\n", yyindent
+2, "",
1784 yysymbol_name (yy_accessing_symbol (yystates
[yyi
]->yylrState
)),
1785 YY_CAST (long, yystates
[yyi
-1]->yyposn
+ 1),
1786 YY_CAST (long, yystates
[yyi
]->yyposn
)));
1789 yyreportTree (yystates
[yyi
]->yysemantics
.yyfirstVal
, yyindent
+2);
1795 yyreportAmbiguity (yySemanticOption
* yyx0
,
1796 yySemanticOption
* yyx1
]b4_pure_formals
[)
1801 #if ]b4_api_PREFIX[DEBUG
1802 YY_FPRINTF ((stderr
, "Ambiguity detected.\n"));
1803 YY_FPRINTF ((stderr
, "Option 1,\n"));
1804 yyreportTree (yyx0
, 2);
1805 YY_FPRINTF ((stderr
, "\nOption 2,\n"));
1806 yyreportTree (yyx1
, 2);
1807 YY_FPRINTF ((stderr
, "\n"));
1810 yyerror (]b4_yyerror_args
[YY_("syntax is ambiguous"));
1812 }]b4_locations_if([[
1814 /** Resolve the locations for each of the YYN1 states in *YYSTACKP,
1815 * ending at YYS1. Has no effect on previously resolved states.
1816 * The first semantic option of a state is always chosen. */
1818 yyresolveLocations (yyGLRState
*yys1
, int yyn1
,
1819 yyGLRStack
*yystackp
]b4_user_formals
[)
1823 yyresolveLocations (yys1
->yypred
, yyn1
- 1, yystackp
]b4_user_args
[);
1824 if (!yys1
->yyresolved
)
1826 yyGLRStackItem yyrhsloc
[1 + YYMAXRHS
];
1828 yySemanticOption
*yyoption
= yys1
->yysemantics
.yyfirstVal
;
1829 YY_ASSERT (yyoption
);
1830 yynrhs
= yyrhsLength (yyoption
->yyrule
);
1835 yyresolveLocations (yyoption
->yystate
, yynrhs
,
1836 yystackp
]b4_user_args
[);
1837 for (yys
= yyoption
->yystate
, yyn
= yynrhs
;
1839 yys
= yys
->yypred
, yyn
-= 1)
1840 yyrhsloc
[yyn
].yystate
.yyloc
= yys
->yyloc
;
1844 /* Both yyresolveAction and yyresolveLocations traverse the GSS
1845 in reverse rightmost order. It is only necessary to invoke
1846 yyresolveLocations on a subforest for which yyresolveAction
1847 would have been invoked next had an ambiguity not been
1848 detected. Thus the location of the previous state (but not
1849 necessarily the previous state itself) is guaranteed to be
1850 resolved already. */
1851 yyGLRState
*yyprevious
= yyoption
->yystate
;
1852 yyrhsloc
[0].yystate
.yyloc
= yyprevious
->yyloc
;
1854 YYLLOC_DEFAULT ((yys1
->yyloc
), yyrhsloc
, yynrhs
);
1859 /** Resolve the ambiguity represented in state YYS in *YYSTACKP,
1860 * perform the indicated actions, and set the semantic value of YYS.
1861 * If result != yyok, the chain of semantic options in YYS has been
1862 * cleared instead or it has been left unmodified except that
1863 * redundant options may have been removed. Regardless of whether
1864 * result = yyok, YYS has been left with consistent data so that
1865 * yydestroyGLRState can be invoked if necessary. */
1867 yyresolveValue (yyGLRState
* yys
, yyGLRStack
* yystackp
]b4_user_formals
[)
1869 yySemanticOption
* yyoptionList
= yys
->yysemantics
.yyfirstVal
;
1870 yySemanticOption
* yybest
= yyoptionList
;
1871 yySemanticOption
** yypp
;
1872 yybool yymerge
= yyfalse
;
1874 YYRESULTTAG yyflag
;]b4_locations_if([
1875 YYLTYPE
*yylocp
= &yys
->yyloc
;])[
1877 for (yypp
= &yyoptionList
->yynext
; *yypp
!= YY_NULLPTR
; )
1879 yySemanticOption
* yyp
= *yypp
;
1881 if (yyidenticalOptions (yybest
, yyp
))
1883 yymergeOptionSets (yybest
, yyp
);
1884 *yypp
= yyp
->yynext
;
1888 switch (yypreference (yybest
, yyp
))
1890 case 0:]b4_locations_if([[
1891 yyresolveLocations (yys
, 1, yystackp
]b4_user_args
[);]])[
1892 return yyreportAmbiguity (yybest
, yyp
]b4_pure_args
[);
1904 /* This cannot happen so it is not worth a YY_ASSERT (yyfalse),
1905 but some compilers complain if the default case is
1909 yypp
= &yyp
->yynext
;
1915 yySemanticOption
* yyp
;
1916 int yyprec
= yydprec
[yybest
->yyrule
];
1917 yyflag
= yyresolveAction (yybest
, yystackp
, &yysval
]b4_locuser_args
[);
1919 for (yyp
= yybest
->yynext
; yyp
!= YY_NULLPTR
; yyp
= yyp
->yynext
)
1921 if (yyprec
== yydprec
[yyp
->yyrule
])
1923 YYSTYPE yysval_other
;]b4_locations_if([
1925 yyflag
= yyresolveAction (yyp
, yystackp
, &yysval_other
]b4_locuser_args([&yydummy
])[);
1928 yydestruct ("Cleanup: discarding incompletely merged value for",
1929 yy_accessing_symbol (yys
->yylrState
),
1930 &yysval
]b4_locuser_args
[);
1933 yyuserMerge (yymerger
[yyp
->yyrule
], &yysval
, &yysval_other
);
1938 yyflag
= yyresolveAction (yybest
, yystackp
, &yysval
]b4_locuser_args([yylocp
])[);
1942 yys
->yyresolved
= yytrue
;
1943 yys
->yysemantics
.yysval
= yysval
;
1946 yys
->yysemantics
.yyfirstVal
= YY_NULLPTR
;
1951 yyresolveStack (yyGLRStack
* yystackp
]b4_user_formals
[)
1953 if (yystackp
->yysplitPoint
!= YY_NULLPTR
)
1958 for (yyn
= 0, yys
= yystackp
->yytops
.yystates
[0];
1959 yys
!= yystackp
->yysplitPoint
;
1960 yys
= yys
->yypred
, yyn
+= 1)
1962 YYCHK (yyresolveStates (yystackp
->yytops
.yystates
[0], yyn
, yystackp
1969 yycompressStack (yyGLRStack
* yystackp
)
1971 yyGLRState
* yyp
, *yyq
, *yyr
;
1973 if (yystackp
->yytops
.yysize
!= 1 || yystackp
->yysplitPoint
== YY_NULLPTR
)
1976 for (yyp
= yystackp
->yytops
.yystates
[0], yyq
= yyp
->yypred
, yyr
= YY_NULLPTR
;
1977 yyp
!= yystackp
->yysplitPoint
;
1978 yyr
= yyp
, yyp
= yyq
, yyq
= yyp
->yypred
)
1981 yystackp
->yyspaceLeft
+= yystackp
->yynextFree
- yystackp
->yyitems
;
1982 yystackp
->yynextFree
= YY_REINTERPRET_CAST (yyGLRStackItem
*, yystackp
->yysplitPoint
) + 1;
1983 yystackp
->yyspaceLeft
-= yystackp
->yynextFree
- yystackp
->yyitems
;
1984 yystackp
->yysplitPoint
= YY_NULLPTR
;
1985 yystackp
->yylastDeleted
= YY_NULLPTR
;
1987 while (yyr
!= YY_NULLPTR
)
1989 yystackp
->yynextFree
->yystate
= *yyr
;
1991 yystackp
->yynextFree
->yystate
.yypred
= &yystackp
->yynextFree
[-1].yystate
;
1992 yystackp
->yytops
.yystates
[0] = &yystackp
->yynextFree
->yystate
;
1993 yystackp
->yynextFree
+= 1;
1994 yystackp
->yyspaceLeft
-= 1;
1999 yyprocessOneStack (yyGLRStack
* yystackp
, YYPTRDIFF_T yyk
,
2000 YYPTRDIFF_T yyposn
]b4_pure_formals
[)
2002 while (yystackp
->yytops
.yystates
[yyk
] != YY_NULLPTR
)
2004 yy_state_t yystate
= yystackp
->yytops
.yystates
[yyk
]->yylrState
;
2005 YY_DPRINTF ((stderr
, "Stack %ld Entering state %d\n",
2006 YY_CAST (long, yyk
), yystate
));
2008 YY_ASSERT (yystate
!= YYFINAL
);
2010 if (yyisDefaultedState (yystate
))
2013 yyRuleNum yyrule
= yydefaultAction (yystate
);
2016 YY_DPRINTF ((stderr
, "Stack %ld dies.\n", YY_CAST (long, yyk
)));
2017 yymarkStackDeleted (yystackp
, yyk
);
2020 yyflag
= yyglrReduce (yystackp
, yyk
, yyrule
, yyimmediate
[yyrule
]]b4_user_args
[);
2021 if (yyflag
== yyerr
)
2023 YY_DPRINTF ((stderr
,
2025 "(predicate failure or explicit user error).\n",
2026 YY_CAST (long, yyk
)));
2027 yymarkStackDeleted (yystackp
, yyk
);
2035 yysymbol_kind_t yytoken
= ]b4_yygetToken_call
[;
2036 const short* yyconflicts
;
2037 const int yyaction
= yygetLRActions (yystate
, yytoken
, &yyconflicts
);
2038 yystackp
->yytops
.yylookaheadNeeds
[yyk
] = yytrue
;
2040 for (/* nothing */; *yyconflicts
; yyconflicts
+= 1)
2043 YYPTRDIFF_T yynewStack
= yysplitStack (yystackp
, yyk
);
2044 YY_DPRINTF ((stderr
, "Splitting off stack %ld from %ld.\n",
2045 YY_CAST (long, yynewStack
), YY_CAST (long, yyk
)));
2046 yyflag
= yyglrReduce (yystackp
, yynewStack
,
2048 yyimmediate
[*yyconflicts
]]b4_user_args
[);
2050 YYCHK (yyprocessOneStack (yystackp
, yynewStack
,
2051 yyposn
]b4_pure_args
[));
2052 else if (yyflag
== yyerr
)
2054 YY_DPRINTF ((stderr
, "Stack %ld dies.\n", YY_CAST (long, yynewStack
)));
2055 yymarkStackDeleted (yystackp
, yynewStack
);
2061 if (yyisShiftAction (yyaction
))
2063 else if (yyisErrorAction (yyaction
))
2065 YY_DPRINTF ((stderr
, "Stack %ld dies.\n", YY_CAST (long, yyk
)));
2066 yymarkStackDeleted (yystackp
, yyk
);
2071 YYRESULTTAG yyflag
= yyglrReduce (yystackp
, yyk
, -yyaction
,
2072 yyimmediate
[-yyaction
]]b4_user_args
[);
2073 if (yyflag
== yyerr
)
2075 YY_DPRINTF ((stderr
,
2077 "(predicate failure or explicit user error).\n",
2078 YY_CAST (long, yyk
)));
2079 yymarkStackDeleted (yystackp
, yyk
);
2082 else if (yyflag
!= yyok
)
2090 ]b4_parse_error_case([simple
], [],
2091 [[/* Put in YYARG at most YYARGN of the expected tokens given the
2092 current YYSTACKP, and return the number of tokens stored in YYARG. If
2093 YYARG is null, return the number of expected tokens (guaranteed to
2094 be less than YYNTOKENS). */
2096 yypcontext_expected_tokens (const yyGLRStack
* yystackp
,
2097 yysymbol_kind_t yyarg
[], int yyargn
)
2099 /* Actual size of YYARG. */
2101 int yyn
= yypact
[yystackp
->yytops
.yystates
[0]->yylrState
];
2102 if (!yypact_value_is_default (yyn
))
2104 /* Start YYX at -YYN if negative to avoid negative indexes in
2105 YYCHECK. In other words, skip the first -YYN actions for
2106 this state because they are default actions. */
2107 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
2108 /* Stay within bounds of both yycheck and yytname. */
2109 int yychecklim
= YYLAST
- yyn
+ 1;
2110 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
2112 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
2113 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= ]b4_symbol(1, kind
)[
2114 && !yytable_value_is_error (yytable
[yyx
+ yyn
]))
2118 else if (yycount
== yyargn
)
2121 yyarg
[yycount
++] = YY_CAST (yysymbol_kind_t
, yyx
);
2124 if (yyarg
&& yycount
== 0 && 0 < yyargn
)
2125 yyarg
[0] = ]b4_symbol(-2, kind
)[;
2129 ]b4_parse_error_bmatch(
2131 [[/* User defined function to report a syntax error. */
2132 typedef yyGLRStack yypcontext_t
;
2134 yyreport_syntax_error (const yyGLRStack
* yystackp
]b4_user_formals
[);
2136 /* The kind of the lookahead of this context. */
2137 static yysymbol_kind_t
2138 yypcontext_token (const yyGLRStack
*yystackp
) YY_ATTRIBUTE_UNUSED
;
2140 static yysymbol_kind_t
2141 yypcontext_token (const yyGLRStack
*yystackp
)
2144 yysymbol_kind_t yytoken
= yychar
== ]b4_symbol(-2, id
)[ ? ]b4_symbol(-2, kind
)[ : YYTRANSLATE (yychar
);
2148 ]b4_locations_if([[/* The location of the lookahead of this context. */
2150 yypcontext_location (const yyGLRStack
*yystackp
) YY_ATTRIBUTE_UNUSED
;
2153 yypcontext_location (const yyGLRStack
*yystackp
)
2158 [detailed\
|verbose
],
2160 yy_syntax_error_arguments (const yyGLRStack
* yystackp
,
2161 yysymbol_kind_t yyarg
[], int yyargn
)
2163 yysymbol_kind_t yytoken
= yychar
== ]b4_symbol(-2, id
)[ ? ]b4_symbol(-2, kind
)[ : YYTRANSLATE (yychar
);
2164 /* Actual size of YYARG. */
2166 /* There are many possibilities here to consider:
2167 - If this state is a consistent state with a default action, then
2168 the only way this function was invoked is if the default action
2169 is an error action. In that case, don't check for expected
2170 tokens because there are none.
2171 - The only way there can be no lookahead present (in yychar) is if
2172 this state is a consistent state with a default action. Thus,
2173 detecting the absence of a lookahead is sufficient to determine
2174 that there is no unexpected or expected token to report. In that
2175 case, just report a simple "syntax error".
2176 - Don't assume there isn't a lookahead just because this state is a
2177 consistent state with a default action. There might have been a
2178 previous inconsistent state, consistent state with a non-default
2179 action, or user semantic action that manipulated yychar.]b4_lac_if([[
2180 In the first two cases, it might appear that the current syntax
2181 error should have been detected in the previous state when yy_lac
2182 was invoked. However, at that time, there might have been a
2183 different syntax error that discarded a different initial context
2184 during error recovery, leaving behind the current lookahead.]], [[
2185 - Of course, the expected token list depends on states to have
2186 correct lookahead information, and it depends on the parser not
2187 to perform extra reductions after fetching a lookahead from the
2188 scanner and before detecting a syntax error. Thus, state merging
2189 (from LALR or IELR) and default reductions corrupt the expected
2190 token list. However, the list is correct for canonical LR with
2191 one exception: it will still contain any token that will not be
2192 accepted due to an error action in a later state.]])[
2194 if (yytoken
!= ]b4_symbol(-2, kind
)[)
2198 yyarg
[yycount
] = yytoken
;
2200 yyn
= yypcontext_expected_tokens (yystackp
,
2201 yyarg
? yyarg
+ 1 : yyarg
, yyargn
- 1);
2202 if (yyn
== YYENOMEM
)
2213 yyreportSyntaxError (yyGLRStack
* yystackp
]b4_user_formals
[)
2215 if (yystackp
->yyerrState
!= 0)
2217 ]b4_parse_error_case(
2219 [[ if (yyreport_syntax_error (yystackp
]b4_user_args
[))
2220 yyMemoryExhausted (yystackp
);]],
2222 [[ yyerror (]b4_lyyerror_args
[YY_("syntax error"));]],
2224 yybool yysize_overflow
= yyfalse
;
2225 char* yymsg
= YY_NULLPTR
;
2226 enum { YYARGS_MAX
= 5 };
2227 /* Internationalized format string. */
2228 const char *yyformat
= YY_NULLPTR
;
2229 /* Arguments of yyformat: reported tokens (one for the "unexpected",
2230 one per "expected"). */
2231 yysymbol_kind_t yyarg
[YYARGS_MAX
];
2232 /* Cumulated lengths of YYARG. */
2233 YYPTRDIFF_T yysize
= 0;
2235 /* Actual size of YYARG. */
2237 = yy_syntax_error_arguments (yystackp
, yyarg
, YYARGS_MAX
);
2238 if (yycount
== YYENOMEM
)
2239 yyMemoryExhausted (yystackp
);
2243 #define YYCASE_(N, S) \
2247 default: /* Avoid compiler warnings. */
2248 YYCASE_(0, YY_("syntax error"));
2249 YYCASE_(1, YY_("syntax error, unexpected %s"));
2250 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
2251 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
2252 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
2253 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
2257 /* Compute error message size. Don't count the "%s"s, but reserve
2258 room for the terminator. */
2259 yysize
= yystrlen (yyformat
) - 2 * yycount
+ 1;
2262 for (yyi
= 0; yyi
< yycount
; ++yyi
)
2265 = ]b4_parse_error_case(
2266 [verbose
], [[yytnamerr (YY_NULLPTR
, yytname
[yyarg
[yyi
]])]],
2267 [[yystrlen (yysymbol_name (yyarg
[yyi
]))]]);[
2268 if (YYSIZE_MAXIMUM
- yysize
< yysz
)
2269 yysize_overflow
= yytrue
;
2275 if (!yysize_overflow
)
2276 yymsg
= YY_CAST (char *, YYMALLOC (YY_CAST (YYSIZE_T
, yysize
)));
2282 while ((*yyp
= *yyformat
))
2284 if (*yyp
== '%' && yyformat
[1] == 's' && yyi
< yycount
)
2285 {]b4_parse_error_case([verbose
], [[
2286 yyp
+= yytnamerr (yyp
, yytname
[yyarg
[yyi
++]]);]], [[
2287 yyp
= yystpcpy (yyp
, yysymbol_name (yyarg
[yyi
++]));]])[
2296 yyerror (]b4_lyyerror_args
[yymsg
);
2301 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
2302 yyMemoryExhausted (yystackp
);
2308 /* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP,
2309 yylval, and yylloc are the syntactic category, semantic value, and location
2310 of the lookahead. */
2312 yyrecoverSyntaxError (yyGLRStack
* yystackp
]b4_user_formals
[)
2314 if (yystackp
->yyerrState
== 3)
2315 /* We just shifted the error token and (perhaps) took some
2316 reductions. Skip tokens until we can proceed. */
2319 yysymbol_kind_t yytoken
;
2321 if (yychar
== ]b4_symbol(0, [id
])[)
2322 yyFail (yystackp
][]b4_lpure_args
[, YY_NULLPTR
);
2323 if (yychar
!= ]b4_symbol(-2, id
)[)
2324 {]b4_locations_if([[
2325 /* We throw away the lookahead, but the error range
2326 of the shifted error token must take it into account. */
2327 yyGLRState
*yys
= yystackp
->yytops
.yystates
[0];
2328 yyGLRStackItem yyerror_range
[3];
2329 yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;
2330 yyerror_range
[2].yystate
.yyloc
= yylloc
;
2331 YYLLOC_DEFAULT ((yys
->yyloc
), yyerror_range
, 2);]])[
2332 yytoken
= YYTRANSLATE (yychar
);
2333 yydestruct ("Error: discarding",
2334 yytoken
, &yylval
]b4_locuser_args([&yylloc
])[);
2335 yychar
= ]b4_symbol(-2, id
)[;
2337 yytoken
= ]b4_yygetToken_call
[;
2338 yyj
= yypact
[yystackp
->yytops
.yystates
[0]->yylrState
];
2339 if (yypact_value_is_default (yyj
))
2342 if (yyj
< 0 || YYLAST
< yyj
|| yycheck
[yyj
] != yytoken
)
2344 if (yydefact
[yystackp
->yytops
.yystates
[0]->yylrState
] != 0)
2347 else if (! yytable_value_is_error (yytable
[yyj
]))
2351 /* Reduce to one stack. */
2354 for (yyk
= 0; yyk
< yystackp
->yytops
.yysize
; yyk
+= 1)
2355 if (yystackp
->yytops
.yystates
[yyk
] != YY_NULLPTR
)
2357 if (yyk
>= yystackp
->yytops
.yysize
)
2358 yyFail (yystackp
][]b4_lpure_args
[, YY_NULLPTR
);
2359 for (yyk
+= 1; yyk
< yystackp
->yytops
.yysize
; yyk
+= 1)
2360 yymarkStackDeleted (yystackp
, yyk
);
2361 yyremoveDeletes (yystackp
);
2362 yycompressStack (yystackp
);
2365 /* Pop stack until we find a state that shifts the error token. */
2366 yystackp
->yyerrState
= 3;
2367 while (yystackp
->yytops
.yystates
[0] != YY_NULLPTR
)
2369 yyGLRState
*yys
= yystackp
->yytops
.yystates
[0];
2370 int yyj
= yypact
[yys
->yylrState
];
2371 if (! yypact_value_is_default (yyj
))
2373 yyj
+= ]b4_symbol(1, kind
)[;
2374 if (0 <= yyj
&& yyj
<= YYLAST
&& yycheck
[yyj
] == ]b4_symbol(1, kind
)[
2375 && yyisShiftAction (yytable
[yyj
]))
2377 /* Shift the error token. */
2378 int yyaction
= yytable
[yyj
];]b4_locations_if([[
2379 /* First adjust its location.*/
2381 yystackp
->yyerror_range
[2].yystate
.yyloc
= yylloc
;
2382 YYLLOC_DEFAULT (yyerrloc
, (yystackp
->yyerror_range
), 2);]])[
2383 YY_SYMBOL_PRINT ("Shifting", yy_accessing_symbol (yyaction
),
2384 &yylval
, &yyerrloc
);
2385 yyglrShift (yystackp
, 0, yyaction
,
2386 yys
->yyposn
, &yylval
]b4_locations_if([, &yyerrloc
])[);
2387 yys
= yystackp
->yytops
.yystates
[0];
2390 }]b4_locations_if([[
2391 yystackp
->yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]])[
2392 if (yys
->yypred
!= YY_NULLPTR
)
2393 yydestroyGLRState ("Error: popping", yys
]b4_user_args
[);
2394 yystackp
->yytops
.yystates
[0] = yys
->yypred
;
2395 yystackp
->yynextFree
-= 1;
2396 yystackp
->yyspaceLeft
+= 1;
2398 if (yystackp
->yytops
.yystates
[0] == YY_NULLPTR
)
2399 yyFail (yystackp
][]b4_lpure_args
[, YY_NULLPTR
);
2402 #define YYCHK1(YYE) \
2412 goto yyuser_error; \
2423 ]b4_glr_cc_if([yy_parse_impl
], [yyparse
])[ (]m4_ifset([b4_parse_param
], [b4_formals(b4_parse_param
)], [void])[)
2427 yyGLRStack
* const yystackp
= &yystack
;
2430 YY_DPRINTF ((stderr
, "Starting parse\n"));
2432 yychar
= ]b4_symbol(-2, id
)[;
2433 yylval
= yyval_default
;]b4_locations_if([
2434 yylloc
= yyloc_default
;])[
2435 ]m4_ifdef([b4_initial_action
], [
2436 b4_dollar_pushdef([yylval
], [], [], [yylloc
])dnl
2437 b4_user_initial_action
2438 b4_dollar_popdef
])[]dnl
2440 if (! yyinitGLRStack (yystackp
, YYINITDEPTH
))
2441 goto yyexhaustedlab
;
2442 switch (YYSETJMP (yystack
.yyexception_buffer
))
2445 case 1: goto yyabortlab
;
2446 case 2: goto yyexhaustedlab
;
2447 default: goto yybuglab
;
2449 yyglrShift (&yystack
, 0, 0, 0, &yylval
]b4_locations_if([, &yylloc
])[);
2454 /* For efficiency, we have two loops, the first of which is
2455 specialized to deterministic operation (single stack, no
2456 potential ambiguity). */
2457 /* Standard mode. */
2460 yy_state_t yystate
= yystack
.yytops
.yystates
[0]->yylrState
;
2461 YY_DPRINTF ((stderr
, "Entering state %d\n", yystate
));
2462 if (yystate
== YYFINAL
)
2464 if (yyisDefaultedState (yystate
))
2466 yyRuleNum yyrule
= yydefaultAction (yystate
);
2468 {]b4_locations_if([[
2469 yystack
.yyerror_range
[1].yystate
.yyloc
= yylloc
;]])[
2470 yyreportSyntaxError (&yystack
]b4_user_args
[);
2473 YYCHK1 (yyglrReduce (&yystack
, 0, yyrule
, yytrue
]b4_user_args
[));
2477 yysymbol_kind_t yytoken
= ]b4_yygetToken_call
;[
2478 const short* yyconflicts
;
2479 int yyaction
= yygetLRActions (yystate
, yytoken
, &yyconflicts
);
2481 /* Enter nondeterministic mode. */
2483 if (yyisShiftAction (yyaction
))
2485 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
2486 yychar
= ]b4_symbol(-2, id
)[;
2488 yyglrShift (&yystack
, 0, yyaction
, yyposn
, &yylval
]b4_locations_if([, &yylloc
])[);
2489 if (0 < yystack
.yyerrState
)
2490 yystack
.yyerrState
-= 1;
2492 else if (yyisErrorAction (yyaction
))
2493 {]b4_locations_if([[
2494 yystack
.yyerror_range
[1].yystate
.yyloc
= yylloc
;]])[
2495 /* Issue an error message unless the scanner already
2497 if (yychar
!= ]b4_symbol(1, id
)[)
2498 yyreportSyntaxError (&yystack
]b4_user_args
[);
2502 YYCHK1 (yyglrReduce (&yystack
, 0, -yyaction
, yytrue
]b4_user_args
[));
2506 /* Nondeterministic mode. */
2509 yysymbol_kind_t yytoken_to_shift
;
2512 for (yys
= 0; yys
< yystack
.yytops
.yysize
; yys
+= 1)
2513 yystackp
->yytops
.yylookaheadNeeds
[yys
] = yychar
!= ]b4_symbol(-2, id
)[;
2515 /* yyprocessOneStack returns one of three things:
2517 - An error flag. If the caller is yyprocessOneStack, it
2518 immediately returns as well. When the caller is finally
2519 yyparse, it jumps to an error label via YYCHK1.
2521 - yyok, but yyprocessOneStack has invoked yymarkStackDeleted
2522 (&yystack, yys), which sets the top state of yys to NULL. Thus,
2523 yyparse's following invocation of yyremoveDeletes will remove
2526 - yyok, when ready to shift a token.
2528 Except in the first case, yyparse will invoke yyremoveDeletes and
2529 then shift the next token onto all remaining stacks. This
2530 synchronization of the shift (that is, after all preceding
2531 reductions on all stacks) helps prevent double destructor calls
2532 on yylval in the event of memory exhaustion. */
2534 for (yys
= 0; yys
< yystack
.yytops
.yysize
; yys
+= 1)
2535 YYCHK1 (yyprocessOneStack (&yystack
, yys
, yyposn
]b4_lpure_args
[));
2536 yyremoveDeletes (&yystack
);
2537 if (yystack
.yytops
.yysize
== 0)
2539 yyundeleteLastStack (&yystack
);
2540 if (yystack
.yytops
.yysize
== 0)
2541 yyFail (&yystack
][]b4_lpure_args
[, YY_("syntax error"));
2542 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2543 YY_DPRINTF ((stderr
, "Returning to deterministic operation.\n"));]b4_locations_if([[
2544 yystack
.yyerror_range
[1].yystate
.yyloc
= yylloc
;]])[
2545 yyreportSyntaxError (&yystack
]b4_user_args
[);
2549 /* If any yyglrShift call fails, it will fail after shifting. Thus,
2550 a copy of yylval will already be on stack 0 in the event of a
2551 failure in the following loop. Thus, yychar is set to ]b4_symbol(-2, id)[
2552 before the loop to make sure the user destructor for yylval isn't
2554 yytoken_to_shift
= YYTRANSLATE (yychar
);
2555 yychar
= ]b4_symbol(-2, id
)[;
2557 for (yys
= 0; yys
< yystack
.yytops
.yysize
; yys
+= 1)
2559 yy_state_t yystate
= yystack
.yytops
.yystates
[yys
]->yylrState
;
2560 const short* yyconflicts
;
2561 int yyaction
= yygetLRActions (yystate
, yytoken_to_shift
,
2563 /* Note that yyconflicts were handled by yyprocessOneStack. */
2564 YY_DPRINTF ((stderr
, "On stack %ld, ", YY_CAST (long, yys
)));
2565 YY_SYMBOL_PRINT ("shifting", yytoken_to_shift
, &yylval
, &yylloc
);
2566 yyglrShift (&yystack
, yys
, yyaction
, yyposn
,
2567 &yylval
]b4_locations_if([, &yylloc
])[);
2568 YY_DPRINTF ((stderr
, "Stack %ld now in state #%d\n",
2569 YY_CAST (long, yys
),
2570 yystack
.yytops
.yystates
[yys
]->yylrState
));
2573 if (yystack
.yytops
.yysize
== 1)
2575 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2576 YY_DPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2577 yycompressStack (&yystack
);
2583 yyrecoverSyntaxError (&yystack
]b4_user_args
[);
2584 yyposn
= yystack
.yytops
.yystates
[0]->yyposn
;
2592 YY_ASSERT (yyfalse
);
2600 yyerror (]b4_lyyerror_args
[YY_("memory exhausted"));
2605 if (yychar
!= ]b4_symbol(-2, id
)[)
2606 yydestruct ("Cleanup: discarding lookahead",
2607 YYTRANSLATE (yychar
), &yylval
]b4_locuser_args([&yylloc
])[);
2609 /* If the stack is well-formed, pop the stack until it is empty,
2610 destroying its entries as we go. But free the stack regardless
2611 of whether it is well-formed. */
2612 if (yystack
.yyitems
)
2614 yyGLRState
** yystates
= yystack
.yytops
.yystates
;
2617 YYPTRDIFF_T yysize
= yystack
.yytops
.yysize
;
2619 for (yyk
= 0; yyk
< yysize
; yyk
+= 1)
2622 while (yystates
[yyk
])
2624 yyGLRState
*yys
= yystates
[yyk
];]b4_locations_if([[
2625 yystack
.yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]])[
2626 if (yys
->yypred
!= YY_NULLPTR
)
2627 yydestroyGLRState ("Cleanup: popping", yys
]b4_user_args
[);
2628 yystates
[yyk
] = yys
->yypred
;
2629 yystack
.yynextFree
-= 1;
2630 yystack
.yyspaceLeft
+= 1;
2635 yyfreeGLRStack (&yystack
);
2641 /* DEBUGGING ONLY */
2642 #if ]b4_api_PREFIX[DEBUG
2644 yy_yypstack (yyGLRState
* yys
)
2648 yy_yypstack (yys
->yypred
);
2649 YY_FPRINTF ((stderr
, " -> "));
2651 YY_FPRINTF ((stderr
, "%d@@%ld", yys
->yylrState
, YY_CAST (long, yys
->yyposn
)));
2655 yypstates (yyGLRState
* yyst
)
2657 if (yyst
== YY_NULLPTR
)
2658 YY_FPRINTF ((stderr
, "<null>"));
2661 YY_FPRINTF ((stderr
, "\n"));
2665 yypstack (yyGLRStack
* yystackp
, YYPTRDIFF_T yyk
)
2667 yypstates (yystackp
->yytops
.yystates
[yyk
]);
2671 yypdumpstack (yyGLRStack
* yystackp
)
2673 #define YYINDEX(YYX) \
2676 ? YY_REINTERPRET_CAST (yyGLRStackItem*, (YYX)) - yystackp->yyitems \
2679 yyGLRStackItem
* yyp
;
2680 for (yyp
= yystackp
->yyitems
; yyp
< yystackp
->yynextFree
; yyp
+= 1)
2682 YY_FPRINTF ((stderr
, "%3ld. ",
2683 YY_CAST (long, yyp
- yystackp
->yyitems
)));
2684 if (*YY_REINTERPRET_CAST (yybool
*, yyp
))
2686 YY_ASSERT (yyp
->yystate
.yyisState
);
2687 YY_ASSERT (yyp
->yyoption
.yyisState
);
2688 YY_FPRINTF ((stderr
, "Res: %d, LR State: %d, posn: %ld, pred: %ld",
2689 yyp
->yystate
.yyresolved
, yyp
->yystate
.yylrState
,
2690 YY_CAST (long, yyp
->yystate
.yyposn
),
2691 YYINDEX (yyp
->yystate
.yypred
)));
2692 if (! yyp
->yystate
.yyresolved
)
2693 YY_FPRINTF ((stderr
, ", firstVal: %ld",
2694 YYINDEX (yyp
->yystate
.yysemantics
.yyfirstVal
)));
2698 YY_ASSERT (!yyp
->yystate
.yyisState
);
2699 YY_ASSERT (!yyp
->yyoption
.yyisState
);
2700 YY_FPRINTF ((stderr
, "Option. rule: %d, state: %ld, next: %ld",
2701 yyp
->yyoption
.yyrule
- 1,
2702 YYINDEX (yyp
->yyoption
.yystate
),
2703 YYINDEX (yyp
->yyoption
.yynext
)));
2705 YY_FPRINTF ((stderr
, "\n"));
2708 YY_FPRINTF ((stderr
, "Tops:"));
2711 for (yyi
= 0; yyi
< yystackp
->yytops
.yysize
; yyi
+= 1)
2712 YY_FPRINTF ((stderr
, "%ld: %ld; ", YY_CAST (long, yyi
),
2713 YYINDEX (yystackp
->yytops
.yystates
[yyi
])));
2714 YY_FPRINTF ((stderr
, "\n"));
2722 #undef yynerrs]b4_locations_if([
2725 m4_if(b4_prefix
, [yy
], [],
2726 [[/* Substitute the variable and function names. */
2727 #define yyparse ]b4_prefix[parse
2728 #define yylex ]b4_prefix[lex
2729 #define yyerror ]b4_prefix[error
2730 #define yylval ]b4_prefix[lval
2731 #define yychar ]b4_prefix[char
2732 #define yydebug ]b4_prefix[debug
2733 #define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
2734 #define yylloc ]b4_prefix[lloc]])])[
2736 ]b4_glr_cc_if([b4_glr_cc_pre_epilogue
2737 b4_glr_cc_cleanup
])[
2738 ]b4_percent_code_get([[epilogue
]])[]dnl