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