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