Home | History | Annotate | Download | only in data
      1                                                                     -*- C -*-
      2 
      3 # GLR skeleton for Bison
      4 
      5 # Copyright (C) 2002-2012 Free Software Foundation, Inc.
      6 
      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.
     11 #
     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.
     16 #
     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/>.
     19 
     20 
     21 # If we are loaded by glr.cc, do not override c++.m4 definitions by
     22 # those of c.m4.
     23 m4_if(b4_skeleton, ["glr.c"],
     24       [m4_include(b4_pkgdatadir/[c.m4])])
     25 
     26 ## ---------------- ##
     27 ## Default values.  ##
     28 ## ---------------- ##
     29 
     30 # Stack parameters.
     31 m4_define_default([b4_stack_depth_max], [10000])
     32 m4_define_default([b4_stack_depth_init],  [200])
     33 
     34 
     35 
     36 ## ------------------------ ##
     37 ## Pure/impure interfaces.  ##
     38 ## ------------------------ ##
     39 
     40 b4_define_flag_if([pure])
     41 # If glr.cc is including this file and thus has already set b4_pure_flag,
     42 # do not change the value of b4_pure_flag, and do not record a use of api.pure.
     43 m4_ifndef([b4_pure_flag],
     44 [b4_percent_define_default([[api.pure]], [[false]])
     45  m4_define([b4_pure_flag],
     46            [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])])
     47 
     48 # b4_user_formals
     49 # ---------------
     50 # The possible parse-params formal arguments preceded by a comma.
     51 #
     52 # This is not shared with yacc.c in c.m4 because  GLR relies on ISO C
     53 # formal argument declarations.
     54 m4_define([b4_user_formals],
     55 [m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])])
     56 
     57 
     58 # b4_lex_param
     59 # ------------
     60 # Accumule in b4_lex_param all the yylex arguments.
     61 # Yes, this is quite ugly...
     62 m4_define([b4_lex_param],
     63 m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl
     64 b4_locations_if([, [[YYLTYPE *], [&yylloc]]])])dnl
     65 m4_ifdef([b4_lex_param], [, ]b4_lex_param)))
     66 
     67 
     68 # b4_yyerror_args
     69 # ---------------
     70 # Optional effective arguments passed to yyerror: user args plus yylloc, and
     71 # a trailing comma.
     72 m4_define([b4_yyerror_args],
     73 [b4_pure_if([b4_locations_if([yylocp, ])])dnl
     74 m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
     75 
     76 
     77 # b4_lyyerror_args
     78 # ----------------
     79 # Same as above, but on the lookahead, hence &yylloc instead of yylocp.
     80 m4_define([b4_lyyerror_args],
     81 [b4_pure_if([b4_locations_if([&yylloc, ])])dnl
     82 m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
     83 
     84 
     85 # b4_pure_args
     86 # ------------
     87 # Same as b4_yyerror_args, but with a leading comma.
     88 m4_define([b4_pure_args],
     89 [b4_pure_if([b4_locations_if([, yylocp])])[]b4_user_args])
     90 
     91 
     92 # b4_lpure_args
     93 # -------------
     94 # Same as above, but on the lookahead, hence &yylloc instead of yylocp.
     95 m4_define([b4_lpure_args],
     96 [b4_pure_if([b4_locations_if([, &yylloc])])[]b4_user_args])
     97 
     98 
     99 
    100 # b4_pure_formals
    101 # ---------------
    102 # Arguments passed to yyerror: user formals plus yylocp with leading comma.
    103 m4_define([b4_pure_formals],
    104 [b4_pure_if([b4_locations_if([, YYLTYPE *yylocp])])[]b4_user_formals])
    105 
    106 
    107 # b4_locuser_formals(LOC = yylocp)
    108 # --------------------------------
    109 m4_define([b4_locuser_formals],
    110 [b4_locations_if([, YYLTYPE *m4_default([$1], [yylocp])])[]b4_user_formals])
    111 
    112 
    113 # b4_locuser_args(LOC = yylocp)
    114 # -----------------------------
    115 m4_define([b4_locuser_args],
    116 [b4_locations_if([, m4_default([$1], [yylocp])])[]b4_user_args])
    117 
    118 
    119 
    120 ## ----------------- ##
    121 ## Semantic Values.  ##
    122 ## ----------------- ##
    123 
    124 
    125 # b4_lhs_value([TYPE])
    126 # --------------------
    127 # Expansion of $<TYPE>$.
    128 m4_define([b4_lhs_value],
    129 [((*yyvalp)[]m4_ifval([$1], [.$1]))])
    130 
    131 
    132 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
    133 # --------------------------------------
    134 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
    135 # symbols on RHS.
    136 m4_define([b4_rhs_value],
    137 [(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))])
    138 
    139 
    140 
    141 ## ----------- ##
    142 ## Locations.  ##
    143 ## ----------- ##
    144 
    145 # b4_lhs_location()
    146 # -----------------
    147 # Expansion of @$.
    148 m4_define([b4_lhs_location],
    149 [(*yylocp)])
    150 
    151 
    152 # b4_rhs_location(RULE-LENGTH, NUM)
    153 # ---------------------------------
    154 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
    155 # on RHS.
    156 m4_define([b4_rhs_location],
    157 [(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)])
    158 
    159 
    160 ## -------------- ##
    161 ## Declarations.  ##
    162 ## -------------- ##
    163 
    164 # b4_shared_declarations
    165 # ----------------------
    166 # Declaration that might either go into the header (if --defines)
    167 # or open coded in the parser body.
    168 m4_define([b4_shared_declarations],
    169 [b4_declare_yydebug[
    170 ]b4_percent_code_get([[requires]])[
    171 ]b4_token_enums(b4_tokens)[
    172 ]b4_declare_yylstype[
    173 ]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
    174 ]b4_percent_code_get([[provides]])[]dnl
    175 ])
    176 
    177 
    178 ## -------------- ##
    179 ## Output files.  ##
    180 ## -------------- ##
    181 
    182 b4_output_begin([b4_parser_file_name])
    183 b4_copyright([Skeleton implementation for Bison GLR parsers in C],
    184              [2002-2012])[
    185 
    186 /* C GLR parser skeleton written by Paul Hilfinger.  */
    187 
    188 ]b4_identification
    189 
    190 b4_percent_code_get([[top]])[
    191 ]m4_if(b4_api_prefix, [yy], [],
    192 [[/* Substitute the type names.  */
    193 #define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
    194 #define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
    195 ]m4_if(b4_prefix, [yy], [],
    196 [[/* Substitute the variable and function names.  */
    197 #define yyparse ]b4_prefix[parse
    198 #define yylex   ]b4_prefix[lex
    199 #define yyerror ]b4_prefix[error
    200 #define yylval  ]b4_prefix[lval
    201 #define yychar  ]b4_prefix[char
    202 #define yydebug ]b4_prefix[debug
    203 #define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
    204 #define yylloc  ]b4_prefix[lloc]])])[
    205 
    206 /* Copy the first part of user declarations.  */
    207 ]b4_user_pre_prologue[
    208 
    209 ]b4_null_define[
    210 
    211 ]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
    212                [b4_shared_declarations])[
    213 
    214 /* Enabling verbose error messages.  */
    215 #ifdef YYERROR_VERBOSE
    216 # undef YYERROR_VERBOSE
    217 # define YYERROR_VERBOSE 1
    218 #else
    219 # define YYERROR_VERBOSE ]b4_error_verbose_flag[
    220 #endif
    221 
    222 /* Default (constant) value used for initialization for null
    223    right-hand sides.  Unlike the standard yacc.c template, here we set
    224    the default value of $$ to a zeroed-out value.  Since the default
    225    value is undefined, this behavior is technically correct.  */
    226 static YYSTYPE yyval_default;]b4_locations_if([[
    227 static YYLTYPE yyloc_default][]b4_yyloc_default;])[
    228 
    229 /* Copy the second part of user declarations.  */
    230 ]b4_user_post_prologue
    231 b4_percent_code_get[]dnl
    232 
    233 [#include <stdio.h>
    234 #include <stdlib.h>
    235 #include <string.h>
    236 
    237 #ifndef YY_
    238 # if defined YYENABLE_NLS && YYENABLE_NLS
    239 #  if ENABLE_NLS
    240 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
    241 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
    242 #  endif
    243 # endif
    244 # ifndef YY_
    245 #  define YY_(Msgid) Msgid
    246 # endif
    247 #endif
    248 
    249 /* Suppress unused-variable warnings by "using" E.  */
    250 #if ! defined lint || defined __GNUC__
    251 # define YYUSE(E) ((void) (E))
    252 #else
    253 # define YYUSE(E) /* empty */
    254 #endif
    255 
    256 /* Identity function, used to suppress warnings about constant conditions.  */
    257 #ifndef lint
    258 # define YYID(N) (N)
    259 #else
    260 ]b4_c_function_def([YYID], [static int], [[int i], [i]])[
    261 {
    262   return i;
    263 }
    264 #endif
    265 
    266 #ifndef YYFREE
    267 # define YYFREE free
    268 #endif
    269 #ifndef YYMALLOC
    270 # define YYMALLOC malloc
    271 #endif
    272 #ifndef YYREALLOC
    273 # define YYREALLOC realloc
    274 #endif
    275 
    276 #define YYSIZEMAX ((size_t) -1)
    277 
    278 #ifdef __cplusplus
    279    typedef bool yybool;
    280 #else
    281    typedef unsigned char yybool;
    282 #endif
    283 #define yytrue 1
    284 #define yyfalse 0
    285 
    286 #ifndef YYSETJMP
    287 # include <setjmp.h>
    288 # define YYJMP_BUF jmp_buf
    289 # define YYSETJMP(Env) setjmp (Env)
    290 /* Pacify clang.  */
    291 # define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
    292 #endif
    293 
    294 /*-----------------.
    295 | GCC extensions.  |
    296 `-----------------*/
    297 
    298 #ifndef __attribute__
    299 /* This feature is available in gcc versions 2.5 and later.  */
    300 # if (! defined __GNUC__ || __GNUC__ < 2 \
    301       || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
    302 #  define __attribute__(Spec) /* empty */
    303 # endif
    304 #endif
    305 
    306 #ifndef YYASSERT
    307 # define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
    308 #endif
    309 
    310 /* YYFINAL -- State number of the termination state.  */
    311 #define YYFINAL  ]b4_final_state_number[
    312 /* YYLAST -- Last index in YYTABLE.  */
    313 #define YYLAST   ]b4_last[
    314 
    315 /* YYNTOKENS -- Number of terminals.  */
    316 #define YYNTOKENS  ]b4_tokens_number[
    317 /* YYNNTS -- Number of nonterminals.  */
    318 #define YYNNTS  ]b4_nterms_number[
    319 /* YYNRULES -- Number of rules.  */
    320 #define YYNRULES  ]b4_rules_number[
    321 /* YYNRULES -- Number of states.  */
    322 #define YYNSTATES  ]b4_states_number[
    323 /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule.  */
    324 #define YYMAXRHS ]b4_r2_max[
    325 /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
    326    accessed by $0, $-1, etc., in any rule.  */
    327 #define YYMAXLEFT ]b4_max_left_semantic_context[
    328 
    329 /* YYTRANSLATE(X) -- Bison symbol number corresponding to X.  */
    330 #define YYUNDEFTOK  ]b4_undef_token_number[
    331 #define YYMAXUTOK   ]b4_user_token_number_max[
    332 
    333 #define YYTRANSLATE(YYX)                                                \
    334   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
    335 
    336 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
    337 static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
    338 {
    339   ]b4_translate[
    340 };
    341 
    342 #if ]b4_api_PREFIX[DEBUG
    343 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
    344    YYRHS.  */
    345 static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
    346 {
    347   ]b4_prhs[
    348 };
    349 
    350 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
    351 static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
    352 {
    353   ]b4_rhs[
    354 };
    355 
    356 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
    357 static const ]b4_int_type_for([b4_rline])[ yyrline[] =
    358 {
    359   ]b4_rline[
    360 };
    361 #endif
    362 
    363 #if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
    364 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
    365    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
    366 static const char *const yytname[] =
    367 {
    368   ]b4_tname[
    369 };
    370 #endif
    371 
    372 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
    373 static const ]b4_int_type_for([b4_r1])[ yyr1[] =
    374 {
    375   ]b4_r1[
    376 };
    377 
    378 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
    379 static const ]b4_int_type_for([b4_r2])[ yyr2[] =
    380 {
    381   ]b4_r2[
    382 };
    383 
    384 /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none).  */
    385 static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
    386 {
    387   ]b4_dprec[
    388 };
    389 
    390 /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM.  */
    391 static const ]b4_int_type_for([b4_merger])[ yymerger[] =
    392 {
    393   ]b4_merger[
    394 };
    395 
    396 /* YYDEFACT[S] -- default reduction number in state S.  Performed when
    397    YYTABLE doesn't specify something else to do.  Zero means the default
    398    is an error.  */
    399 static const ]b4_int_type_for([b4_defact])[ yydefact[] =
    400 {
    401   ]b4_defact[
    402 };
    403 
    404 /* YYPDEFGOTO[NTERM-NUM].  */
    405 static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
    406 {
    407   ]b4_defgoto[
    408 };
    409 
    410 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    411    STATE-NUM.  */
    412 #define YYPACT_NINF ]b4_pact_ninf[
    413 static const ]b4_int_type_for([b4_pact])[ yypact[] =
    414 {
    415   ]b4_pact[
    416 };
    417 
    418 /* YYPGOTO[NTERM-NUM].  */
    419 static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
    420 {
    421   ]b4_pgoto[
    422 };
    423 
    424 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    425    positive, shift that token.  If negative, reduce the rule which
    426    number is the opposite.  If YYTABLE_NINF, syntax error.  */
    427 #define YYTABLE_NINF ]b4_table_ninf[
    428 static const ]b4_int_type_for([b4_table])[ yytable[] =
    429 {
    430   ]b4_table[
    431 };
    432 
    433 /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
    434    list of conflicting reductions corresponding to action entry for
    435    state STATE-NUM in yytable.  0 means no conflicts.  The list in
    436    yyconfl is terminated by a rule number of 0.  */
    437 static const ]b4_int_type_for([b4_conflict_list_heads])[ yyconflp[] =
    438 {
    439   ]b4_conflict_list_heads[
    440 };
    441 
    442 /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
    443    0, pointed into by YYCONFLP.  */
    444 ]dnl Do not use b4_int_type_for here, since there are places where
    445 dnl pointers onto yyconfl are taken, which type is "short int *".
    446 dnl We probably ought to introduce a type for confl.
    447 [static const short int yyconfl[] =
    448 {
    449   ]b4_conflicting_rules[
    450 };
    451 
    452 static const ]b4_int_type_for([b4_check])[ yycheck[] =
    453 {
    454   ]b4_check[
    455 };
    456 
    457 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
    458    symbol of state STATE-NUM.  */
    459 static const ]b4_int_type_for([b4_stos])[ yystos[] =
    460 {
    461   ]b4_stos[
    462 };
    463 
    464 /* Error token number */
    465 #define YYTERROR 1
    466 
    467 ]b4_locations_if([[
    468 ]b4_yylloc_default_define[
    469 # define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
    470 ]])[
    471 ]b4_yy_location_print_define[
    472 
    473 /* YYLEX -- calling `yylex' with the right arguments.  */
    474 #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
    475 
    476 ]b4_pure_if(
    477 [
    478 #undef yynerrs
    479 #define yynerrs (yystackp->yyerrcnt)
    480 #undef yychar
    481 #define yychar (yystackp->yyrawchar)
    482 #undef yylval
    483 #define yylval (yystackp->yyval)
    484 #undef yylloc
    485 #define yylloc (yystackp->yyloc)
    486 m4_if(b4_prefix[], [yy], [],
    487 [#define b4_prefix[]nerrs yynerrs
    488 #define b4_prefix[]char yychar
    489 #define b4_prefix[]lval yylval
    490 #define b4_prefix[]lloc yylloc])],
    491 [YYSTYPE yylval;]b4_locations_if([[
    492 YYLTYPE yylloc;]])[
    493 
    494 int yynerrs;
    495 int yychar;])[
    496 
    497 static const int YYEOF = 0;
    498 static const int YYEMPTY = -2;
    499 
    500 typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
    501 
    502 #define YYCHK(YYE)                                                           \
    503    do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; }       \
    504    while (YYID (0))
    505 
    506 #if ]b4_api_PREFIX[DEBUG
    507 
    508 # ifndef YYFPRINTF
    509 #  define YYFPRINTF fprintf
    510 # endif
    511 
    512 # define YYDPRINTF(Args)                        \
    513 do {                                            \
    514   if (yydebug)                                  \
    515     YYFPRINTF Args;                             \
    516 } while (YYID (0))
    517 
    518 ]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[
    519 
    520 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)          \
    521 do {                                                            \
    522   if (yydebug)                                                  \
    523     {                                                           \
    524       YYFPRINTF (stderr, "%s ", Title);                         \
    525       yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[);        \
    526       YYFPRINTF (stderr, "\n");                                 \
    527     }                                                           \
    528 } while (YYID (0))
    529 
    530 /* Nonzero means print parse trace.  It is left uninitialized so that
    531    multiple parsers can coexist.  */
    532 int yydebug;
    533 
    534 #else /* !]b4_api_PREFIX[DEBUG */
    535 
    536 # define YYDPRINTF(Args)
    537 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
    538 
    539 #endif /* !]b4_api_PREFIX[DEBUG */
    540 
    541 /* YYINITDEPTH -- initial size of the parser's stacks.  */
    542 #ifndef YYINITDEPTH
    543 # define YYINITDEPTH ]b4_stack_depth_init[
    544 #endif
    545 
    546 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
    547    if the built-in stack extension method is used).
    548 
    549    Do not make this value too large; the results are undefined if
    550    SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
    551    evaluated with infinite-precision integer arithmetic.  */
    552 
    553 #ifndef YYMAXDEPTH
    554 # define YYMAXDEPTH ]b4_stack_depth_max[
    555 #endif
    556 
    557 /* Minimum number of free items on the stack allowed after an
    558    allocation.  This is to allow allocation and initialization
    559    to be completed by functions that call yyexpandGLRStack before the
    560    stack is expanded, thus insuring that all necessary pointers get
    561    properly redirected to new data.  */
    562 #define YYHEADROOM 2
    563 
    564 #ifndef YYSTACKEXPANDABLE
    565 # if (! defined __cplusplus \
    566       || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
    567           && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL))
    568 #  define YYSTACKEXPANDABLE 1
    569 # else
    570 #  define YYSTACKEXPANDABLE 0
    571 # endif
    572 #endif
    573 
    574 #if YYSTACKEXPANDABLE
    575 # define YY_RESERVE_GLRSTACK(Yystack)                   \
    576   do {                                                  \
    577     if (Yystack->yyspaceLeft < YYHEADROOM)              \
    578       yyexpandGLRStack (Yystack);                       \
    579   } while (YYID (0))
    580 #else
    581 # define YY_RESERVE_GLRSTACK(Yystack)                   \
    582   do {                                                  \
    583     if (Yystack->yyspaceLeft < YYHEADROOM)              \
    584       yyMemoryExhausted (Yystack);                      \
    585   } while (YYID (0))
    586 #endif
    587 
    588 
    589 #if YYERROR_VERBOSE
    590 
    591 # ifndef yystpcpy
    592 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
    593 #   define yystpcpy stpcpy
    594 #  else
    595 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
    596    YYDEST.  */
    597 static char *
    598 yystpcpy (char *yydest, const char *yysrc)
    599 {
    600   char *yyd = yydest;
    601   const char *yys = yysrc;
    602 
    603   while ((*yyd++ = *yys++) != '\0')
    604     continue;
    605 
    606   return yyd - 1;
    607 }
    608 #  endif
    609 # endif
    610 
    611 # ifndef yytnamerr
    612 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
    613    quotes and backslashes, so that it's suitable for yyerror.  The
    614    heuristic is that double-quoting is unnecessary unless the string
    615    contains an apostrophe, a comma, or backslash (other than
    616    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
    617    null, do not copy; instead, return the length of what the result
    618    would have been.  */
    619 static size_t
    620 yytnamerr (char *yyres, const char *yystr)
    621 {
    622   if (*yystr == '"')
    623     {
    624       size_t yyn = 0;
    625       char const *yyp = yystr;
    626 
    627       for (;;)
    628         switch (*++yyp)
    629           {
    630           case '\'':
    631           case ',':
    632             goto do_not_strip_quotes;
    633 
    634           case '\\':
    635             if (*++yyp != '\\')
    636               goto do_not_strip_quotes;
    637             /* Fall through.  */
    638           default:
    639             if (yyres)
    640               yyres[yyn] = *yyp;
    641             yyn++;
    642             break;
    643 
    644           case '"':
    645             if (yyres)
    646               yyres[yyn] = '\0';
    647             return yyn;
    648           }
    649     do_not_strip_quotes: ;
    650     }
    651 
    652   if (! yyres)
    653     return strlen (yystr);
    654 
    655   return yystpcpy (yyres, yystr) - yyres;
    656 }
    657 # endif
    658 
    659 #endif /* !YYERROR_VERBOSE */
    660 
    661 /** State numbers, as in LALR(1) machine */
    662 typedef int yyStateNum;
    663 
    664 /** Rule numbers, as in LALR(1) machine */
    665 typedef int yyRuleNum;
    666 
    667 /** Grammar symbol */
    668 typedef short int yySymbol;
    669 
    670 /** Item references, as in LALR(1) machine */
    671 typedef short int yyItemNum;
    672 
    673 typedef struct yyGLRState yyGLRState;
    674 typedef struct yyGLRStateSet yyGLRStateSet;
    675 typedef struct yySemanticOption yySemanticOption;
    676 typedef union yyGLRStackItem yyGLRStackItem;
    677 typedef struct yyGLRStack yyGLRStack;
    678 
    679 struct yyGLRState {
    680   /** Type tag: always true.  */
    681   yybool yyisState;
    682   /** Type tag for yysemantics.  If true, yysval applies, otherwise
    683    *  yyfirstVal applies.  */
    684   yybool yyresolved;
    685   /** Number of corresponding LALR(1) machine state.  */
    686   yyStateNum yylrState;
    687   /** Preceding state in this stack */
    688   yyGLRState* yypred;
    689   /** Source position of the first token produced by my symbol */
    690   size_t yyposn;
    691   union {
    692     /** First in a chain of alternative reductions producing the
    693      *  non-terminal corresponding to this state, threaded through
    694      *  yynext.  */
    695     yySemanticOption* yyfirstVal;
    696     /** Semantic value for this state.  */
    697     YYSTYPE yysval;
    698   } yysemantics;]b4_locations_if([[
    699   /** Source location for this state.  */
    700   YYLTYPE yyloc;]])[
    701 };
    702 
    703 struct yyGLRStateSet {
    704   yyGLRState** yystates;
    705   /** During nondeterministic operation, yylookaheadNeeds tracks which
    706    *  stacks have actually needed the current lookahead.  During deterministic
    707    *  operation, yylookaheadNeeds[0] is not maintained since it would merely
    708    *  duplicate yychar != YYEMPTY.  */
    709   yybool* yylookaheadNeeds;
    710   size_t yysize, yycapacity;
    711 };
    712 
    713 struct yySemanticOption {
    714   /** Type tag: always false.  */
    715   yybool yyisState;
    716   /** Rule number for this reduction */
    717   yyRuleNum yyrule;
    718   /** The last RHS state in the list of states to be reduced.  */
    719   yyGLRState* yystate;
    720   /** The lookahead for this reduction.  */
    721   int yyrawchar;
    722   YYSTYPE yyval;]b4_locations_if([[
    723   YYLTYPE yyloc;]])[
    724   /** Next sibling in chain of options.  To facilitate merging,
    725    *  options are chained in decreasing order by address.  */
    726   yySemanticOption* yynext;
    727 };
    728 
    729 /** Type of the items in the GLR stack.  The yyisState field
    730  *  indicates which item of the union is valid.  */
    731 union yyGLRStackItem {
    732   yyGLRState yystate;
    733   yySemanticOption yyoption;
    734 };
    735 
    736 struct yyGLRStack {
    737   int yyerrState;
    738 ]b4_locations_if([[  /* To compute the location of the error token.  */
    739   yyGLRStackItem yyerror_range[3];]])[
    740 ]b4_pure_if(
    741 [
    742   int yyerrcnt;
    743   int yyrawchar;
    744   YYSTYPE yyval;]b4_locations_if([[
    745   YYLTYPE yyloc;]])[
    746 ])[
    747   YYJMP_BUF yyexception_buffer;
    748   yyGLRStackItem* yyitems;
    749   yyGLRStackItem* yynextFree;
    750   size_t yyspaceLeft;
    751   yyGLRState* yysplitPoint;
    752   yyGLRState* yylastDeleted;
    753   yyGLRStateSet yytops;
    754 };
    755 
    756 #if YYSTACKEXPANDABLE
    757 static void yyexpandGLRStack (yyGLRStack* yystackp);
    758 #endif
    759 
    760 static void yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
    761   __attribute__ ((__noreturn__));
    762 static void
    763 yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
    764 {
    765   if (yymsg != YY_NULL)
    766     yyerror (]b4_yyerror_args[yymsg);
    767   YYLONGJMP (yystackp->yyexception_buffer, 1);
    768 }
    769 
    770 static void yyMemoryExhausted (yyGLRStack* yystackp)
    771   __attribute__ ((__noreturn__));
    772 static void
    773 yyMemoryExhausted (yyGLRStack* yystackp)
    774 {
    775   YYLONGJMP (yystackp->yyexception_buffer, 2);
    776 }
    777 
    778 #if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE
    779 /** A printable representation of TOKEN.  */
    780 static inline const char*
    781 yytokenName (yySymbol yytoken)
    782 {
    783   if (yytoken == YYEMPTY)
    784     return "";
    785 
    786   return yytname[yytoken];
    787 }
    788 #endif
    789 
    790 /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
    791  *  at YYVSP[YYLOW0].yystate.yypred.  Leaves YYVSP[YYLOW1].yystate.yypred
    792  *  containing the pointer to the next state in the chain.  */
    793 static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__));
    794 static void
    795 yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
    796 {
    797   int i;
    798   yyGLRState *s = yyvsp[yylow0].yystate.yypred;
    799   for (i = yylow0-1; i >= yylow1; i -= 1)
    800     {
    801       YYASSERT (s->yyresolved);
    802       yyvsp[i].yystate.yyresolved = yytrue;
    803       yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;]b4_locations_if([[
    804       yyvsp[i].yystate.yyloc = s->yyloc;]])[
    805       s = yyvsp[i].yystate.yypred = s->yypred;
    806     }
    807 }
    808 
    809 /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1.  Otherwise, fill in
    810  * YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
    811  * For convenience, always return YYLOW1.  */
    812 static inline int yyfill (yyGLRStackItem *, int *, int, yybool)
    813      __attribute__ ((__unused__));
    814 static inline int
    815 yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
    816 {
    817   if (!yynormal && yylow1 < *yylow)
    818     {
    819       yyfillin (yyvsp, *yylow, yylow1);
    820       *yylow = yylow1;
    821     }
    822   return yylow1;
    823 }
    824 
    825 /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
    826  *  and top stack item YYVSP.  YYLVALP points to place to put semantic
    827  *  value ($$), and yylocp points to place for location information
    828  *  (@@$).  Returns yyok for normal return, yyaccept for YYACCEPT,
    829  *  yyerr for YYERROR, yyabort for YYABORT.  */
    830 /*ARGSUSED*/ static YYRESULTTAG
    831 yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
    832               yyGLRStack* yystackp,
    833               YYSTYPE* yyvalp]b4_locuser_formals[)
    834 {
    835   yybool yynormal __attribute__ ((__unused__)) =
    836     (yystackp->yysplitPoint == YY_NULL);
    837   int yylow;
    838 ]b4_parse_param_use[]dnl
    839 [# undef yyerrok
    840 # define yyerrok (yystackp->yyerrState = 0)
    841 # undef YYACCEPT
    842 # define YYACCEPT return yyaccept
    843 # undef YYABORT
    844 # define YYABORT return yyabort
    845 # undef YYERROR
    846 # define YYERROR return yyerrok, yyerr
    847 # undef YYRECOVERING
    848 # define YYRECOVERING() (yystackp->yyerrState != 0)
    849 # undef yyclearin
    850 # define yyclearin (yychar = YYEMPTY)
    851 # undef YYFILL
    852 # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
    853 # undef YYBACKUP
    854 # define YYBACKUP(Token, Value)                                              \
    855   return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")),     \
    856          yyerrok, yyerr
    857 
    858   yylow = 1;
    859   if (yyrhslen == 0)
    860     *yyvalp = yyval_default;
    861   else
    862     *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;]b4_locations_if([[
    863   YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen);
    864   yystackp->yyerror_range[1].yystate.yyloc = *yylocp;
    865 ]])[
    866   switch (yyn)
    867     {
    868       ]b4_user_actions[
    869       default: break;
    870     }
    871 
    872   return yyok;
    873 # undef yyerrok
    874 # undef YYABORT
    875 # undef YYACCEPT
    876 # undef YYERROR
    877 # undef YYBACKUP
    878 # undef yyclearin
    879 # undef YYRECOVERING
    880 }
    881 
    882 
    884 /*ARGSUSED*/ static void
    885 yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
    886 {
    887   YYUSE (yy0);
    888   YYUSE (yy1);
    889 
    890   switch (yyn)
    891     {
    892       ]b4_mergers[
    893       default: break;
    894     }
    895 }
    896 
    897                               /* Bison grammar-table manipulation.  */
    898 
    899 ]b4_yydestruct_generate([b4_c_ansi_function_def])[
    900 
    901 /** Number of symbols composing the right hand side of rule #RULE.  */
    902 static inline int
    903 yyrhsLength (yyRuleNum yyrule)
    904 {
    905   return yyr2[yyrule];
    906 }
    907 
    908 static void
    909 yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
    910 {
    911   if (yys->yyresolved)
    912     yydestruct (yymsg, yystos[yys->yylrState],
    913                 &yys->yysemantics.yysval]b4_locuser_args([&yys->yyloc])[);
    914   else
    915     {
    916 #if ]b4_api_PREFIX[DEBUG
    917       if (yydebug)
    918         {
    919           if (yys->yysemantics.yyfirstVal)
    920             YYFPRINTF (stderr, "%s unresolved ", yymsg);
    921           else
    922             YYFPRINTF (stderr, "%s incomplete ", yymsg);
    923           yy_symbol_print (stderr, yystos[yys->yylrState],
    924                            YY_NULL]b4_locuser_args([&yys->yyloc])[);
    925           YYFPRINTF (stderr, "\n");
    926         }
    927 #endif
    928 
    929       if (yys->yysemantics.yyfirstVal)
    930         {
    931           yySemanticOption *yyoption = yys->yysemantics.yyfirstVal;
    932           yyGLRState *yyrh;
    933           int yyn;
    934           for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule);
    935                yyn > 0;
    936                yyrh = yyrh->yypred, yyn -= 1)
    937             yydestroyGLRState (yymsg, yyrh]b4_user_args[);
    938         }
    939     }
    940 }
    941 
    942 /** Left-hand-side symbol for rule #RULE.  */
    943 static inline yySymbol
    944 yylhsNonterm (yyRuleNum yyrule)
    945 {
    946   return yyr1[yyrule];
    947 }
    948 
    949 #define yypact_value_is_default(Yystate) \
    950   ]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
    951 
    952 /** True iff LR state STATE has only a default reduction (regardless
    953  *  of token).  */
    954 static inline yybool
    955 yyisDefaultedState (yyStateNum yystate)
    956 {
    957   return yypact_value_is_default (yypact[yystate]);
    958 }
    959 
    960 /** The default reduction for STATE, assuming it has one.  */
    961 static inline yyRuleNum
    962 yydefaultAction (yyStateNum yystate)
    963 {
    964   return yydefact[yystate];
    965 }
    966 
    967 #define yytable_value_is_error(Yytable_value) \
    968   ]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
    969 
    970 /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
    971  *  Result R means
    972  *    R < 0:  Reduce on rule -R.
    973  *    R = 0:  Error.
    974  *    R > 0:  Shift to state R.
    975  *  Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
    976  *  conflicting reductions.
    977  */
    978 static inline void
    979 yygetLRActions (yyStateNum yystate, int yytoken,
    980                 int* yyaction, const short int** yyconflicts)
    981 {
    982   int yyindex = yypact[yystate] + yytoken;
    983   if (yypact_value_is_default (yypact[yystate])
    984       || yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
    985     {
    986       *yyaction = -yydefact[yystate];
    987       *yyconflicts = yyconfl;
    988     }
    989   else if (! yytable_value_is_error (yytable[yyindex]))
    990     {
    991       *yyaction = yytable[yyindex];
    992       *yyconflicts = yyconfl + yyconflp[yyindex];
    993     }
    994   else
    995     {
    996       *yyaction = 0;
    997       *yyconflicts = yyconfl + yyconflp[yyindex];
    998     }
    999 }
   1000 
   1001 static inline yyStateNum
   1002 yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
   1003 {
   1004   int yyr;
   1005   yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
   1006   if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
   1007     return yytable[yyr];
   1008   else
   1009     return yydefgoto[yylhs - YYNTOKENS];
   1010 }
   1011 
   1012 static inline yybool
   1013 yyisShiftAction (int yyaction)
   1014 {
   1015   return 0 < yyaction;
   1016 }
   1017 
   1018 static inline yybool
   1019 yyisErrorAction (int yyaction)
   1020 {
   1021   return yyaction == 0;
   1022 }
   1023 
   1024                                 /* GLRStates */
   1025 
   1026 /** Return a fresh GLRStackItem.  Callers should call
   1027  * YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
   1028  * headroom.  */
   1029 
   1030 static inline yyGLRStackItem*
   1031 yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
   1032 {
   1033   yyGLRStackItem* yynewItem = yystackp->yynextFree;
   1034   yystackp->yyspaceLeft -= 1;
   1035   yystackp->yynextFree += 1;
   1036   yynewItem->yystate.yyisState = yyisState;
   1037   return yynewItem;
   1038 }
   1039 
   1040 /** Add a new semantic action that will execute the action for rule
   1041  *  RULENUM on the semantic values in RHS to the list of
   1042  *  alternative actions for STATE.  Assumes that RHS comes from
   1043  *  stack #K of *STACKP. */
   1044 static void
   1045 yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
   1046                      yyGLRState* rhs, yyRuleNum yyrule)
   1047 {
   1048   yySemanticOption* yynewOption =
   1049     &yynewGLRStackItem (yystackp, yyfalse)->yyoption;
   1050   yynewOption->yystate = rhs;
   1051   yynewOption->yyrule = yyrule;
   1052   if (yystackp->yytops.yylookaheadNeeds[yyk])
   1053     {
   1054       yynewOption->yyrawchar = yychar;
   1055       yynewOption->yyval = yylval;]b4_locations_if([
   1056       yynewOption->yyloc = yylloc;])[
   1057     }
   1058   else
   1059     yynewOption->yyrawchar = YYEMPTY;
   1060   yynewOption->yynext = yystate->yysemantics.yyfirstVal;
   1061   yystate->yysemantics.yyfirstVal = yynewOption;
   1062 
   1063   YY_RESERVE_GLRSTACK (yystackp);
   1064 }
   1065 
   1066                                 /* GLRStacks */
   1067 
   1068 /** Initialize SET to a singleton set containing an empty stack.  */
   1069 static yybool
   1070 yyinitStateSet (yyGLRStateSet* yyset)
   1071 {
   1072   yyset->yysize = 1;
   1073   yyset->yycapacity = 16;
   1074   yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
   1075   if (! yyset->yystates)
   1076     return yyfalse;
   1077   yyset->yystates[0] = YY_NULL;
   1078   yyset->yylookaheadNeeds =
   1079     (yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]);
   1080   if (! yyset->yylookaheadNeeds)
   1081     {
   1082       YYFREE (yyset->yystates);
   1083       return yyfalse;
   1084     }
   1085   return yytrue;
   1086 }
   1087 
   1088 static void yyfreeStateSet (yyGLRStateSet* yyset)
   1089 {
   1090   YYFREE (yyset->yystates);
   1091   YYFREE (yyset->yylookaheadNeeds);
   1092 }
   1093 
   1094 /** Initialize STACK to a single empty stack, with total maximum
   1095  *  capacity for all stacks of SIZE.  */
   1096 static yybool
   1097 yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
   1098 {
   1099   yystackp->yyerrState = 0;
   1100   yynerrs = 0;
   1101   yystackp->yyspaceLeft = yysize;
   1102   yystackp->yyitems =
   1103     (yyGLRStackItem*) YYMALLOC (yysize * sizeof yystackp->yynextFree[0]);
   1104   if (!yystackp->yyitems)
   1105     return yyfalse;
   1106   yystackp->yynextFree = yystackp->yyitems;
   1107   yystackp->yysplitPoint = YY_NULL;
   1108   yystackp->yylastDeleted = YY_NULL;
   1109   return yyinitStateSet (&yystackp->yytops);
   1110 }
   1111 
   1112 
   1113 #if YYSTACKEXPANDABLE
   1114 # define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
   1115   &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
   1116 
   1117 /** If STACK is expandable, extend it.  WARNING: Pointers into the
   1118     stack from outside should be considered invalid after this call.
   1119     We always expand when there are 1 or fewer items left AFTER an
   1120     allocation, so that we can avoid having external pointers exist
   1121     across an allocation.  */
   1122 static void
   1123 yyexpandGLRStack (yyGLRStack* yystackp)
   1124 {
   1125   yyGLRStackItem* yynewItems;
   1126   yyGLRStackItem* yyp0, *yyp1;
   1127   size_t yynewSize;
   1128   size_t yyn;
   1129   size_t yysize = yystackp->yynextFree - yystackp->yyitems;
   1130   if (YYMAXDEPTH - YYHEADROOM < yysize)
   1131     yyMemoryExhausted (yystackp);
   1132   yynewSize = 2*yysize;
   1133   if (YYMAXDEPTH < yynewSize)
   1134     yynewSize = YYMAXDEPTH;
   1135   yynewItems = (yyGLRStackItem*) YYMALLOC (yynewSize * sizeof yynewItems[0]);
   1136   if (! yynewItems)
   1137     yyMemoryExhausted (yystackp);
   1138   for (yyp0 = yystackp->yyitems, yyp1 = yynewItems, yyn = yysize;
   1139        0 < yyn;
   1140        yyn -= 1, yyp0 += 1, yyp1 += 1)
   1141     {
   1142       *yyp1 = *yyp0;
   1143       if (*(yybool *) yyp0)
   1144         {
   1145           yyGLRState* yys0 = &yyp0->yystate;
   1146           yyGLRState* yys1 = &yyp1->yystate;
   1147           if (yys0->yypred != YY_NULL)
   1148             yys1->yypred =
   1149               YYRELOC (yyp0, yyp1, yys0->yypred, yystate);
   1150           if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != YY_NULL)
   1151             yys1->yysemantics.yyfirstVal =
   1152               YYRELOC (yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption);
   1153         }
   1154       else
   1155         {
   1156           yySemanticOption* yyv0 = &yyp0->yyoption;
   1157           yySemanticOption* yyv1 = &yyp1->yyoption;
   1158           if (yyv0->yystate != YY_NULL)
   1159             yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate);
   1160           if (yyv0->yynext != YY_NULL)
   1161             yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption);
   1162         }
   1163     }
   1164   if (yystackp->yysplitPoint != YY_NULL)
   1165     yystackp->yysplitPoint = YYRELOC (yystackp->yyitems, yynewItems,
   1166                                  yystackp->yysplitPoint, yystate);
   1167 
   1168   for (yyn = 0; yyn < yystackp->yytops.yysize; yyn += 1)
   1169     if (yystackp->yytops.yystates[yyn] != YY_NULL)
   1170       yystackp->yytops.yystates[yyn] =
   1171         YYRELOC (yystackp->yyitems, yynewItems,
   1172                  yystackp->yytops.yystates[yyn], yystate);
   1173   YYFREE (yystackp->yyitems);
   1174   yystackp->yyitems = yynewItems;
   1175   yystackp->yynextFree = yynewItems + yysize;
   1176   yystackp->yyspaceLeft = yynewSize - yysize;
   1177 }
   1178 #endif
   1179 
   1180 static void
   1181 yyfreeGLRStack (yyGLRStack* yystackp)
   1182 {
   1183   YYFREE (yystackp->yyitems);
   1184   yyfreeStateSet (&yystackp->yytops);
   1185 }
   1186 
   1187 /** Assuming that S is a GLRState somewhere on STACK, update the
   1188  *  splitpoint of STACK, if needed, so that it is at least as deep as
   1189  *  S.  */
   1190 static inline void
   1191 yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
   1192 {
   1193   if (yystackp->yysplitPoint != YY_NULL && yystackp->yysplitPoint > yys)
   1194     yystackp->yysplitPoint = yys;
   1195 }
   1196 
   1197 /** Invalidate stack #K in STACK.  */
   1198 static inline void
   1199 yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
   1200 {
   1201   if (yystackp->yytops.yystates[yyk] != YY_NULL)
   1202     yystackp->yylastDeleted = yystackp->yytops.yystates[yyk];
   1203   yystackp->yytops.yystates[yyk] = YY_NULL;
   1204 }
   1205 
   1206 /** Undelete the last stack that was marked as deleted.  Can only be
   1207     done once after a deletion, and only when all other stacks have
   1208     been deleted.  */
   1209 static void
   1210 yyundeleteLastStack (yyGLRStack* yystackp)
   1211 {
   1212   if (yystackp->yylastDeleted == YY_NULL || yystackp->yytops.yysize != 0)
   1213     return;
   1214   yystackp->yytops.yystates[0] = yystackp->yylastDeleted;
   1215   yystackp->yytops.yysize = 1;
   1216   YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
   1217   yystackp->yylastDeleted = YY_NULL;
   1218 }
   1219 
   1220 static inline void
   1221 yyremoveDeletes (yyGLRStack* yystackp)
   1222 {
   1223   size_t yyi, yyj;
   1224   yyi = yyj = 0;
   1225   while (yyj < yystackp->yytops.yysize)
   1226     {
   1227       if (yystackp->yytops.yystates[yyi] == YY_NULL)
   1228         {
   1229           if (yyi == yyj)
   1230             {
   1231               YYDPRINTF ((stderr, "Removing dead stacks.\n"));
   1232             }
   1233           yystackp->yytops.yysize -= 1;
   1234         }
   1235       else
   1236         {
   1237           yystackp->yytops.yystates[yyj] = yystackp->yytops.yystates[yyi];
   1238           /* In the current implementation, it's unnecessary to copy
   1239              yystackp->yytops.yylookaheadNeeds[yyi] since, after
   1240              yyremoveDeletes returns, the parser immediately either enters
   1241              deterministic operation or shifts a token.  However, it doesn't
   1242              hurt, and the code might evolve to need it.  */
   1243           yystackp->yytops.yylookaheadNeeds[yyj] =
   1244             yystackp->yytops.yylookaheadNeeds[yyi];
   1245           if (yyj != yyi)
   1246             {
   1247               YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
   1248                           (unsigned long int) yyi, (unsigned long int) yyj));
   1249             }
   1250           yyj += 1;
   1251         }
   1252       yyi += 1;
   1253     }
   1254 }
   1255 
   1256 /** Shift to a new state on stack #K of STACK, corresponding to LR state
   1257  * LRSTATE, at input position POSN, with (resolved) semantic value SVAL.  */
   1258 static inline void
   1259 yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
   1260             size_t yyposn,
   1261             YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[)
   1262 {
   1263   yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
   1264 
   1265   yynewState->yylrState = yylrState;
   1266   yynewState->yyposn = yyposn;
   1267   yynewState->yyresolved = yytrue;
   1268   yynewState->yypred = yystackp->yytops.yystates[yyk];
   1269   yynewState->yysemantics.yysval = *yyvalp;]b4_locations_if([
   1270   yynewState->yyloc = *yylocp;])[
   1271   yystackp->yytops.yystates[yyk] = yynewState;
   1272 
   1273   YY_RESERVE_GLRSTACK (yystackp);
   1274 }
   1275 
   1276 /** Shift stack #K of YYSTACK, to a new state corresponding to LR
   1277  *  state YYLRSTATE, at input position YYPOSN, with the (unresolved)
   1278  *  semantic value of YYRHS under the action for YYRULE.  */
   1279 static inline void
   1280 yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
   1281                  size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
   1282 {
   1283   yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
   1284 
   1285   yynewState->yylrState = yylrState;
   1286   yynewState->yyposn = yyposn;
   1287   yynewState->yyresolved = yyfalse;
   1288   yynewState->yypred = yystackp->yytops.yystates[yyk];
   1289   yynewState->yysemantics.yyfirstVal = YY_NULL;
   1290   yystackp->yytops.yystates[yyk] = yynewState;
   1291 
   1292   /* Invokes YY_RESERVE_GLRSTACK.  */
   1293   yyaddDeferredAction (yystackp, yyk, yynewState, rhs, yyrule);
   1294 }
   1295 
   1296 /** Pop the symbols consumed by reduction #RULE from the top of stack
   1297  *  #K of STACK, and perform the appropriate semantic action on their
   1298  *  semantic values.  Assumes that all ambiguities in semantic values
   1299  *  have been previously resolved.  Set *VALP to the resulting value,
   1300  *  and *LOCP to the computed location (if any).  Return value is as
   1301  *  for userAction.  */
   1302 static inline YYRESULTTAG
   1303 yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
   1304             YYSTYPE* yyvalp]b4_locuser_formals[)
   1305 {
   1306   int yynrhs = yyrhsLength (yyrule);
   1307 
   1308   if (yystackp->yysplitPoint == YY_NULL)
   1309     {
   1310       /* Standard special case: single stack.  */
   1311       yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
   1312       YYASSERT (yyk == 0);
   1313       yystackp->yynextFree -= yynrhs;
   1314       yystackp->yyspaceLeft += yynrhs;
   1315       yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
   1316       return yyuserAction (yyrule, yynrhs, rhs, yystackp,
   1317                            yyvalp]b4_locuser_args[);
   1318     }
   1319   else
   1320     {
   1321       /* At present, doAction is never called in nondeterministic
   1322        * mode, so this branch is never taken.  It is here in
   1323        * anticipation of a future feature that will allow immediate
   1324        * evaluation of selected actions in nondeterministic mode.  */
   1325       int yyi;
   1326       yyGLRState* yys;
   1327       yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
   1328       yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
   1329         = yystackp->yytops.yystates[yyk];]b4_locations_if([[
   1330       if (yynrhs == 0)
   1331         /* Set default location.  */
   1332         yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[
   1333       for (yyi = 0; yyi < yynrhs; yyi += 1)
   1334         {
   1335           yys = yys->yypred;
   1336           YYASSERT (yys);
   1337         }
   1338       yyupdateSplit (yystackp, yys);
   1339       yystackp->yytops.yystates[yyk] = yys;
   1340       return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
   1341                            yystackp, yyvalp]b4_locuser_args[);
   1342     }
   1343 }
   1344 
   1345 #if !]b4_api_PREFIX[DEBUG
   1346 # define YY_REDUCE_PRINT(Args)
   1347 #else
   1348 # define YY_REDUCE_PRINT(Args)          \
   1349 do {                                    \
   1350   if (yydebug)                          \
   1351     yy_reduce_print Args;               \
   1352 } while (YYID (0))
   1353 
   1354 /*----------------------------------------------------------.
   1355 | Report that the RULE is going to be reduced on stack #K.  |
   1356 `----------------------------------------------------------*/
   1357 
   1358 /*ARGSUSED*/ static inline void
   1359 yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
   1360                  YYSTYPE* yyvalp]b4_locuser_formals[)
   1361 {
   1362   int yynrhs = yyrhsLength (yyrule);
   1363   yybool yynormal __attribute__ ((__unused__)) =
   1364     (yystackp->yysplitPoint == YY_NULL);
   1365   yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
   1366   int yylow = 1;
   1367   int yyi;
   1368   YYUSE (yyvalp);]b4_locations_if([
   1369   YYUSE (yylocp);])[
   1370 ]b4_parse_param_use[]dnl
   1371 [  YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
   1372              (unsigned long int) yyk, yyrule - 1,
   1373              (unsigned long int) yyrline[yyrule]);
   1374   /* The symbols being reduced.  */
   1375   for (yyi = 0; yyi < yynrhs; yyi++)
   1376     {
   1377       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
   1378       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
   1379                        &]b4_rhs_value(yynrhs, yyi + 1)[
   1380                        ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
   1381                        b4_user_args[);
   1382       YYFPRINTF (stderr, "\n");
   1383     }
   1384 }
   1385 #endif
   1386 
   1387 /** Pop items off stack #K of STACK according to grammar rule RULE,
   1388  *  and push back on the resulting nonterminal symbol.  Perform the
   1389  *  semantic action associated with RULE and store its value with the
   1390  *  newly pushed state, if FORCEEVAL or if STACK is currently
   1391  *  unambiguous.  Otherwise, store the deferred semantic action with
   1392  *  the new state.  If the new state would have an identical input
   1393  *  position, LR state, and predecessor to an existing state on the stack,
   1394  *  it is identified with that existing state, eliminating stack #K from
   1395  *  the STACK.  In this case, the (necessarily deferred) semantic value is
   1396  *  added to the options for the existing state's semantic value.
   1397  */
   1398 static inline YYRESULTTAG
   1399 yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
   1400              yybool yyforceEval]b4_user_formals[)
   1401 {
   1402   size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
   1403 
   1404   if (yyforceEval || yystackp->yysplitPoint == YY_NULL)
   1405     {
   1406       YYSTYPE yysval;]b4_locations_if([
   1407       YYLTYPE yyloc;])[
   1408 
   1409       YY_REDUCE_PRINT ((yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[));
   1410       YYCHK (yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[));
   1411       YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
   1412       yyglrShift (yystackp, yyk,
   1413                   yyLRgotoState (yystackp->yytops.yystates[yyk]->yylrState,
   1414                                  yylhsNonterm (yyrule)),
   1415                   yyposn, &yysval]b4_locations_if([, &yyloc])[);
   1416     }
   1417   else
   1418     {
   1419       size_t yyi;
   1420       int yyn;
   1421       yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk];
   1422       yyStateNum yynewLRState;
   1423 
   1424       for (yys = yystackp->yytops.yystates[yyk], yyn = yyrhsLength (yyrule);
   1425            0 < yyn; yyn -= 1)
   1426         {
   1427           yys = yys->yypred;
   1428           YYASSERT (yys);
   1429         }
   1430       yyupdateSplit (yystackp, yys);
   1431       yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
   1432       YYDPRINTF ((stderr,
   1433                   "Reduced stack %lu by rule #%d; action deferred.  Now in state %d.\n",
   1434                   (unsigned long int) yyk, yyrule - 1, yynewLRState));
   1435       for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
   1436         if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULL)
   1437           {
   1438             yyGLRState *yysplit = yystackp->yysplitPoint;
   1439             yyGLRState *yyp = yystackp->yytops.yystates[yyi];
   1440             while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn)
   1441               {
   1442                 if (yyp->yylrState == yynewLRState && yyp->yypred == yys)
   1443                   {
   1444                     yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule);
   1445                     yymarkStackDeleted (yystackp, yyk);
   1446                     YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n",
   1447                                 (unsigned long int) yyk,
   1448                                 (unsigned long int) yyi));
   1449                     return yyok;
   1450                   }
   1451                 yyp = yyp->yypred;
   1452               }
   1453           }
   1454       yystackp->yytops.yystates[yyk] = yys;
   1455       yyglrShiftDefer (yystackp, yyk, yynewLRState, yyposn, yys0, yyrule);
   1456     }
   1457   return yyok;
   1458 }
   1459 
   1460 static size_t
   1461 yysplitStack (yyGLRStack* yystackp, size_t yyk)
   1462 {
   1463   if (yystackp->yysplitPoint == YY_NULL)
   1464     {
   1465       YYASSERT (yyk == 0);
   1466       yystackp->yysplitPoint = yystackp->yytops.yystates[yyk];
   1467     }
   1468   if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity)
   1469     {
   1470       yyGLRState** yynewStates;
   1471       yybool* yynewLookaheadNeeds;
   1472 
   1473       yynewStates = YY_NULL;
   1474 
   1475       if (yystackp->yytops.yycapacity
   1476           > (YYSIZEMAX / (2 * sizeof yynewStates[0])))
   1477         yyMemoryExhausted (yystackp);
   1478       yystackp->yytops.yycapacity *= 2;
   1479 
   1480       yynewStates =
   1481         (yyGLRState**) YYREALLOC (yystackp->yytops.yystates,
   1482                                   (yystackp->yytops.yycapacity
   1483                                    * sizeof yynewStates[0]));
   1484       if (yynewStates == YY_NULL)
   1485         yyMemoryExhausted (yystackp);
   1486       yystackp->yytops.yystates = yynewStates;
   1487 
   1488       yynewLookaheadNeeds =
   1489         (yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds,
   1490                              (yystackp->yytops.yycapacity
   1491                               * sizeof yynewLookaheadNeeds[0]));
   1492       if (yynewLookaheadNeeds == YY_NULL)
   1493         yyMemoryExhausted (yystackp);
   1494       yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds;
   1495     }
   1496   yystackp->yytops.yystates[yystackp->yytops.yysize]
   1497     = yystackp->yytops.yystates[yyk];
   1498   yystackp->yytops.yylookaheadNeeds[yystackp->yytops.yysize]
   1499     = yystackp->yytops.yylookaheadNeeds[yyk];
   1500   yystackp->yytops.yysize += 1;
   1501   return yystackp->yytops.yysize-1;
   1502 }
   1503 
   1504 /** True iff Y0 and Y1 represent identical options at the top level.
   1505  *  That is, they represent the same rule applied to RHS symbols
   1506  *  that produce the same terminal symbols.  */
   1507 static yybool
   1508 yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
   1509 {
   1510   if (yyy0->yyrule == yyy1->yyrule)
   1511     {
   1512       yyGLRState *yys0, *yys1;
   1513       int yyn;
   1514       for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
   1515            yyn = yyrhsLength (yyy0->yyrule);
   1516            yyn > 0;
   1517            yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
   1518         if (yys0->yyposn != yys1->yyposn)
   1519           return yyfalse;
   1520       return yytrue;
   1521     }
   1522   else
   1523     return yyfalse;
   1524 }
   1525 
   1526 /** Assuming identicalOptions (Y0,Y1), destructively merge the
   1527  *  alternative semantic values for the RHS-symbols of Y1 and Y0.  */
   1528 static void
   1529 yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
   1530 {
   1531   yyGLRState *yys0, *yys1;
   1532   int yyn;
   1533   for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
   1534        yyn = yyrhsLength (yyy0->yyrule);
   1535        yyn > 0;
   1536        yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
   1537     {
   1538       if (yys0 == yys1)
   1539         break;
   1540       else if (yys0->yyresolved)
   1541         {
   1542           yys1->yyresolved = yytrue;
   1543           yys1->yysemantics.yysval = yys0->yysemantics.yysval;
   1544         }
   1545       else if (yys1->yyresolved)
   1546         {
   1547           yys0->yyresolved = yytrue;
   1548           yys0->yysemantics.yysval = yys1->yysemantics.yysval;
   1549         }
   1550       else
   1551         {
   1552           yySemanticOption** yyz0p = &yys0->yysemantics.yyfirstVal;
   1553           yySemanticOption* yyz1 = yys1->yysemantics.yyfirstVal;
   1554           while (YYID (yytrue))
   1555             {
   1556               if (yyz1 == *yyz0p || yyz1 == YY_NULL)
   1557                 break;
   1558               else if (*yyz0p == YY_NULL)
   1559                 {
   1560                   *yyz0p = yyz1;
   1561                   break;
   1562                 }
   1563               else if (*yyz0p < yyz1)
   1564                 {
   1565                   yySemanticOption* yyz = *yyz0p;
   1566                   *yyz0p = yyz1;
   1567                   yyz1 = yyz1->yynext;
   1568                   (*yyz0p)->yynext = yyz;
   1569                 }
   1570               yyz0p = &(*yyz0p)->yynext;
   1571             }
   1572           yys1->yysemantics.yyfirstVal = yys0->yysemantics.yyfirstVal;
   1573         }
   1574     }
   1575 }
   1576 
   1577 /** Y0 and Y1 represent two possible actions to take in a given
   1578  *  parsing state; return 0 if no combination is possible,
   1579  *  1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred.  */
   1580 static int
   1581 yypreference (yySemanticOption* y0, yySemanticOption* y1)
   1582 {
   1583   yyRuleNum r0 = y0->yyrule, r1 = y1->yyrule;
   1584   int p0 = yydprec[r0], p1 = yydprec[r1];
   1585 
   1586   if (p0 == p1)
   1587     {
   1588       if (yymerger[r0] == 0 || yymerger[r0] != yymerger[r1])
   1589         return 0;
   1590       else
   1591         return 1;
   1592     }
   1593   if (p0 == 0 || p1 == 0)
   1594     return 0;
   1595   if (p0 < p1)
   1596     return 3;
   1597   if (p1 < p0)
   1598     return 2;
   1599   return 0;
   1600 }
   1601 
   1602 static YYRESULTTAG yyresolveValue (yyGLRState* yys,
   1603                                    yyGLRStack* yystackp]b4_user_formals[);
   1604 
   1605 
   1606 /** Resolve the previous N states starting at and including state S.  If result
   1607  *  != yyok, some states may have been left unresolved possibly with empty
   1608  *  semantic option chains.  Regardless of whether result = yyok, each state
   1609  *  has been left with consistent data so that yydestroyGLRState can be invoked
   1610  *  if necessary.  */
   1611 static YYRESULTTAG
   1612 yyresolveStates (yyGLRState* yys, int yyn,
   1613                  yyGLRStack* yystackp]b4_user_formals[)
   1614 {
   1615   if (0 < yyn)
   1616     {
   1617       YYASSERT (yys->yypred);
   1618       YYCHK (yyresolveStates (yys->yypred, yyn-1, yystackp]b4_user_args[));
   1619       if (! yys->yyresolved)
   1620         YYCHK (yyresolveValue (yys, yystackp]b4_user_args[));
   1621     }
   1622   return yyok;
   1623 }
   1624 
   1625 /** Resolve the states for the RHS of OPT, perform its user action, and return
   1626  *  the semantic value and location.  Regardless of whether result = yyok, all
   1627  *  RHS states have been destroyed (assuming the user action destroys all RHS
   1628  *  semantic values if invoked).  */
   1629 static YYRESULTTAG
   1630 yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
   1631                  YYSTYPE* yyvalp]b4_locuser_formals[)
   1632 {
   1633   yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
   1634   int yynrhs = yyrhsLength (yyopt->yyrule);
   1635   YYRESULTTAG yyflag =
   1636     yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[);
   1637   if (yyflag != yyok)
   1638     {
   1639       yyGLRState *yys;
   1640       for (yys = yyopt->yystate; yynrhs > 0; yys = yys->yypred, yynrhs -= 1)
   1641         yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[);
   1642       return yyflag;
   1643     }
   1644 
   1645   yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_locations_if([[
   1646   if (yynrhs == 0)
   1647     /* Set default location.  */
   1648     yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[
   1649   {
   1650     int yychar_current = yychar;
   1651     YYSTYPE yylval_current = yylval;]b4_locations_if([
   1652     YYLTYPE yylloc_current = yylloc;])[
   1653     yychar = yyopt->yyrawchar;
   1654     yylval = yyopt->yyval;]b4_locations_if([
   1655     yylloc = yyopt->yyloc;])[
   1656     yyflag = yyuserAction (yyopt->yyrule, yynrhs,
   1657                            yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
   1658                            yystackp, yyvalp]b4_locuser_args[);
   1659     yychar = yychar_current;
   1660     yylval = yylval_current;]b4_locations_if([
   1661     yylloc = yylloc_current;])[
   1662   }
   1663   return yyflag;
   1664 }
   1665 
   1666 #if ]b4_api_PREFIX[DEBUG
   1667 static void
   1668 yyreportTree (yySemanticOption* yyx, int yyindent)
   1669 {
   1670   int yynrhs = yyrhsLength (yyx->yyrule);
   1671   int yyi;
   1672   yyGLRState* yys;
   1673   yyGLRState* yystates[1 + YYMAXRHS];
   1674   yyGLRState yyleftmost_state;
   1675 
   1676   for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred)
   1677     yystates[yyi] = yys;
   1678   if (yys == YY_NULL)
   1679     {
   1680       yyleftmost_state.yyposn = 0;
   1681       yystates[0] = &yyleftmost_state;
   1682     }
   1683   else
   1684     yystates[0] = yys;
   1685 
   1686   if (yyx->yystate->yyposn < yys->yyposn + 1)
   1687     YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n",
   1688                yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
   1689                yyx->yyrule - 1);
   1690   else
   1691     YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
   1692                yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
   1693                yyx->yyrule - 1, (unsigned long int) (yys->yyposn + 1),
   1694                (unsigned long int) yyx->yystate->yyposn);
   1695   for (yyi = 1; yyi <= yynrhs; yyi += 1)
   1696     {
   1697       if (yystates[yyi]->yyresolved)
   1698         {
   1699           if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
   1700             YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
   1701                        yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]));
   1702           else
   1703             YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
   1704                        yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]),
   1705                        (unsigned long int) (yystates[yyi - 1]->yyposn + 1),
   1706                        (unsigned long int) yystates[yyi]->yyposn);
   1707         }
   1708       else
   1709         yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
   1710     }
   1711 }
   1712 #endif
   1713 
   1714 /*ARGSUSED*/ static YYRESULTTAG
   1715 yyreportAmbiguity (yySemanticOption* yyx0,
   1716                    yySemanticOption* yyx1]b4_pure_formals[)
   1717 {
   1718   YYUSE (yyx0);
   1719   YYUSE (yyx1);
   1720 
   1721 #if ]b4_api_PREFIX[DEBUG
   1722   YYFPRINTF (stderr, "Ambiguity detected.\n");
   1723   YYFPRINTF (stderr, "Option 1,\n");
   1724   yyreportTree (yyx0, 2);
   1725   YYFPRINTF (stderr, "\nOption 2,\n");
   1726   yyreportTree (yyx1, 2);
   1727   YYFPRINTF (stderr, "\n");
   1728 #endif
   1729 
   1730   yyerror (]b4_yyerror_args[YY_("syntax is ambiguous"));
   1731   return yyabort;
   1732 }]b4_locations_if([[
   1733 
   1734 /** Starting at and including state S1, resolve the location for each of the
   1735  *  previous N1 states that is unresolved.  The first semantic option of a state
   1736  *  is always chosen.  */
   1737 static void
   1738 yyresolveLocations (yyGLRState* yys1, int yyn1,
   1739                     yyGLRStack *yystackp]b4_user_formals[)
   1740 {
   1741   if (0 < yyn1)
   1742     {
   1743       yyresolveLocations (yys1->yypred, yyn1 - 1, yystackp]b4_user_args[);
   1744       if (!yys1->yyresolved)
   1745         {
   1746           yyGLRStackItem yyrhsloc[1 + YYMAXRHS];
   1747           int yynrhs;
   1748           yySemanticOption *yyoption = yys1->yysemantics.yyfirstVal;
   1749           YYASSERT (yyoption != YY_NULL);
   1750           yynrhs = yyrhsLength (yyoption->yyrule);
   1751           if (yynrhs > 0)
   1752             {
   1753               yyGLRState *yys;
   1754               int yyn;
   1755               yyresolveLocations (yyoption->yystate, yynrhs,
   1756                                   yystackp]b4_user_args[);
   1757               for (yys = yyoption->yystate, yyn = yynrhs;
   1758                    yyn > 0;
   1759                    yys = yys->yypred, yyn -= 1)
   1760                 yyrhsloc[yyn].yystate.yyloc = yys->yyloc;
   1761             }
   1762           else
   1763             {
   1764               /* Both yyresolveAction and yyresolveLocations traverse the GSS
   1765                  in reverse rightmost order.  It is only necessary to invoke
   1766                  yyresolveLocations on a subforest for which yyresolveAction
   1767                  would have been invoked next had an ambiguity not been
   1768                  detected.  Thus the location of the previous state (but not
   1769                  necessarily the previous state itself) is guaranteed to be
   1770                  resolved already.  */
   1771               yyGLRState *yyprevious = yyoption->yystate;
   1772               yyrhsloc[0].yystate.yyloc = yyprevious->yyloc;
   1773             }
   1774           {
   1775             int yychar_current = yychar;
   1776             YYSTYPE yylval_current = yylval;
   1777             YYLTYPE yylloc_current = yylloc;
   1778             yychar = yyoption->yyrawchar;
   1779             yylval = yyoption->yyval;
   1780             yylloc = yyoption->yyloc;
   1781             YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
   1782             yychar = yychar_current;
   1783             yylval = yylval_current;
   1784             yylloc = yylloc_current;
   1785           }
   1786         }
   1787     }
   1788 }]])[
   1789 
   1790 /** Resolve the ambiguity represented in state S, perform the indicated
   1791  *  actions, and set the semantic value of S.  If result != yyok, the chain of
   1792  *  semantic options in S has been cleared instead or it has been left
   1793  *  unmodified except that redundant options may have been removed.  Regardless
   1794  *  of whether result = yyok, S has been left with consistent data so that
   1795  *  yydestroyGLRState can be invoked if necessary.  */
   1796 static YYRESULTTAG
   1797 yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
   1798 {
   1799   yySemanticOption* yyoptionList = yys->yysemantics.yyfirstVal;
   1800   yySemanticOption* yybest = yyoptionList;
   1801   yySemanticOption** yypp;
   1802   yybool yymerge = yyfalse;
   1803   YYSTYPE yysval;
   1804   YYRESULTTAG yyflag;]b4_locations_if([
   1805   YYLTYPE *yylocp = &yys->yyloc;])[
   1806 
   1807   for (yypp = &yyoptionList->yynext; *yypp != YY_NULL; )
   1808     {
   1809       yySemanticOption* yyp = *yypp;
   1810 
   1811       if (yyidenticalOptions (yybest, yyp))
   1812         {
   1813           yymergeOptionSets (yybest, yyp);
   1814           *yypp = yyp->yynext;
   1815         }
   1816       else
   1817         {
   1818           switch (yypreference (yybest, yyp))
   1819             {
   1820             case 0:]b4_locations_if([[
   1821               yyresolveLocations (yys, 1, yystackp]b4_user_args[);]])[
   1822               return yyreportAmbiguity (yybest, yyp]b4_pure_args[);
   1823               break;
   1824             case 1:
   1825               yymerge = yytrue;
   1826               break;
   1827             case 2:
   1828               break;
   1829             case 3:
   1830               yybest = yyp;
   1831               yymerge = yyfalse;
   1832               break;
   1833             default:
   1834               /* This cannot happen so it is not worth a YYASSERT (yyfalse),
   1835                  but some compilers complain if the default case is
   1836                  omitted.  */
   1837               break;
   1838             }
   1839           yypp = &yyp->yynext;
   1840         }
   1841     }
   1842 
   1843   if (yymerge)
   1844     {
   1845       yySemanticOption* yyp;
   1846       int yyprec = yydprec[yybest->yyrule];
   1847       yyflag = yyresolveAction (yybest, yystackp, &yysval]b4_locuser_args[);
   1848       if (yyflag == yyok)
   1849         for (yyp = yybest->yynext; yyp != YY_NULL; yyp = yyp->yynext)
   1850           {
   1851             if (yyprec == yydprec[yyp->yyrule])
   1852               {
   1853                 YYSTYPE yysval_other;]b4_locations_if([
   1854                 YYLTYPE yydummy;])[
   1855                 yyflag = yyresolveAction (yyp, yystackp, &yysval_other]b4_locuser_args([&yydummy])[);
   1856                 if (yyflag != yyok)
   1857                   {
   1858                     yydestruct ("Cleanup: discarding incompletely merged value for",
   1859                                 yystos[yys->yylrState],
   1860                                 &yysval]b4_locuser_args[);
   1861                     break;
   1862                   }
   1863                 yyuserMerge (yymerger[yyp->yyrule], &yysval, &yysval_other);
   1864               }
   1865           }
   1866     }
   1867   else
   1868     yyflag = yyresolveAction (yybest, yystackp, &yysval]b4_locuser_args([yylocp])[);
   1869 
   1870   if (yyflag == yyok)
   1871     {
   1872       yys->yyresolved = yytrue;
   1873       yys->yysemantics.yysval = yysval;
   1874     }
   1875   else
   1876     yys->yysemantics.yyfirstVal = YY_NULL;
   1877   return yyflag;
   1878 }
   1879 
   1880 static YYRESULTTAG
   1881 yyresolveStack (yyGLRStack* yystackp]b4_user_formals[)
   1882 {
   1883   if (yystackp->yysplitPoint != YY_NULL)
   1884     {
   1885       yyGLRState* yys;
   1886       int yyn;
   1887 
   1888       for (yyn = 0, yys = yystackp->yytops.yystates[0];
   1889            yys != yystackp->yysplitPoint;
   1890            yys = yys->yypred, yyn += 1)
   1891         continue;
   1892       YYCHK (yyresolveStates (yystackp->yytops.yystates[0], yyn, yystackp
   1893                              ]b4_user_args[));
   1894     }
   1895   return yyok;
   1896 }
   1897 
   1898 static void
   1899 yycompressStack (yyGLRStack* yystackp)
   1900 {
   1901   yyGLRState* yyp, *yyq, *yyr;
   1902 
   1903   if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == YY_NULL)
   1904     return;
   1905 
   1906   for (yyp = yystackp->yytops.yystates[0], yyq = yyp->yypred, yyr = YY_NULL;
   1907        yyp != yystackp->yysplitPoint;
   1908        yyr = yyp, yyp = yyq, yyq = yyp->yypred)
   1909     yyp->yypred = yyr;
   1910 
   1911   yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
   1912   yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
   1913   yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
   1914   yystackp->yysplitPoint = YY_NULL;
   1915   yystackp->yylastDeleted = YY_NULL;
   1916 
   1917   while (yyr != YY_NULL)
   1918     {
   1919       yystackp->yynextFree->yystate = *yyr;
   1920       yyr = yyr->yypred;
   1921       yystackp->yynextFree->yystate.yypred = &yystackp->yynextFree[-1].yystate;
   1922       yystackp->yytops.yystates[0] = &yystackp->yynextFree->yystate;
   1923       yystackp->yynextFree += 1;
   1924       yystackp->yyspaceLeft -= 1;
   1925     }
   1926 }
   1927 
   1928 static YYRESULTTAG
   1929 yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
   1930                    size_t yyposn]b4_pure_formals[)
   1931 {
   1932   int yyaction;
   1933   const short int* yyconflicts;
   1934   yyRuleNum yyrule;
   1935 
   1936   while (yystackp->yytops.yystates[yyk] != YY_NULL)
   1937     {
   1938       yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
   1939       YYDPRINTF ((stderr, "Stack %lu Entering state %d\n",
   1940                   (unsigned long int) yyk, yystate));
   1941 
   1942       YYASSERT (yystate != YYFINAL);
   1943 
   1944       if (yyisDefaultedState (yystate))
   1945         {
   1946           yyrule = yydefaultAction (yystate);
   1947           if (yyrule == 0)
   1948             {
   1949               YYDPRINTF ((stderr, "Stack %lu dies.\n",
   1950                           (unsigned long int) yyk));
   1951               yymarkStackDeleted (yystackp, yyk);
   1952               return yyok;
   1953             }
   1954           YYCHK (yyglrReduce (yystackp, yyk, yyrule, yyfalse]b4_user_args[));
   1955         }
   1956       else
   1957         {
   1958           yySymbol yytoken;
   1959           yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
   1960           if (yychar == YYEMPTY)
   1961             {
   1962               YYDPRINTF ((stderr, "Reading a token: "));
   1963               yychar = YYLEX;
   1964             }
   1965 
   1966           if (yychar <= YYEOF)
   1967             {
   1968               yychar = yytoken = YYEOF;
   1969               YYDPRINTF ((stderr, "Now at end of input.\n"));
   1970             }
   1971           else
   1972             {
   1973               yytoken = YYTRANSLATE (yychar);
   1974               YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
   1975             }
   1976 
   1977           yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
   1978 
   1979           while (*yyconflicts != 0)
   1980             {
   1981               size_t yynewStack = yysplitStack (yystackp, yyk);
   1982               YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
   1983                           (unsigned long int) yynewStack,
   1984                           (unsigned long int) yyk));
   1985               YYCHK (yyglrReduce (yystackp, yynewStack,
   1986                                   *yyconflicts, yyfalse]b4_user_args[));
   1987               YYCHK (yyprocessOneStack (yystackp, yynewStack,
   1988                                         yyposn]b4_pure_args[));
   1989               yyconflicts += 1;
   1990             }
   1991 
   1992           if (yyisShiftAction (yyaction))
   1993             break;
   1994           else if (yyisErrorAction (yyaction))
   1995             {
   1996               YYDPRINTF ((stderr, "Stack %lu dies.\n",
   1997                           (unsigned long int) yyk));
   1998               yymarkStackDeleted (yystackp, yyk);
   1999               break;
   2000             }
   2001           else
   2002             YYCHK (yyglrReduce (yystackp, yyk, -yyaction,
   2003                                 yyfalse]b4_user_args[));
   2004         }
   2005     }
   2006   return yyok;
   2007 }
   2008 
   2009 /*ARGSUSED*/ static void
   2010 yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
   2011 {
   2012   if (yystackp->yyerrState != 0)
   2013     return;
   2014 #if ! YYERROR_VERBOSE
   2015   yyerror (]b4_lyyerror_args[YY_("syntax error"));
   2016 #else
   2017   {
   2018   yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
   2019   size_t yysize0 = yytnamerr (YY_NULL, yytokenName (yytoken));
   2020   size_t yysize = yysize0;
   2021   yybool yysize_overflow = yyfalse;
   2022   char* yymsg = YY_NULL;
   2023   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
   2024   /* Internationalized format string. */
   2025   const char *yyformat = YY_NULL;
   2026   /* Arguments of yyformat. */
   2027   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
   2028   /* Number of reported tokens (one for the "unexpected", one per
   2029      "expected").  */
   2030   int yycount = 0;
   2031 
   2032   /* There are many possibilities here to consider:
   2033      - If this state is a consistent state with a default action, then
   2034        the only way this function was invoked is if the default action
   2035        is an error action.  In that case, don't check for expected
   2036        tokens because there are none.
   2037      - The only way there can be no lookahead present (in yychar) is if
   2038        this state is a consistent state with a default action.  Thus,
   2039        detecting the absence of a lookahead is sufficient to determine
   2040        that there is no unexpected or expected token to report.  In that
   2041        case, just report a simple "syntax error".
   2042      - Don't assume there isn't a lookahead just because this state is a
   2043        consistent state with a default action.  There might have been a
   2044        previous inconsistent state, consistent state with a non-default
   2045        action, or user semantic action that manipulated yychar.
   2046      - Of course, the expected token list depends on states to have
   2047        correct lookahead information, and it depends on the parser not
   2048        to perform extra reductions after fetching a lookahead from the
   2049        scanner and before detecting a syntax error.  Thus, state merging
   2050        (from LALR or IELR) and default reductions corrupt the expected
   2051        token list.  However, the list is correct for canonical LR with
   2052        one exception: it will still contain any token that will not be
   2053        accepted due to an error action in a later state.
   2054   */
   2055   if (yytoken != YYEMPTY)
   2056     {
   2057       int yyn = yypact[yystackp->yytops.yystates[0]->yylrState];
   2058       yyarg[yycount++] = yytokenName (yytoken);
   2059       if (!yypact_value_is_default (yyn))
   2060         {
   2061           /* Start YYX at -YYN if negative to avoid negative indexes in
   2062              YYCHECK.  In other words, skip the first -YYN actions for this
   2063              state because they are default actions.  */
   2064           int yyxbegin = yyn < 0 ? -yyn : 0;
   2065           /* Stay within bounds of both yycheck and yytname.  */
   2066           int yychecklim = YYLAST - yyn + 1;
   2067           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
   2068           int yyx;
   2069           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
   2070             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
   2071                 && !yytable_value_is_error (yytable[yyx + yyn]))
   2072               {
   2073                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
   2074                   {
   2075                     yycount = 1;
   2076                     yysize = yysize0;
   2077                     break;
   2078                   }
   2079                 yyarg[yycount++] = yytokenName (yyx);
   2080                 {
   2081                   size_t yysz = yysize + yytnamerr (YY_NULL, yytokenName (yyx));
   2082                   yysize_overflow |= yysz < yysize;
   2083                   yysize = yysz;
   2084                 }
   2085               }
   2086         }
   2087     }
   2088 
   2089   switch (yycount)
   2090     {
   2091 #define YYCASE_(N, S)                   \
   2092       case N:                           \
   2093         yyformat = S;                   \
   2094       break
   2095       YYCASE_(0, YY_("syntax error"));
   2096       YYCASE_(1, YY_("syntax error, unexpected %s"));
   2097       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
   2098       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
   2099       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
   2100       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
   2101 #undef YYCASE_
   2102     }
   2103 
   2104   {
   2105     size_t yysz = yysize + strlen (yyformat);
   2106     yysize_overflow |= yysz < yysize;
   2107     yysize = yysz;
   2108   }
   2109 
   2110   if (!yysize_overflow)
   2111     yymsg = (char *) YYMALLOC (yysize);
   2112 
   2113   if (yymsg)
   2114     {
   2115       char *yyp = yymsg;
   2116       int yyi = 0;
   2117       while ((*yyp = *yyformat))
   2118         {
   2119           if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
   2120             {
   2121               yyp += yytnamerr (yyp, yyarg[yyi++]);
   2122               yyformat += 2;
   2123             }
   2124           else
   2125             {
   2126               yyp++;
   2127               yyformat++;
   2128             }
   2129         }
   2130       yyerror (]b4_lyyerror_args[yymsg);
   2131       YYFREE (yymsg);
   2132     }
   2133   else
   2134     {
   2135       yyerror (]b4_lyyerror_args[YY_("syntax error"));
   2136       yyMemoryExhausted (yystackp);
   2137     }
   2138   }
   2139 #endif /* YYERROR_VERBOSE */
   2140   yynerrs += 1;
   2141 }
   2142 
   2143 /* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP,
   2144    yylval, and yylloc are the syntactic category, semantic value, and location
   2145    of the lookahead.  */
   2146 /*ARGSUSED*/ static void
   2147 yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
   2148 {
   2149   size_t yyk;
   2150   int yyj;
   2151 
   2152   if (yystackp->yyerrState == 3)
   2153     /* We just shifted the error token and (perhaps) took some
   2154        reductions.  Skip tokens until we can proceed.  */
   2155     while (YYID (yytrue))
   2156       {
   2157         yySymbol yytoken;
   2158         if (yychar == YYEOF)
   2159           yyFail (yystackp][]b4_lpure_args[, YY_NULL);
   2160         if (yychar != YYEMPTY)
   2161           {]b4_locations_if([[
   2162             /* We throw away the lookahead, but the error range
   2163                of the shifted error token must take it into account.  */
   2164             yyGLRState *yys = yystackp->yytops.yystates[0];
   2165             yyGLRStackItem yyerror_range[3];
   2166             yyerror_range[1].yystate.yyloc = yys->yyloc;
   2167             yyerror_range[2].yystate.yyloc = yylloc;
   2168             YYLLOC_DEFAULT ((yys->yyloc), yyerror_range, 2);]])[
   2169             yytoken = YYTRANSLATE (yychar);
   2170             yydestruct ("Error: discarding",
   2171                         yytoken, &yylval]b4_locuser_args([&yylloc])[);
   2172           }
   2173         YYDPRINTF ((stderr, "Reading a token: "));
   2174         yychar = YYLEX;
   2175         if (yychar <= YYEOF)
   2176           {
   2177             yychar = yytoken = YYEOF;
   2178             YYDPRINTF ((stderr, "Now at end of input.\n"));
   2179           }
   2180         else
   2181           {
   2182             yytoken = YYTRANSLATE (yychar);
   2183             YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
   2184           }
   2185         yyj = yypact[yystackp->yytops.yystates[0]->yylrState];
   2186         if (yypact_value_is_default (yyj))
   2187           return;
   2188         yyj += yytoken;
   2189         if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != yytoken)
   2190           {
   2191             if (yydefact[yystackp->yytops.yystates[0]->yylrState] != 0)
   2192               return;
   2193           }
   2194         else if (! yytable_value_is_error (yytable[yyj]))
   2195           return;
   2196       }
   2197 
   2198   /* Reduce to one stack.  */
   2199   for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
   2200     if (yystackp->yytops.yystates[yyk] != YY_NULL)
   2201       break;
   2202   if (yyk >= yystackp->yytops.yysize)
   2203     yyFail (yystackp][]b4_lpure_args[, YY_NULL);
   2204   for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1)
   2205     yymarkStackDeleted (yystackp, yyk);
   2206   yyremoveDeletes (yystackp);
   2207   yycompressStack (yystackp);
   2208 
   2209   /* Now pop stack until we find a state that shifts the error token.  */
   2210   yystackp->yyerrState = 3;
   2211   while (yystackp->yytops.yystates[0] != YY_NULL)
   2212     {
   2213       yyGLRState *yys = yystackp->yytops.yystates[0];
   2214       yyj = yypact[yys->yylrState];
   2215       if (! yypact_value_is_default (yyj))
   2216         {
   2217           yyj += YYTERROR;
   2218           if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR
   2219               && yyisShiftAction (yytable[yyj]))
   2220             {
   2221               /* Shift the error token.  */]b4_locations_if([[
   2222               /* First adjust its location.*/
   2223               YYLTYPE yyerrloc;
   2224               yystackp->yyerror_range[2].yystate.yyloc = yylloc;
   2225               YYLLOC_DEFAULT (yyerrloc, (yystackp->yyerror_range), 2);]])[
   2226               YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]],
   2227                                &yylval, &yyerrloc);
   2228               yyglrShift (yystackp, 0, yytable[yyj],
   2229                           yys->yyposn, &yylval]b4_locations_if([, &yyerrloc])[);
   2230               yys = yystackp->yytops.yystates[0];
   2231               break;
   2232             }
   2233         }]b4_locations_if([[
   2234       yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
   2235       if (yys->yypred != YY_NULL)
   2236         yydestroyGLRState ("Error: popping", yys]b4_user_args[);
   2237       yystackp->yytops.yystates[0] = yys->yypred;
   2238       yystackp->yynextFree -= 1;
   2239       yystackp->yyspaceLeft += 1;
   2240     }
   2241   if (yystackp->yytops.yystates[0] == YY_NULL)
   2242     yyFail (yystackp][]b4_lpure_args[, YY_NULL);
   2243 }
   2244 
   2245 #define YYCHK1(YYE)                                                          \
   2246   do {                                                                       \
   2247     switch (YYE) {                                                           \
   2248     case yyok:                                                               \
   2249       break;                                                                 \
   2250     case yyabort:                                                            \
   2251       goto yyabortlab;                                                       \
   2252     case yyaccept:                                                           \
   2253       goto yyacceptlab;                                                      \
   2254     case yyerr:                                                              \
   2255       goto yyuser_error;                                                     \
   2256     default:                                                                 \
   2257       goto yybuglab;                                                         \
   2258     }                                                                        \
   2259   } while (YYID (0))
   2260 
   2261 
   2262 /*----------.
   2263 | yyparse.  |
   2264 `----------*/
   2265 
   2266 ]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[
   2267 {
   2268   int yyresult;
   2269   yyGLRStack yystack;
   2270   yyGLRStack* const yystackp = &yystack;
   2271   size_t yyposn;
   2272 
   2273   YYDPRINTF ((stderr, "Starting parse\n"));
   2274 
   2275   yychar = YYEMPTY;
   2276   yylval = yyval_default;]b4_locations_if([
   2277   yylloc = yyloc_default;])[
   2278 ]m4_ifdef([b4_initial_action], [
   2279 b4_dollar_pushdef([yylval], [], [yylloc])dnl
   2280 /* User initialization code.  */
   2281 b4_user_initial_action
   2282 b4_dollar_popdef])[]dnl
   2283 [
   2284   if (! yyinitGLRStack (yystackp, YYINITDEPTH))
   2285     goto yyexhaustedlab;
   2286   switch (YYSETJMP (yystack.yyexception_buffer))
   2287     {
   2288     case 0: break;
   2289     case 1: goto yyabortlab;
   2290     case 2: goto yyexhaustedlab;
   2291     default: goto yybuglab;
   2292     }
   2293   yyglrShift (&yystack, 0, 0, 0, &yylval]b4_locations_if([, &yylloc])[);
   2294   yyposn = 0;
   2295 
   2296   while (YYID (yytrue))
   2297     {
   2298       /* For efficiency, we have two loops, the first of which is
   2299          specialized to deterministic operation (single stack, no
   2300          potential ambiguity).  */
   2301       /* Standard mode */
   2302       while (YYID (yytrue))
   2303         {
   2304           yyRuleNum yyrule;
   2305           int yyaction;
   2306           const short int* yyconflicts;
   2307 
   2308           yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
   2309           YYDPRINTF ((stderr, "Entering state %d\n", yystate));
   2310           if (yystate == YYFINAL)
   2311             goto yyacceptlab;
   2312           if (yyisDefaultedState (yystate))
   2313             {
   2314               yyrule = yydefaultAction (yystate);
   2315               if (yyrule == 0)
   2316                 {
   2317 ]b4_locations_if([[               yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
   2318                   yyreportSyntaxError (&yystack]b4_user_args[);
   2319                   goto yyuser_error;
   2320                 }
   2321               YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue]b4_user_args[));
   2322             }
   2323           else
   2324             {
   2325               yySymbol yytoken;
   2326               if (yychar == YYEMPTY)
   2327                 {
   2328                   YYDPRINTF ((stderr, "Reading a token: "));
   2329                   yychar = YYLEX;
   2330                 }
   2331 
   2332               if (yychar <= YYEOF)
   2333                 {
   2334                   yychar = yytoken = YYEOF;
   2335                   YYDPRINTF ((stderr, "Now at end of input.\n"));
   2336                 }
   2337               else
   2338                 {
   2339                   yytoken = YYTRANSLATE (yychar);
   2340                   YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
   2341                 }
   2342 
   2343               yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
   2344               if (*yyconflicts != 0)
   2345                 break;
   2346               if (yyisShiftAction (yyaction))
   2347                 {
   2348                   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
   2349                   yychar = YYEMPTY;
   2350                   yyposn += 1;
   2351                   yyglrShift (&yystack, 0, yyaction, yyposn, &yylval]b4_locations_if([, &yylloc])[);
   2352                   if (0 < yystack.yyerrState)
   2353                     yystack.yyerrState -= 1;
   2354                 }
   2355               else if (yyisErrorAction (yyaction))
   2356                 {
   2357 ]b4_locations_if([[               yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
   2358                   yyreportSyntaxError (&yystack]b4_user_args[);
   2359                   goto yyuser_error;
   2360                 }
   2361               else
   2362                 YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue]b4_user_args[));
   2363             }
   2364         }
   2365 
   2366       while (YYID (yytrue))
   2367         {
   2368           yySymbol yytoken_to_shift;
   2369           size_t yys;
   2370 
   2371           for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
   2372             yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY;
   2373 
   2374           /* yyprocessOneStack returns one of three things:
   2375 
   2376               - An error flag.  If the caller is yyprocessOneStack, it
   2377                 immediately returns as well.  When the caller is finally
   2378                 yyparse, it jumps to an error label via YYCHK1.
   2379 
   2380               - yyok, but yyprocessOneStack has invoked yymarkStackDeleted
   2381                 (&yystack, yys), which sets the top state of yys to NULL.  Thus,
   2382                 yyparse's following invocation of yyremoveDeletes will remove
   2383                 the stack.
   2384 
   2385               - yyok, when ready to shift a token.
   2386 
   2387              Except in the first case, yyparse will invoke yyremoveDeletes and
   2388              then shift the next token onto all remaining stacks.  This
   2389              synchronization of the shift (that is, after all preceding
   2390              reductions on all stacks) helps prevent double destructor calls
   2391              on yylval in the event of memory exhaustion.  */
   2392 
   2393           for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
   2394             YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn]b4_lpure_args[));
   2395           yyremoveDeletes (&yystack);
   2396           if (yystack.yytops.yysize == 0)
   2397             {
   2398               yyundeleteLastStack (&yystack);
   2399               if (yystack.yytops.yysize == 0)
   2400                 yyFail (&yystack][]b4_lpure_args[, YY_("syntax error"));
   2401               YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
   2402               YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
   2403 ]b4_locations_if([[           yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
   2404               yyreportSyntaxError (&yystack]b4_user_args[);
   2405               goto yyuser_error;
   2406             }
   2407 
   2408           /* If any yyglrShift call fails, it will fail after shifting.  Thus,
   2409              a copy of yylval will already be on stack 0 in the event of a
   2410              failure in the following loop.  Thus, yychar is set to YYEMPTY
   2411              before the loop to make sure the user destructor for yylval isn't
   2412              called twice.  */
   2413           yytoken_to_shift = YYTRANSLATE (yychar);
   2414           yychar = YYEMPTY;
   2415           yyposn += 1;
   2416           for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
   2417             {
   2418               int yyaction;
   2419               const short int* yyconflicts;
   2420               yyStateNum yystate = yystack.yytops.yystates[yys]->yylrState;
   2421               yygetLRActions (yystate, yytoken_to_shift, &yyaction,
   2422                               &yyconflicts);
   2423               /* Note that yyconflicts were handled by yyprocessOneStack.  */
   2424               YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long int) yys));
   2425               YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc);
   2426               yyglrShift (&yystack, yys, yyaction, yyposn,
   2427                           &yylval]b4_locations_if([, &yylloc])[);
   2428               YYDPRINTF ((stderr, "Stack %lu now in state #%d\n",
   2429                           (unsigned long int) yys,
   2430                           yystack.yytops.yystates[yys]->yylrState));
   2431             }
   2432 
   2433           if (yystack.yytops.yysize == 1)
   2434             {
   2435               YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
   2436               YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
   2437               yycompressStack (&yystack);
   2438               break;
   2439             }
   2440         }
   2441       continue;
   2442     yyuser_error:
   2443       yyrecoverSyntaxError (&yystack]b4_user_args[);
   2444       yyposn = yystack.yytops.yystates[0]->yyposn;
   2445     }
   2446 
   2447  yyacceptlab:
   2448   yyresult = 0;
   2449   goto yyreturn;
   2450 
   2451  yybuglab:
   2452   YYASSERT (yyfalse);
   2453   goto yyabortlab;
   2454 
   2455  yyabortlab:
   2456   yyresult = 1;
   2457   goto yyreturn;
   2458 
   2459  yyexhaustedlab:
   2460   yyerror (]b4_lyyerror_args[YY_("memory exhausted"));
   2461   yyresult = 2;
   2462   goto yyreturn;
   2463 
   2464  yyreturn:
   2465   if (yychar != YYEMPTY)
   2466     yydestruct ("Cleanup: discarding lookahead",
   2467                 YYTRANSLATE (yychar), &yylval]b4_locuser_args([&yylloc])[);
   2468 
   2469   /* If the stack is well-formed, pop the stack until it is empty,
   2470      destroying its entries as we go.  But free the stack regardless
   2471      of whether it is well-formed.  */
   2472   if (yystack.yyitems)
   2473     {
   2474       yyGLRState** yystates = yystack.yytops.yystates;
   2475       if (yystates)
   2476         {
   2477           size_t yysize = yystack.yytops.yysize;
   2478           size_t yyk;
   2479           for (yyk = 0; yyk < yysize; yyk += 1)
   2480             if (yystates[yyk])
   2481               {
   2482                 while (yystates[yyk])
   2483                   {
   2484                     yyGLRState *yys = yystates[yyk];
   2485 ]b4_locations_if([[                 yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
   2486 )[                  if (yys->yypred != YY_NULL)
   2487                       yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[);
   2488                     yystates[yyk] = yys->yypred;
   2489                     yystack.yynextFree -= 1;
   2490                     yystack.yyspaceLeft += 1;
   2491                   }
   2492                 break;
   2493               }
   2494         }
   2495       yyfreeGLRStack (&yystack);
   2496     }
   2497 
   2498   /* Make sure YYID is used.  */
   2499   return YYID (yyresult);
   2500 }
   2501 
   2502 /* DEBUGGING ONLY */
   2503 #if ]b4_api_PREFIX[DEBUG
   2504 static void yypstack (yyGLRStack* yystackp, size_t yyk)
   2505   __attribute__ ((__unused__));
   2506 static void yypdumpstack (yyGLRStack* yystackp) __attribute__ ((__unused__));
   2507 
   2508 static void
   2509 yy_yypstack (yyGLRState* yys)
   2510 {
   2511   if (yys->yypred)
   2512     {
   2513       yy_yypstack (yys->yypred);
   2514       YYFPRINTF (stderr, " -> ");
   2515     }
   2516   YYFPRINTF (stderr, "%d@@%lu", yys->yylrState,
   2517              (unsigned long int) yys->yyposn);
   2518 }
   2519 
   2520 static void
   2521 yypstates (yyGLRState* yyst)
   2522 {
   2523   if (yyst == YY_NULL)
   2524     YYFPRINTF (stderr, "<null>");
   2525   else
   2526     yy_yypstack (yyst);
   2527   YYFPRINTF (stderr, "\n");
   2528 }
   2529 
   2530 static void
   2531 yypstack (yyGLRStack* yystackp, size_t yyk)
   2532 {
   2533   yypstates (yystackp->yytops.yystates[yyk]);
   2534 }
   2535 
   2536 #define YYINDEX(YYX)                                                         \
   2537     ((YYX) == YY_NULL ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems)
   2538 
   2539 
   2540 static void
   2541 yypdumpstack (yyGLRStack* yystackp)
   2542 {
   2543   yyGLRStackItem* yyp;
   2544   size_t yyi;
   2545   for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1)
   2546     {
   2547       YYFPRINTF (stderr, "%3lu. ",
   2548                  (unsigned long int) (yyp - yystackp->yyitems));
   2549       if (*(yybool *) yyp)
   2550         {
   2551           YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
   2552                      yyp->yystate.yyresolved, yyp->yystate.yylrState,
   2553                      (unsigned long int) yyp->yystate.yyposn,
   2554                      (long int) YYINDEX (yyp->yystate.yypred));
   2555           if (! yyp->yystate.yyresolved)
   2556             YYFPRINTF (stderr, ", firstVal: %ld",
   2557                        (long int) YYINDEX (yyp->yystate
   2558                                              .yysemantics.yyfirstVal));
   2559         }
   2560       else
   2561         {
   2562           YYFPRINTF (stderr, "Option. rule: %d, state: %ld, next: %ld",
   2563                      yyp->yyoption.yyrule - 1,
   2564                      (long int) YYINDEX (yyp->yyoption.yystate),
   2565                      (long int) YYINDEX (yyp->yyoption.yynext));
   2566         }
   2567       YYFPRINTF (stderr, "\n");
   2568     }
   2569   YYFPRINTF (stderr, "Tops:");
   2570   for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
   2571     YYFPRINTF (stderr, "%lu: %ld; ", (unsigned long int) yyi,
   2572                (long int) YYINDEX (yystackp->yytops.yystates[yyi]));
   2573   YYFPRINTF (stderr, "\n");
   2574 }
   2575 #endif
   2576 ]b4_epilogue[]dnl
   2577 b4_output_end()
   2578 
   2579 # glr.cc produces its own header.
   2580 m4_if(b4_skeleton, ["glr.c"],
   2581 [b4_defines_if(
   2582 [b4_output_begin([b4_spec_defines_file])
   2583 b4_copyright([Skeleton interface for Bison GLR parsers in C],
   2584              [2002-2012])[
   2585 
   2586 ]b4_cpp_guard_open([b4_spec_defines_file])[
   2587 ]b4_shared_declarations[
   2588 ]b4_cpp_guard_close([b4_spec_defines_file])[
   2589 ]b4_output_end()
   2590 ])])
   2591