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