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