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