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