]> git.saurik.com Git - bison.git/blame - data/glr.c
* data/glr.c (yyuserAction): Fix uninitialized variable that caused
[bison.git] / data / glr.c
CommitLineData
720623af 1m4_divert(-1) -*- C -*-
01241d47 2
fb8135fa 3# GLR skeleton for Bison
010f91c3 4# Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
fb8135fa
AD
5
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
0fb669f9
PE
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19# 02110-1301 USA
fb8135fa 20
66d30cd4
AD
21
22## ---------------- ##
23## Default values. ##
24## ---------------- ##
25
26# Stack parameters.
27m4_define_default([b4_stack_depth_max], [10000])
28m4_define_default([b4_stack_depth_init], [200])
29
2a8d363a
AD
30
31
32## ------------------------ ##
33## Pure/impure interfaces. ##
34## ------------------------ ##
35
36
37# b4_lex_param
38# ------------
21964f43
AD
39# Accumule in b4_lex_param all the yylex arguments.
40# Yes, this is quite ugly...
41m4_define([b4_lex_param],
42m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[yylvalp]]][]dnl
43b4_location_if([, [[YYLTYPE *], [yyllocp]]])])dnl
44m4_ifdef([b4_lex_param], [, ]b4_lex_param)))
45
2a8d363a
AD
46
47# b4_user_formals
48# ---------------
49m4_define([b4_user_formals],
50[m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])])
51
52
93724f13
AD
53# b4_yyerror_args
54# ---------------
55# Arguments passed to yyerror: user args plus yylloc.
56m4_define([b4_yyerror_args],
57[b4_pure_if([b4_location_if([yylocp, ])])dnl
58m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
59
60
61# b4_lyyerror_args
62# ----------------
8dd162d3 63# Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
93724f13
AD
64m4_define([b4_lyyerror_args],
65[b4_pure_if([b4_location_if([yyllocp, ])])dnl
66m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
67
68
2a8d363a
AD
69# b4_pure_args
70# ------------
93724f13 71# Arguments needed by yyerror: user args plus yylloc.
2a8d363a
AD
72m4_define([b4_pure_args],
73[b4_pure_if([b4_location_if([, yylocp])])[]b4_user_args])
74
75
76# b4_pure_formals
77# ---------------
78# Arguments passed to yyerror: user formals plus yyllocp.
79m4_define([b4_pure_formals],
80[b4_pure_if([b4_location_if([, YYLTYPE *yylocp])])[]b4_user_formals])
81
82
83# b4_lpure_args
84# -------------
8dd162d3 85# Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
2a8d363a
AD
86m4_define([b4_lpure_args],
87[b4_pure_if([b4_location_if([, yyllocp])])[]b4_user_args])
0245f82d 88
66d30cd4 89
2a8d363a
AD
90# b4_lpure_formals
91# ----------------
8dd162d3 92# Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
2a8d363a
AD
93m4_define([b4_lpure_formals],
94[b4_pure_if([b4_location_if([YYLTYPE *yyllocp])])[]b4_user_formals])
95
66d30cd4
AD
96
97## ----------------- ##
98## Semantic Values. ##
99## ----------------- ##
100
101
01241d47
PH
102# b4_lhs_value([TYPE])
103# --------------------
104# Expansion of $<TYPE>$.
105m4_define([b4_lhs_value],
bc82c5a5 106[((*yyvalp)[]m4_ifval([$1], [.$1]))])
01241d47
PH
107
108
109# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
110# --------------------------------------
111# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
112# symbols on RHS.
113m4_define([b4_rhs_value],
bc82c5a5 114[(((yyGLRStackItem const *)yyvsp)@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))])
01241d47
PH
115
116
117
118## ----------- ##
119## Locations. ##
120## ----------- ##
121
01241d47
PH
122# b4_lhs_location()
123# -----------------
124# Expansion of @$.
125m4_define([b4_lhs_location],
126[(*yylocp)])
127
128
129# b4_rhs_location(RULE-LENGTH, NUM)
130# ---------------------------------
131# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
132# on RHS.
133m4_define([b4_rhs_location],
bc82c5a5 134[(((yyGLRStackItem const *)yyvsp)@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yyloc)])
01241d47 135
b526ee61
AD
136# We do want M4 expansion after # for CPP macros.
137m4_changecom()
01241d47 138m4_divert(0)dnl
947427ae 139@output @output_parser_name@
010f91c3
PE
140b4_copyright([Skeleton parser for GLR parsing with Bison],
141 [2002, 2003, 2004, 2005])
fb8135fa 142[
01241d47
PH
143/* This is the parser code for GLR (Generalized LR) parser. */
144
2a8d363a
AD
145]b4_identification
146m4_if(b4_prefix[], [yy], [],
c5b95ccf 147[/* Substitute the variable and function names. */
01241d47
PH
148#define yyparse b4_prefix[]parse
149#define yylex b4_prefix[]lex
150#define yyerror b4_prefix[]error
151#define yylval b4_prefix[]lval
152#define yychar b4_prefix[]char
153#define yydebug b4_prefix[]debug
154#define yynerrs b4_prefix[]nerrs
383e69dc 155#define yylloc b4_prefix[]lloc])
01241d47 156
17acead5 157b4_token_defines(b4_tokens)
01241d47 158
17acead5
PE
159/* Copy the first part of user declarations. */
160b4_pre_prologue[
01241d47
PH
161
162/* Enabling traces. */
163#ifndef YYDEBUG
164# define YYDEBUG ]b4_debug[
165#endif
166
167/* Enabling verbose error messages. */
168#ifdef YYERROR_VERBOSE
169# undef YYERROR_VERBOSE
170# define YYERROR_VERBOSE 1
171#else
172# define YYERROR_VERBOSE ]b4_error_verbose[
173#endif
174
fa8c3ebc 175#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
01241d47 176]m4_ifdef([b4_stype],
437c2d80 177[b4_syncline([b4_stype_line], [b4_filename])
fa8c3ebc 178typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE;
996b1c7e 179/* Line __line__ of glr.c. */
947427ae 180b4_syncline([@oline@], [@ofile@])],
fa8c3ebc
PE
181[typedef int YYSTYPE;])[
182# define YYSTYPE_IS_DECLARED 1
01241d47
PH
183# define YYSTYPE_IS_TRIVIAL 1
184#endif
185
fa8c3ebc
PE
186#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
187typedef struct YYLTYPE
01241d47 188{
25005f6a 189]b4_location_if([
f50adbbd
AD
190 int first_line;
191 int first_column;
192 int last_line;
ffa4c58a 193 int last_column;
5cc16ecc
PE
194],[
195 char yydummy;
25005f6a 196])[
fa8c3ebc
PE
197} YYLTYPE;
198# define YYLTYPE_IS_DECLARED 1
01241d47
PH
199# define YYLTYPE_IS_TRIVIAL 1
200#endif
201
288006a2 202/* Default (constant) value used for initialization for null
f6abc26e 203 right-hand sides. Unlike the standard yacc.c template,
288006a2 204 here we set the default value of $$ to a zeroed-out value.
b9b51bf0
PE
205 Since the default value is undefined, this behavior is
206 technically correct. */
01241d47 207static YYSTYPE yyval_default;
01241d47
PH
208
209/* Copy the second part of user declarations. */
210]b4_post_prologue[
211
996b1c7e 212]/* Line __line__ of glr.c. */
947427ae 213b4_syncline([@oline@], [@ofile@])
01241d47 214[
63cb01d6
PE
215#include <stdio.h>
216#include <stdlib.h>
217#include <string.h>
218#include <stdarg.h>
219#include <setjmp.h>
220
a525b568
PE
221#ifndef YYFREE
222# define YYFREE free
223#endif
224#ifndef YYMALLOC
225# define YYMALLOC malloc
226#endif
227#ifndef YYREALLOC
228# define YYREALLOC realloc
229#endif
230
63cb01d6
PE
231#define YYSIZEMAX ((size_t) -1)
232
f7c398aa
PE
233#ifdef __cplusplus
234 typedef bool yybool;
235#else
236 typedef unsigned char yybool;
01241d47 237#endif
f7c398aa
PE
238#define yytrue 1
239#define yyfalse 0
01241d47 240
1154cced
AD
241/*-----------------.
242| GCC extensions. |
243`-----------------*/
244
245#ifndef __attribute__
246/* This feature is available in gcc versions 2.5 and later. */
247# if !defined (__GNUC__) || __GNUC__ < 2 || \
248(__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
249# define __attribute__(Spec) /* empty */
43d3b664
PH
250# else
251]b4_location_if([# define YYOPTIONAL_LOC(Name) Name],[
252# if defined (__cplusplus)
253# define YYOPTIONAL_LOC(Name) /* empty */
254# else
255# define YYOPTIONAL_LOC(Name) Name ATTRIBUTE_UNUSED
256# endif])[
1154cced
AD
257# endif
258#endif
259
64c4fd52
PE
260#ifndef YYASSERT
261# define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
262#endif
263
1154cced
AD
264#ifndef ATTRIBUTE_UNUSED
265# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
266#endif
267
01241d47 268/* YYFINAL -- State number of the termination state. */
7db2ed2d 269#define YYFINAL ]b4_final_state_number[
39912f52 270/* YYLAST -- Last index in YYTABLE. */
01241d47
PH
271#define YYLAST ]b4_last[
272
273/* YYNTOKENS -- Number of terminals. */
7db2ed2d 274#define YYNTOKENS ]b4_tokens_number[
01241d47 275/* YYNNTS -- Number of nonterminals. */
7db2ed2d 276#define YYNNTS ]b4_nterms_number[
01241d47 277/* YYNRULES -- Number of rules. */
7db2ed2d 278#define YYNRULES ]b4_rules_number[
01241d47 279/* YYNRULES -- Number of states. */
7db2ed2d 280#define YYNSTATES ]b4_states_number[
01241d47
PH
281/* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
282#define YYMAXRHS ]b4_r2_max[
25005f6a
PH
283/* YYMAXLEFT -- Maximum number of symbols to the left of a handle
284 accessed by $0, $-1, etc., in any rule. */
285#define YYMAXLEFT ]b4_max_left_semantic_context[
01241d47
PH
286
287/* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
288#define YYUNDEFTOK ]b4_undef_token_number[
289#define YYMAXUTOK ]b4_user_token_number_max[
290
5cc16ecc 291#define YYTRANSLATE(YYX) \
b0400cc6 292 ((YYX <= 0) ? YYEOF : \
779e7ceb 293 (unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
01241d47
PH
294
295/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
a762e609 296static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
01241d47
PH
297{
298 ]b4_translate[
299};
300
301#if YYDEBUG
302/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
303 YYRHS. */
a762e609 304static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
01241d47
PH
305{
306 ]b4_prhs[
307};
308
309/* YYRHS -- A `-1'-separated list of the rules' RHS. */
a762e609 310static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
01241d47
PH
311{
312 ]b4_rhs[
313};
314
315/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
a762e609 316static const ]b4_int_type_for([b4_rline])[ yyrline[] =
01241d47
PH
317{
318 ]b4_rline[
319};
320#endif
321
322#if (YYDEBUG) || YYERROR_VERBOSE
323/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
324 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
325static const char *const yytname[] =
326{
327 ]b4_tname[
328};
01241d47
PH
329#endif
330
331/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
a762e609 332static const ]b4_int_type_for([b4_r1])[ yyr1[] =
01241d47
PH
333{
334 ]b4_r1[
335};
336
337/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
a762e609 338static const ]b4_int_type_for([b4_r2])[ yyr2[] =
01241d47
PH
339{
340 ]b4_r2[
341};
342
343/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
a762e609 344static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
01241d47
PH
345{
346 ]b4_dprec[
347};
348
349/* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
a762e609 350static const ]b4_int_type_for([b4_merger])[ yymerger[] =
01241d47
PH
351{
352 ]b4_merger[
353};
354
355/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
356 doesn't specify something else to do. Zero means the default is an
357 error. */
a762e609 358static const ]b4_int_type_for([b4_defact])[ yydefact[] =
01241d47
PH
359{
360 ]b4_defact[
361};
362
12b0043a 363/* YYPDEFGOTO[NTERM-NUM]. */
a762e609 364static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
01241d47
PH
365{
366 ]b4_defgoto[
367};
368
369/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
370 STATE-NUM. */
12b0043a 371#define YYPACT_NINF ]b4_pact_ninf[
a762e609 372static const ]b4_int_type_for([b4_pact])[ yypact[] =
01241d47
PH
373{
374 ]b4_pact[
375};
376
377/* YYPGOTO[NTERM-NUM]. */
a762e609 378static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
01241d47
PH
379{
380 ]b4_pgoto[
381};
382
383/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
384 positive, shift that token. If negative, reduce the rule which
f50adbbd 385 number is the opposite. If zero, do what YYDEFACT says.
6e649e65 386 If YYTABLE_NINF, syntax error. */
12b0043a 387#define YYTABLE_NINF ]b4_table_ninf[
a762e609 388static const ]b4_int_type_for([b4_table])[ yytable[] =
01241d47
PH
389{
390 ]b4_table[
391};
392
ea99527d
AD
393/* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
394 list of conflicting reductions corresponding to action entry for
395 state STATE-NUM in yytable. 0 means no conflicts. The list in
396 yyconfl is terminated by a rule number of 0. */
a762e609 397static const ]b4_int_type_for([b4_conflict_list_heads])[ yyconflp[] =
01241d47
PH
398{
399 ]b4_conflict_list_heads[
400};
401
ea99527d
AD
402/* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
403 0, pointed into by YYCONFLP. */
a762e609 404]dnl Do not use b4_int_type_for here, since there are places where
779e7ceb 405dnl pointers onto yyconfl are taken, which type is "short int *".
a762e609 406dnl We probably ought to introduce a type for confl.
779e7ceb 407[static const short int yyconfl[] =
01241d47
PH
408{
409 ]b4_conflicting_rules[
410};
411
a762e609 412static const ]b4_int_type_for([b4_check])[ yycheck[] =
01241d47
PH
413{
414 ]b4_check[
415};
416
7bd6c77e
AD
417/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
418 symbol of state STATE-NUM. */
419static const ]b4_int_type_for([b4_stos])[ yystos[] =
420{
421 ]b4_stos[
422};
423
01241d47 424\f
0245f82d 425/* Prevent warning if -Wmissing-prototypes. */
2a8d363a 426]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param)[
e7cb57c0 427
2a8d363a 428/* Error token number */
01241d47
PH
429#define YYTERROR 1
430
b4a20338
AD
431/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
432 If N is 0, then set CURRENT to the empty location which ends
433 the previous symbol: RHS[0] (always defined). */
01241d47 434
25005f6a 435]b4_location_if([[
9fafc4dd 436#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
01241d47 437#ifndef YYLLOC_DEFAULT
9fafc4dd
PE
438# define YYLLOC_DEFAULT(Current, Rhs, N) \
439 do \
440 if (N) \
441 { \
9bec482e
PE
442 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
443 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
444 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
445 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
9fafc4dd
PE
446 } \
447 else \
448 { \
449 (Current).first_line = (Current).last_line = \
9bec482e 450 YYRHSLOC (Rhs, 0).last_line; \
9fafc4dd 451 (Current).first_column = (Current).last_column = \
9bec482e 452 YYRHSLOC (Rhs, 0).last_column; \
9fafc4dd
PE
453 } \
454 while (0)
3fc16193
AD
455
456/* YY_LOCATION_PRINT -- Print the location on the stream.
457 This macro was not mandated originally: define only if we know
458 we won't break user code: when these are the locations we know. */
459
460# define YY_LOCATION_PRINT(File, Loc) \
461 fprintf (File, "%d.%d-%d.%d", \
462 (Loc).first_line, (Loc).first_column, \
463 (Loc).last_line, (Loc).last_column)
25005f6a
PH
464#endif
465]],[
466#ifndef YYLLOC_DEFAULT
9fafc4dd 467# define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)
01241d47 468#endif
25005f6a
PH
469])[
470
3fc16193
AD
471#ifndef YY_LOCATION_PRINT
472# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
473#endif
474
01241d47
PH
475
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
PH
481#undef yynerrs
482#define yynerrs (yystack->yyerrcnt)
483#undef yychar
484#define yychar (yystack->yyrawchar)],
485[YYSTYPE yylval;
486
487YYLTYPE yylloc;
488
489int yynerrs;
490int yychar;])[
491
492static const int YYEOF = 0;
493static const int YYEMPTY = -2;
494
495typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
496
497#define YYCHK(YYE) \
5cc16ecc 498 do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
01241d47
PH
499 while (0)
500
501#if YYDEBUG
502
503#if ! defined (YYFPRINTF)
504# define YYFPRINTF fprintf
505#endif
506
507# define YYDPRINTF(Args) \
508do { \
509 if (yydebug) \
510 YYFPRINTF Args; \
511} while (0)
7bd6c77e
AD
512
513]b4_yysymprint_generate([b4_c_ansi_function_def])[
514
284acc8b 515# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
9c1e26bd
AD
516do { \
517 if (yydebug) \
518 { \
519 YYFPRINTF (stderr, "%s ", Title); \
5cc16ecc 520 yysymprint (stderr, \
284acc8b 521 Type, Value]b4_location_if([, Location])[); \
9c1e26bd
AD
522 } \
523} while (0)
524
01241d47
PH
525/* Nonzero means print parse trace. It is left uninitialized so that
526 multiple parsers can coexist. */
527int yydebug;
7bd6c77e 528
01241d47 529#else /* !YYDEBUG */
7bd6c77e 530
ee16363f 531# define YYDPRINTF(Args)
284acc8b 532# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
7bd6c77e 533
01241d47
PH
534#endif /* !YYDEBUG */
535
536/* YYINITDEPTH -- initial size of the parser's stacks. */
537#ifndef YYINITDEPTH
66d30cd4 538# define YYINITDEPTH ]b4_stack_depth_init[
01241d47
PH
539#endif
540
541/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
542 if the built-in stack extension method is used).
543
544 Do not make this value too large; the results are undefined if
fb8135fa 545 SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
01241d47
PH
546 evaluated with infinite-precision integer arithmetic. */
547
01241d47 548#ifndef YYMAXDEPTH
66d30cd4 549# define YYMAXDEPTH ]b4_stack_depth_max[
01241d47
PH
550#endif
551
552/* Minimum number of free items on the stack allowed after an
fb8135fa 553 allocation. This is to allow allocation and initialization
63cb01d6 554 to be completed by functions that call yyexpandGLRStack before the
fb8135fa 555 stack is expanded, thus insuring that all necessary pointers get
01241d47
PH
556 properly redirected to new data. */
557#define YYHEADROOM 2
558
fa8c3ebc
PE
559#if (! defined (YYSTACKEXPANDABLE) \
560 && (! defined (__cplusplus) \
f5452625
PE
561 || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \
562 && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
01241d47
PH
563#define YYSTACKEXPANDABLE 1
564#else
565#define YYSTACKEXPANDABLE 0
566#endif
567
63cb01d6
PE
568#if YYERROR_VERBOSE
569
570# ifndef yystpcpy
571# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
572# define yystpcpy stpcpy
573# else
574/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
575 YYDEST. */
576static char *
577yystpcpy (char *yydest, const char *yysrc)
578{
579 char *yyd = yydest;
580 const char *yys = yysrc;
581
582 while ((*yyd++ = *yys++) != '\0')
583 continue;
584
585 return yyd - 1;
586}
587# endif
588# endif
589
590#endif /* !YYERROR_VERBOSE */
591
01241d47
PH
592/** State numbers, as in LALR(1) machine */
593typedef int yyStateNum;
594
595/** Rule numbers, as in LALR(1) machine */
596typedef int yyRuleNum;
597
598/** Grammar symbol */
779e7ceb 599typedef short int yySymbol;
01241d47
PH
600
601/** Item references, as in LALR(1) machine */
779e7ceb 602typedef short int yyItemNum;
01241d47
PH
603
604typedef struct yyGLRState yyGLRState;
605typedef struct yySemanticOption yySemanticOption;
606typedef union yyGLRStackItem yyGLRStackItem;
607typedef struct yyGLRStack yyGLRStack;
608typedef struct yyGLRStateSet yyGLRStateSet;
609
610struct yyGLRState {
5e6f62f2 611 /** Type tag: always true. */
f7c398aa 612 yybool yyisState;
5e6f62f2
PH
613 /** Type tag for yysemantics. If true, yysval applies, otherwise
614 * yyfirstVal applies. */
f7c398aa 615 yybool yyresolved;
5e6f62f2 616 /** Number of corresponding LALR(1) machine state. */
01241d47 617 yyStateNum yylrState;
5e6f62f2 618 /** Preceding state in this stack */
01241d47 619 yyGLRState* yypred;
5e6f62f2 620 /** Source position of the first token produced by my symbol */
01241d47
PH
621 size_t yyposn;
622 union {
5e6f62f2 623 /** First in a chain of alternative reductions producing the
010f91c3 624 * non-terminal corresponding to this state, threaded through
5e6f62f2 625 * yynext. */
01241d47 626 yySemanticOption* yyfirstVal;
5e6f62f2 627 /** Semantic value for this state. */
01241d47
PH
628 YYSTYPE yysval;
629 } yysemantics;
5e6f62f2 630 /** Source location for this state. */
01241d47
PH
631 YYLTYPE yyloc;
632};
633
634struct yyGLRStateSet {
635 yyGLRState** yystates;
636 size_t yysize, yycapacity;
637};
638
639struct yySemanticOption {
5e6f62f2 640 /** Type tag: always false. */
f7c398aa 641 yybool yyisState;
5e6f62f2 642 /** Rule number for this reduction */
01241d47 643 yyRuleNum yyrule;
5e6f62f2 644 /** The last RHS state in the list of states to be reduced. */
01241d47 645 yyGLRState* yystate;
5e6f62f2
PH
646 /** Next sibling in chain of options. To facilitate merging,
647 * options are chained in decreasing order by address. */
01241d47
PH
648 yySemanticOption* yynext;
649};
650
010f91c3 651/** Type of the items in the GLR stack. The yyisState field
5e6f62f2 652 * indicates which item of the union is valid. */
01241d47
PH
653union yyGLRStackItem {
654 yyGLRState yystate;
655 yySemanticOption yyoption;
656};
657
658struct yyGLRStack {
659 int yyerrflag;
660 int yyerrState;
63d72da7
PE
661]b4_location_if([[ /* To compute the location of the error token. */
662 yyGLRStackItem yyerror_range[3];]])[
01241d47
PH
663]b4_pure_if(
664[
665 int yyerrcnt;
666 int yyrawchar;
667])[
668 yySymbol* yytokenp;
669 jmp_buf yyexception_buffer;
670 yyGLRStackItem* yyitems;
671 yyGLRStackItem* yynextFree;
63cb01d6 672 size_t yyspaceLeft;
01241d47
PH
673 yyGLRState* yysplitPoint;
674 yyGLRState* yylastDeleted;
675 yyGLRStateSet yytops;
676};
677
2a8d363a 678static void yyexpandGLRStack (yyGLRStack* yystack]b4_pure_formals[);
01241d47
PH
679
680static void
fd2df2ed 681yyFail (yyGLRStack* yystack]b4_pure_formals[, const char* yymsg)
01241d47 682{
970785f1 683 yystack->yyerrflag = 1;
fd2df2ed
PE
684 if (yymsg != NULL)
685 yyerror (]b4_yyerror_args[yymsg);
01241d47
PH
686 longjmp (yystack->yyexception_buffer, 1);
687}
688
63cb01d6
PE
689static void
690yyStackOverflow (yyGLRStack* yystack]b4_pure_formals[)
691{
692 yyFail (yystack]b4_pure_args[, "parser stack overflow");
693}
694
01241d47 695#if YYDEBUG || YYERROR_VERBOSE
63cb01d6 696/** A printable representation of TOKEN. */
fb8135fa
AD
697static inline const char*
698yytokenName (yySymbol yytoken)
01241d47 699{
d0d5aa64
PE
700 if (yytoken == YYEMPTY)
701 return "";
702
01241d47
PH
703 return yytname[yytoken];
704}
705#endif
706
f868dc04
PH
707/** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
708 * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
c4749565 709 * containing the pointer to the next state in the chain. Assumes
6a84279c
PE
710 * YYLOW1 < YYLOW0. */
711static void yyfillin (yyGLRStackItem *, int, int) ATTRIBUTE_UNUSED;
712static void
713yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
f868dc04
PH
714{
715 yyGLRState* s;
716 int i;
c4749565 717 s = yyvsp[yylow0].yystate.yypred;
f868dc04
PH
718 for (i = yylow0-1; i >= yylow1; i -= 1)
719 {
64c4fd52 720 YYASSERT (s->yyresolved);
f868dc04
PH
721 yyvsp[i].yystate.yyresolved = yytrue;
722 yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;
723 yyvsp[i].yystate.yyloc = s->yyloc;
724 s = yyvsp[i].yystate.yypred = s->yypred;
725 }
6a84279c
PE
726}
727
728/* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
729 YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
730 For convenience, always return YYLOW1. */
731static inline int yyfill (yyGLRStackItem *, int *, int, yybool)
732 ATTRIBUTE_UNUSED;
733static inline int
734yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
735{
736 if (!yynormal && yylow1 < *yylow)
737 {
738 yyfillin (yyvsp, *yylow, yylow1);
739 *yylow = yylow1;
740 }
f868dc04
PH
741 return yylow1;
742}
743
01241d47
PH
744/** Perform user action for rule number YYN, with RHS length YYRHSLEN,
745 * and top stack item YYVSP. YYLVALP points to place to put semantic
746 * value ($$), and yylocp points to place for location information
947427ae 747 * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
01241d47
PH
748 * yyerr for YYERROR, yyabort for YYABORT. */
749static YYRESULTTAG
fb8135fa 750yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
80a18357 751 YYSTYPE* yyvalp,
43d3b664 752 YYLTYPE* YYOPTIONAL_LOC (yylocp),
80a18357 753 yyGLRStack* yystack
2a8d363a 754 ]b4_user_formals[)
01241d47 755{
6a84279c 756 yybool yynormal ATTRIBUTE_UNUSED = (yystack->yysplitPoint == NULL);
f868dc04 757 int yylow;
1154cced 758
01241d47
PH
759# undef yyerrok
760# define yyerrok (yystack->yyerrState = 0)
761# undef YYACCEPT
762# define YYACCEPT return yyaccept
763# undef YYABORT
764# define YYABORT return yyabort
765# undef YYERROR
5cc16ecc 766# define YYERROR return yyerrok, yyerr
01241d47
PH
767# undef YYRECOVERING
768# define YYRECOVERING (yystack->yyerrState != 0)
769# undef yyclearin
770# define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)
f868dc04 771# undef YYFILL
6a84279c 772# define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
01241d47
PH
773# undef YYBACKUP
774# define YYBACKUP(Token, Value) \
5cc16ecc
PE
775 return yyerror (]b4_yyerror_args["syntax error: cannot back up"), \
776 yyerrok, yyerr
01241d47 777
25005f6a
PH
778 yylow = 1;
779 if (yyrhslen == 0)
b4a20338 780 *yyvalp = yyval_default;
25005f6a 781 else
b4a20338
AD
782 *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;
783 YYLLOC_DEFAULT (*yylocp, yyvsp - yyrhslen, yyrhslen);
d741bd1b
PE
784]b4_location_if([[ yystack->yyerror_range[1].yystate.yyloc = *yylocp;
785]])
25005f6a
PH
786 switch (yyn)
787 {
788 b4_actions
95f22ad2 789 default: break;
25005f6a 790 }
01241d47 791
25005f6a 792 return yyok;
01241d47
PH
793# undef yyerrok
794# undef YYABORT
795# undef YYACCEPT
796# undef YYERROR
797# undef YYBACKUP
798# undef yyclearin
799# undef YYRECOVERING
996b1c7e 800/* Line __line__ of glr.c. */
947427ae 801b4_syncline([@oline@], [@ofile@])
01241d47
PH
802}
803\f
804
7b98f503 805static void
01241d47
PH
806yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
807{
2a8d363a 808 /* `Use' the arguments. */
1154cced
AD
809 (void) yy0;
810 (void) yy1;
811
fb8135fa 812 switch (yyn)
01241d47
PH
813 {
814 b4_mergers
815 }
01241d47
PH
816}
817[
2a8d363a 818 /* Bison grammar-table manipulation. */
01241d47 819
7bd6c77e
AD
820]b4_yydestruct_generate([b4_c_ansi_function_def])[
821
01241d47
PH
822/** Number of symbols composing the right hand side of rule #RULE. */
823static inline int
fb8135fa 824yyrhsLength (yyRuleNum yyrule)
01241d47
PH
825{
826 return yyr2[yyrule];
827}
828
829/** Left-hand-side symbol for rule #RULE. */
830static inline yySymbol
fb8135fa 831yylhsNonterm (yyRuleNum yyrule)
01241d47
PH
832{
833 return yyr1[yyrule];
834}
835
944ed9f4
PE
836#define yyis_pact_ninf(yystate) \
837 ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), 1,
838 0,
839 ((yystate) == YYPACT_NINF))[
840
01241d47
PH
841/** True iff LR state STATE has only a default reduction (regardless
842 * of token). */
f7c398aa 843static inline yybool
01241d47
PH
844yyisDefaultedState (yyStateNum yystate)
845{
944ed9f4 846 return yyis_pact_ninf (yypact[yystate]);
01241d47 847}
fb8135fa 848
01241d47
PH
849/** The default reduction for STATE, assuming it has one. */
850static inline yyRuleNum
851yydefaultAction (yyStateNum yystate)
852{
853 return yydefact[yystate];
854}
855
df38312a 856#define yyis_table_ninf(yytable_value) \
944ed9f4
PE
857 ]m4_if(m4_eval(b4_table_ninf < b4_table_min), 1,
858 0,
df38312a 859 ((yytable_value) == YYTABLE_NINF))[
944ed9f4 860
2a1fe6ed 861/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
01241d47
PH
862 * Result R means
863 * R < 0: Reduce on rule -R.
864 * R = 0: Error.
fb8135fa
AD
865 * R > 0: Shift to state R.
866 * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
01241d47
PH
867 * conflicting reductions.
868 */
869static inline void
fb8135fa 870yygetLRActions (yyStateNum yystate, int yytoken,
779e7ceb 871 int* yyaction, const short int** yyconflicts)
01241d47
PH
872{
873 int yyindex = yypact[yystate] + yytoken;
f50adbbd 874 if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
01241d47
PH
875 {
876 *yyaction = -yydefact[yystate];
877 *yyconflicts = yyconfl;
878 }
df38312a 879 else if (! yyis_table_ninf (yytable[yyindex]))
01241d47
PH
880 {
881 *yyaction = yytable[yyindex];
882 *yyconflicts = yyconfl + yyconflp[yyindex];
883 }
f50adbbd
AD
884 else
885 {
886 *yyaction = 0;
887 *yyconflicts = yyconfl + yyconflp[yyindex];
888 }
01241d47
PH
889}
890
891static inline yyStateNum
892yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
893{
894 int yyr;
895 yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
f50adbbd 896 if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
01241d47
PH
897 return yytable[yyr];
898 else
899 return yydefgoto[yylhs - YYNTOKENS];
900}
901
f7c398aa 902static inline yybool
fb8135fa 903yyisShiftAction (int yyaction)
01241d47 904{
39912f52 905 return 0 < yyaction;
01241d47
PH
906}
907
f7c398aa 908static inline yybool
fb8135fa 909yyisErrorAction (int yyaction)
01241d47 910{
f50adbbd 911 return yyaction == 0;
01241d47
PH
912}
913
914 /* GLRStates */
915
1154cced
AD
916static void
917yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate,
2a8d363a 918 yyGLRState* rhs, yyRuleNum yyrule]b4_pure_formals[)
01241d47
PH
919{
920 yySemanticOption* yynewItem;
921 yynewItem = &yystack->yynextFree->yyoption;
922 yystack->yyspaceLeft -= 1;
923 yystack->yynextFree += 1;
924 yynewItem->yyisState = yyfalse;
6fed0802 925 yynewItem->yystate = rhs;
fb8135fa 926 yynewItem->yyrule = yyrule;
01241d47
PH
927 yynewItem->yynext = yystate->yysemantics.yyfirstVal;
928 yystate->yysemantics.yyfirstVal = yynewItem;
929 if (yystack->yyspaceLeft < YYHEADROOM)
2a8d363a 930 yyexpandGLRStack (yystack]b4_pure_args[);
01241d47
PH
931}
932
933 /* GLRStacks */
934
935/** Initialize SET to a singleton set containing an empty stack. */
63cb01d6 936static yybool
01241d47
PH
937yyinitStateSet (yyGLRStateSet* yyset)
938{
939 yyset->yysize = 1;
940 yyset->yycapacity = 16;
be16239b 941 yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
63cb01d6
PE
942 if (! yyset->yystates)
943 return yyfalse;
01241d47 944 yyset->yystates[0] = NULL;
63cb01d6 945 return yytrue;
01241d47
PH
946}
947
fb8135fa 948static void yyfreeStateSet (yyGLRStateSet* yyset)
01241d47 949{
a525b568 950 YYFREE (yyset->yystates);
01241d47
PH
951}
952
953/** Initialize STACK to a single empty stack, with total maximum
954 * capacity for all stacks of SIZE. */
63cb01d6 955static yybool
01241d47
PH
956yyinitGLRStack (yyGLRStack* yystack, size_t yysize)
957{
958 yystack->yyerrflag = 0;
959 yystack->yyerrState = 0;
960 yynerrs = 0;
961 yystack->yyspaceLeft = yysize;
fb8135fa 962 yystack->yynextFree = yystack->yyitems =
be16239b 963 (yyGLRStackItem*) YYMALLOC (yysize * sizeof yystack->yynextFree[0]);
01241d47
PH
964 yystack->yysplitPoint = NULL;
965 yystack->yylastDeleted = NULL;
63cb01d6 966 return yyinitStateSet (&yystack->yytops) && yystack->yyitems;
01241d47
PH
967}
968
969#define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
970 &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
971
972/** If STACK is expandable, extend it. WARNING: Pointers into the
973 stack from outside should be considered invalid after this call.
974 We always expand when there are 1 or fewer items left AFTER an
975 allocation, so that we can avoid having external pointers exist
976 across an allocation. */
977static void
2a8d363a 978yyexpandGLRStack (yyGLRStack* yystack]b4_pure_formals[)
01241d47
PH
979{
980#if YYSTACKEXPANDABLE
63cb01d6 981 yyGLRStackItem* yynewItems;
01241d47
PH
982 yyGLRStackItem* yyp0, *yyp1;
983 size_t yysize, yynewSize;
984 size_t yyn;
985 yysize = yystack->yynextFree - yystack->yyitems;
39912f52 986 if (YYMAXDEPTH <= yysize)
63cb01d6 987 yyStackOverflow (yystack]b4_pure_args[);
01241d47 988 yynewSize = 2*yysize;
39912f52 989 if (YYMAXDEPTH < yynewSize)
01241d47 990 yynewSize = YYMAXDEPTH;
63cb01d6
PE
991 yynewItems = (yyGLRStackItem*) YYMALLOC (yynewSize * sizeof yynewItems[0]);
992 if (! yynewItems)
993 yyStackOverflow (yystack]b4_pure_args[);
994 for (yyp0 = yystack->yyitems, yyp1 = yynewItems, yyn = yysize;
39912f52 995 0 < yyn;
fb8135fa 996 yyn -= 1, yyp0 += 1, yyp1 += 1)
01241d47
PH
997 {
998 *yyp1 = *yyp0;
f7c398aa 999 if (*(yybool *) yyp0)
fb8135fa 1000 {
01241d47
PH
1001 yyGLRState* yys0 = &yyp0->yystate;
1002 yyGLRState* yys1 = &yyp1->yystate;
fb8135fa
AD
1003 if (yys0->yypred != NULL)
1004 yys1->yypred =
01241d47
PH
1005 YYRELOC (yyp0, yyp1, yys0->yypred, yystate);
1006 if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != NULL)
fb8135fa 1007 yys1->yysemantics.yyfirstVal =
01241d47
PH
1008 YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption);
1009 }
fb8135fa 1010 else
01241d47
PH
1011 {
1012 yySemanticOption* yyv0 = &yyp0->yyoption;
1013 yySemanticOption* yyv1 = &yyp1->yyoption;
1014 if (yyv0->yystate != NULL)
1015 yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate);
1016 if (yyv0->yynext != NULL)
1017 yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption);
1018 }
1019 }
1020 if (yystack->yysplitPoint != NULL)
63cb01d6 1021 yystack->yysplitPoint = YYRELOC (yystack->yyitems, yynewItems,
01241d47 1022 yystack->yysplitPoint, yystate);
fb8135fa
AD
1023
1024 for (yyn = 0; yyn < yystack->yytops.yysize; yyn += 1)
01241d47 1025 if (yystack->yytops.yystates[yyn] != NULL)
fb8135fa 1026 yystack->yytops.yystates[yyn] =
63cb01d6 1027 YYRELOC (yystack->yyitems, yynewItems,
01241d47 1028 yystack->yytops.yystates[yyn], yystate);
a525b568 1029 YYFREE (yystack->yyitems);
63cb01d6
PE
1030 yystack->yyitems = yynewItems;
1031 yystack->yynextFree = yynewItems + yysize;
1032 yystack->yyspaceLeft = yynewSize - yysize;
01241d47
PH
1033
1034#else
fb8135fa 1035
63cb01d6 1036 yyStackOverflow (yystack]b4_pure_args[);
fb8135fa 1037#endif
01241d47
PH
1038}
1039
1040static void
fb8135fa 1041yyfreeGLRStack (yyGLRStack* yystack)
01241d47 1042{
a525b568 1043 YYFREE (yystack->yyitems);
01241d47
PH
1044 yyfreeStateSet (&yystack->yytops);
1045}
1046
1047/** Assuming that S is a GLRState somewhere on STACK, update the
fb8135fa 1048 * splitpoint of STACK, if needed, so that it is at least as deep as
01241d47
PH
1049 * S. */
1050static inline void
fb8135fa 1051yyupdateSplit (yyGLRStack* yystack, yyGLRState* yys)
01241d47 1052{
fb8135fa 1053 if (yystack->yysplitPoint != NULL && yystack->yysplitPoint > yys)
01241d47
PH
1054 yystack->yysplitPoint = yys;
1055}
1056
1057/** Invalidate stack #K in STACK. */
1058static inline void
63cb01d6 1059yymarkStackDeleted (yyGLRStack* yystack, size_t yyk)
01241d47
PH
1060{
1061 if (yystack->yytops.yystates[yyk] != NULL)
1062 yystack->yylastDeleted = yystack->yytops.yystates[yyk];
1063 yystack->yytops.yystates[yyk] = NULL;
1064}
1065
fb8135fa 1066/** Undelete the last stack that was marked as deleted. Can only be
01241d47
PH
1067 done once after a deletion, and only when all other stacks have
1068 been deleted. */
1069static void
1070yyundeleteLastStack (yyGLRStack* yystack)
1071{
1072 if (yystack->yylastDeleted == NULL || yystack->yytops.yysize != 0)
1073 return;
fb8135fa 1074 yystack->yytops.yystates[0] = yystack->yylastDeleted;
01241d47
PH
1075 yystack->yytops.yysize = 1;
1076 YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
1077 yystack->yylastDeleted = NULL;
1078}
1079
1080static inline void
1081yyremoveDeletes (yyGLRStack* yystack)
1082{
1154cced 1083 size_t yyi, yyj;
01241d47 1084 yyi = yyj = 0;
fb8135fa 1085 while (yyj < yystack->yytops.yysize)
01241d47
PH
1086 {
1087 if (yystack->yytops.yystates[yyi] == NULL)
1088 {
1154cced 1089 if (yyi == yyj)
ee16363f
PE
1090 {
1091 YYDPRINTF ((stderr, "Removing dead stacks.\n"));
1092 }
01241d47
PH
1093 yystack->yytops.yysize -= 1;
1094 }
fb8135fa 1095 else
01241d47
PH
1096 {
1097 yystack->yytops.yystates[yyj] = yystack->yytops.yystates[yyi];
1098 if (yyj != yyi)
ee16363f 1099 {
08fc98e5
PE
1100 YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
1101 (unsigned long int) yyi, (unsigned long int) yyj));
ee16363f 1102 }
01241d47
PH
1103 yyj += 1;
1104 }
1105 yyi += 1;
1106 }
1107}
1108
fb8135fa 1109/** Shift to a new state on stack #K of STACK, corresponding to LR state
01241d47
PH
1110 * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
1111static inline void
63cb01d6
PE
1112yyglrShift (yyGLRStack* yystack, size_t yyk, yyStateNum yylrState,
1113 size_t yyposn,
2a8d363a 1114 YYSTYPE yysval, YYLTYPE* yylocp]b4_user_formals[)
01241d47
PH
1115{
1116 yyGLRStackItem* yynewItem;
1117
1118 yynewItem = yystack->yynextFree;
1119 yystack->yynextFree += 1;
1120 yystack->yyspaceLeft -= 1;
1121 yynewItem->yystate.yyisState = yytrue;
1122 yynewItem->yystate.yylrState = yylrState;
1123 yynewItem->yystate.yyposn = yyposn;
1124 yynewItem->yystate.yyresolved = yytrue;
1125 yynewItem->yystate.yypred = yystack->yytops.yystates[yyk];
1126 yystack->yytops.yystates[yyk] = &yynewItem->yystate;
1127 yynewItem->yystate.yysemantics.yysval = yysval;
1128 yynewItem->yystate.yyloc = *yylocp;
1129 if (yystack->yyspaceLeft < YYHEADROOM)
2a8d363a 1130 yyexpandGLRStack (yystack]b4_pure_args[);
01241d47
PH
1131}
1132
f868dc04 1133/** Shift stack #K of YYSTACK, to a new state corresponding to LR
c4749565 1134 * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
f868dc04 1135 * semantic value of YYRHS under the action for YYRULE. */
01241d47 1136static inline void
63cb01d6 1137yyglrShiftDefer (yyGLRStack* yystack, size_t yyk, yyStateNum yylrState,
2a8d363a 1138 size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule]b4_pure_formals[)
01241d47
PH
1139{
1140 yyGLRStackItem* yynewItem;
1141
1142 yynewItem = yystack->yynextFree;
1143 yynewItem->yystate.yyisState = yytrue;
1144 yynewItem->yystate.yylrState = yylrState;
1145 yynewItem->yystate.yyposn = yyposn;
1146 yynewItem->yystate.yyresolved = yyfalse;
1147 yynewItem->yystate.yypred = yystack->yytops.yystates[yyk];
1148 yynewItem->yystate.yysemantics.yyfirstVal = NULL;
1149 yystack->yytops.yystates[yyk] = &yynewItem->yystate;
1150 yystack->yynextFree += 1;
1151 yystack->yyspaceLeft -= 1;
2a8d363a 1152 yyaddDeferredAction (yystack, &yynewItem->yystate, rhs, yyrule]b4_pure_args[);
01241d47
PH
1153}
1154
1155/** Pop the symbols consumed by reduction #RULE from the top of stack
fb8135fa
AD
1156 * #K of STACK, and perform the appropriate semantic action on their
1157 * semantic values. Assumes that all ambiguities in semantic values
01241d47
PH
1158 * have been previously resolved. Set *VALP to the resulting value,
1159 * and *LOCP to the computed location (if any). Return value is as
1160 * for userAction. */
ff032592 1161static inline YYRESULTTAG
63cb01d6 1162yydoAction (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
5cc16ecc 1163 YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
01241d47
PH
1164{
1165 int yynrhs = yyrhsLength (yyrule);
1166
fb8135fa 1167 if (yystack->yysplitPoint == NULL)
01241d47
PH
1168 {
1169 /* Standard special case: single stack. */
6fed0802 1170 yyGLRStackItem* rhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk];
64c4fd52 1171 YYASSERT (yyk == 0);
01241d47
PH
1172 yystack->yynextFree -= yynrhs;
1173 yystack->yyspaceLeft += yynrhs;
1174 yystack->yytops.yystates[0] = & yystack->yynextFree[-1].yystate;
e7cb57c0 1175 return yyuserAction (yyrule, yynrhs, rhs,
2a8d363a 1176 yyvalp, yylocp, yystack]b4_user_args[);
01241d47 1177 }
fb8135fa 1178 else
01241d47
PH
1179 {
1180 int yyi;
1181 yyGLRState* yys;
25005f6a 1182 yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
5cc16ecc 1183 yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
25005f6a 1184 = yystack->yytops.yystates[yyk];
f868dc04 1185 for (yyi = 0; yyi < yynrhs; yyi += 1)
01241d47 1186 {
f868dc04 1187 yys = yys->yypred;
64c4fd52 1188 YYASSERT (yys);
01241d47
PH
1189 }
1190 yyupdateSplit (yystack, yys);
1191 yystack->yytops.yystates[yyk] = yys;
25005f6a 1192 return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
2a8d363a 1193 yyvalp, yylocp, yystack]b4_user_args[);
01241d47
PH
1194 }
1195}
1196
e7cb57c0
AD
1197#if !YYDEBUG
1198# define YY_REDUCE_PRINT(K, Rule)
1199#else
1200# define YY_REDUCE_PRINT(K, Rule) \
1201do { \
1202 if (yydebug) \
1203 yy_reduce_print (K, Rule); \
1204} while (0)
1205
1206/*----------------------------------------------------------.
1207| Report that the RULE is going to be reduced on stack #K. |
1208`----------------------------------------------------------*/
1209
1210static inline void
1211yy_reduce_print (size_t yyk, yyRuleNum yyrule)
1212{
1213 int yyi;
08fc98e5
PE
1214 YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu), ",
1215 (unsigned long int) yyk, yyrule - 1,
1216 (unsigned long int) yyrline[yyrule]);
e7cb57c0
AD
1217 /* Print the symbols being reduced, and their result. */
1218 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
1219 YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi]));
9c1e26bd 1220 YYFPRINTF (stderr, "-> %s\n", yytokenName (yyr1[yyrule]));
e7cb57c0
AD
1221}
1222#endif
1223
01241d47
PH
1224/** Pop items off stack #K of STACK according to grammar rule RULE,
1225 * and push back on the resulting nonterminal symbol. Perform the
fb8135fa 1226 * semantic action associated with RULE and store its value with the
01241d47
PH
1227 * newly pushed state, if FORCEEVAL or if STACK is currently
1228 * unambiguous. Otherwise, store the deferred semantic action with
1229 * the new state. If the new state would have an identical input
1230 * position, LR state, and predecessor to an existing state on the stack,
fb8135fa
AD
1231 * it is identified with that existing state, eliminating stack #K from
1232 * the STACK. In this case, the (necessarily deferred) semantic value is
1233 * added to the options for the existing state's semantic value.
01241d47
PH
1234 */
1235static inline YYRESULTTAG
1154cced 1236yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
f7c398aa 1237 yybool yyforceEval]b4_pure_formals[)
01241d47 1238{
1154cced 1239 size_t yyposn = yystack->yytops.yystates[yyk]->yyposn;
01241d47 1240
fb8135fa 1241 if (yyforceEval || yystack->yysplitPoint == NULL)
01241d47
PH
1242 {
1243 YYSTYPE yysval;
1244 YYLTYPE yyloc;
fb8135fa 1245
e7cb57c0 1246 YY_REDUCE_PRINT (yyk, yyrule);
2a8d363a 1247 YYCHK (yydoAction (yystack, yyk, yyrule, &yysval, &yyloc]b4_user_args[));
fb8135fa
AD
1248 yyglrShift (yystack, yyk,
1249 yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState,
01241d47 1250 yylhsNonterm (yyrule)),
2a8d363a 1251 yyposn, yysval, &yyloc]b4_user_args[);
01241d47 1252 }
fb8135fa 1253 else
01241d47 1254 {
1154cced
AD
1255 size_t yyi;
1256 int yyn;
01241d47
PH
1257 yyGLRState* yys, *yys0 = yystack->yytops.yystates[yyk];
1258 yyStateNum yynewLRState;
1259
fb8135fa 1260 for (yys = yystack->yytops.yystates[yyk], yyn = yyrhsLength (yyrule);
39912f52 1261 0 < yyn; yyn -= 1)
01241d47
PH
1262 {
1263 yys = yys->yypred;
64c4fd52 1264 YYASSERT (yys);
01241d47
PH
1265 }
1266 yyupdateSplit (yystack, yys);
1267 yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
fb8135fa 1268 YYDPRINTF ((stderr,
dfc8a220 1269 "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
08fc98e5 1270 (unsigned long int) yyk, yyrule - 1, yynewLRState));
01241d47 1271 for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1)
fb8135fa 1272 if (yyi != yyk && yystack->yytops.yystates[yyi] != NULL)
01241d47
PH
1273 {
1274 yyGLRState* yyp, *yysplit = yystack->yysplitPoint;
1275 yyp = yystack->yytops.yystates[yyi];
fb8135fa 1276 while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn)
01241d47 1277 {
fb8135fa 1278 if (yyp->yylrState == yynewLRState && yyp->yypred == yys)
01241d47 1279 {
2a8d363a 1280 yyaddDeferredAction (yystack, yyp, yys0, yyrule]b4_pure_args[);
01241d47 1281 yymarkStackDeleted (yystack, yyk);
08fc98e5
PE
1282 YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n",
1283 (unsigned long int) yyk,
1284 (unsigned long int) yyi));
ff032592 1285 return yyok;
01241d47
PH
1286 }
1287 yyp = yyp->yypred;
1288 }
1289 }
1290 yystack->yytops.yystates[yyk] = yys;
2a8d363a 1291 yyglrShiftDefer (yystack, yyk, yynewLRState, yyposn, yys0, yyrule]b4_pure_args[);
fb8135fa 1292 }
ff032592 1293 return yyok;
01241d47
PH
1294}
1295
63cb01d6
PE
1296static size_t
1297yysplitStack (yyGLRStack* yystack, size_t yyk]b4_pure_formals[)
01241d47 1298{
fb8135fa 1299 if (yystack->yysplitPoint == NULL)
01241d47 1300 {
64c4fd52 1301 YYASSERT (yyk == 0);
01241d47
PH
1302 yystack->yysplitPoint = yystack->yytops.yystates[yyk];
1303 }
fb8135fa 1304 if (yystack->yytops.yysize >= yystack->yytops.yycapacity)
01241d47 1305 {
63cb01d6
PE
1306 yyGLRState** yynewStates;
1307 if (! ((yystack->yytops.yycapacity
1308 <= (YYSIZEMAX / (2 * sizeof yynewStates[0])))
1309 && (yynewStates =
1310 (yyGLRState**) YYREALLOC (yystack->yytops.yystates,
1311 ((yystack->yytops.yycapacity *= 2)
1312 * sizeof yynewStates[0])))))
1313 yyStackOverflow (yystack]b4_pure_args[);
1314 yystack->yytops.yystates = yynewStates;
01241d47 1315 }
fb8135fa 1316 yystack->yytops.yystates[yystack->yytops.yysize]
01241d47
PH
1317 = yystack->yytops.yystates[yyk];
1318 yystack->yytops.yysize += 1;
1319 return yystack->yytops.yysize-1;
1320}
1321
1322/** True iff Y0 and Y1 represent identical options at the top level.
1323 * That is, they represent the same rule applied to RHS symbols
1324 * that produce the same terminal symbols. */
f7c398aa 1325static yybool
01241d47
PH
1326yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
1327{
fb8135fa 1328 if (yyy0->yyrule == yyy1->yyrule)
01241d47
PH
1329 {
1330 yyGLRState *yys0, *yys1;
1331 int yyn;
fb8135fa 1332 for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
01241d47
PH
1333 yyn = yyrhsLength (yyy0->yyrule);
1334 yyn > 0;
1335 yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
1336 if (yys0->yyposn != yys1->yyposn)
1337 return yyfalse;
1338 return yytrue;
1339 }
1340 else
1341 return yyfalse;
1342}
1343
5e6f62f2
PH
1344/** Assuming identicalOptions (Y0,Y1), destructively merge the
1345 * alternative semantic values for the RHS-symbols of Y1 and Y0. */
01241d47
PH
1346static void
1347yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
1348{
1349 yyGLRState *yys0, *yys1;
1350 int yyn;
fb8135fa 1351 for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
01241d47
PH
1352 yyn = yyrhsLength (yyy0->yyrule);
1353 yyn > 0;
1354 yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
5e6f62f2
PH
1355 {
1356 if (yys0 == yys1)
1357 break;
010f91c3 1358 else if (yys0->yyresolved)
5e6f62f2
PH
1359 {
1360 yys1->yyresolved = yytrue;
1361 yys1->yysemantics.yysval = yys0->yysemantics.yysval;
1362 }
1363 else if (yys1->yyresolved)
1364 {
1365 yys0->yyresolved = yytrue;
1366 yys0->yysemantics.yysval = yys1->yysemantics.yysval;
1367 }
010f91c3 1368 else
5e6f62f2
PH
1369 {
1370 yySemanticOption** yyz0p;
1371 yySemanticOption* yyz1;
1372 yyz0p = &yys0->yysemantics.yyfirstVal;
1373 yyz1 = yys1->yysemantics.yyfirstVal;
1374 while (yytrue)
1375 {
1376 if (yyz1 == *yyz0p || yyz1 == NULL)
1377 break;
1378 else if (*yyz0p == NULL)
1379 {
1380 *yyz0p = yyz1;
1381 break;
1382 }
1383 else if (*yyz0p < yyz1)
1384 {
1385 yySemanticOption* yyz = *yyz0p;
1386 *yyz0p = yyz1;
1387 yyz1 = yyz1->yynext;
1388 (*yyz0p)->yynext = yyz;
1389 }
1390 yyz0p = &(*yyz0p)->yynext;
1391 }
1392 yys1->yysemantics.yyfirstVal = yys0->yysemantics.yyfirstVal;
1393 }
1394 }
01241d47
PH
1395}
1396
1397/** Y0 and Y1 represent two possible actions to take in a given
1398 * parsing state; return 0 if no combination is possible,
1399 * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
1400static int
1154cced 1401yypreference (yySemanticOption* y0, yySemanticOption* y1)
01241d47 1402{
1154cced
AD
1403 yyRuleNum r0 = y0->yyrule, r1 = y1->yyrule;
1404 int p0 = yydprec[r0], p1 = yydprec[r1];
01241d47 1405
1154cced 1406 if (p0 == p1)
01241d47 1407 {
1154cced 1408 if (yymerger[r0] == 0 || yymerger[r0] != yymerger[r1])
01241d47
PH
1409 return 0;
1410 else
1411 return 1;
1412 }
1154cced 1413 if (p0 == 0 || p1 == 0)
01241d47 1414 return 0;
1154cced 1415 if (p0 < p1)
01241d47 1416 return 3;
39912f52 1417 if (p1 < p0)
01241d47
PH
1418 return 2;
1419 return 0;
1420}
1421
fb8135fa
AD
1422static YYRESULTTAG yyresolveValue (yySemanticOption* yyoptionList,
1423 yyGLRStack* yystack, YYSTYPE* yyvalp,
2a8d363a 1424 YYLTYPE* yylocp]b4_user_formals[);
01241d47
PH
1425
1426static YYRESULTTAG
2a8d363a 1427yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack]b4_user_formals[)
01241d47
PH
1428{
1429 YYRESULTTAG yyflag;
39912f52 1430 if (0 < yyn)
01241d47 1431 {
64c4fd52 1432 YYASSERT (yys->yypred);
2a8d363a 1433 yyflag = yyresolveStates (yys->yypred, yyn-1, yystack]b4_user_args[);
01241d47
PH
1434 if (yyflag != yyok)
1435 return yyflag;
fb8135fa 1436 if (! yys->yyresolved)
01241d47
PH
1437 {
1438 yyflag = yyresolveValue (yys->yysemantics.yyfirstVal, yystack,
e7cb57c0 1439 &yys->yysemantics.yysval, &yys->yyloc
2a8d363a 1440 ]b4_user_args[);
01241d47
PH
1441 if (yyflag != yyok)
1442 return yyflag;
1443 yys->yyresolved = yytrue;
1444 }
1445 }
1446 return yyok;
1447}
1448
1449static YYRESULTTAG
fb8135fa 1450yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack,
2a8d363a 1451 YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
01241d47 1452{
25005f6a 1453 yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
f868dc04 1454 int yynrhs;
01241d47
PH
1455
1456 yynrhs = yyrhsLength (yyopt->yyrule);
2a8d363a 1457 YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack]b4_user_args[));
25005f6a 1458 yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;
5cc16ecc 1459 return yyuserAction (yyopt->yyrule, yynrhs,
25005f6a 1460 yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
2a8d363a 1461 yyvalp, yylocp, yystack]b4_user_args[);
01241d47
PH
1462}
1463
1464#if YYDEBUG
e7cb57c0
AD
1465static void
1466yyreportTree (yySemanticOption* yyx, int yyindent)
01241d47
PH
1467{
1468 int yynrhs = yyrhsLength (yyx->yyrule);
1469 int yyi;
1470 yyGLRState* yys;
1471 yyGLRState* yystates[YYMAXRHS];
782a05f9 1472 yyGLRState yyleftmost_state;
01241d47 1473
39912f52 1474 for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred)
01241d47
PH
1475 yystates[yyi] = yys;
1476 if (yys == NULL)
782a05f9
PE
1477 {
1478 yyleftmost_state.yyposn = 0;
1479 yystates[0] = &yyleftmost_state;
1480 }
01241d47
PH
1481 else
1482 yystates[0] = yys;
1483
39912f52 1484 if (yyx->yystate->yyposn < yys->yyposn + 1)
01241d47 1485 YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n",
fb8135fa 1486 yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
01241d47
PH
1487 yyx->yyrule);
1488 else
08fc98e5 1489 YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
01241d47 1490 yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
08fc98e5
PE
1491 yyx->yyrule, (unsigned long int) (yys->yyposn + 1),
1492 (unsigned long int) yyx->yystate->yyposn);
fb8135fa 1493 for (yyi = 1; yyi <= yynrhs; yyi += 1)
01241d47 1494 {
fb8135fa 1495 if (yystates[yyi]->yyresolved)
01241d47
PH
1496 {
1497 if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
1498 YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
1499 yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]));
1500 else
08fc98e5 1501 YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
01241d47 1502 yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]),
08fc98e5
PE
1503 (unsigned long int) (yystates[yyi - 1]->yyposn + 1),
1504 (unsigned long int) yystates[yyi]->yyposn);
01241d47 1505 }
fb8135fa 1506 else
01241d47
PH
1507 yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
1508 }
1509}
fb8135fa 1510#endif
01241d47
PH
1511
1512static void
1513yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,
2a8d363a 1514 yyGLRStack* yystack]b4_pure_formals[)
01241d47 1515{
1154cced
AD
1516 /* `Unused' warnings. */
1517 (void) yyx0;
1518 (void) yyx1;
1519
01241d47
PH
1520#if YYDEBUG
1521 YYFPRINTF (stderr, "Ambiguity detected.\n");
1522 YYFPRINTF (stderr, "Option 1,\n");
1523 yyreportTree (yyx0, 2);
1524 YYFPRINTF (stderr, "\nOption 2,\n");
1525 yyreportTree (yyx1, 2);
1526 YYFPRINTF (stderr, "\n");
1527#endif
2a8d363a 1528 yyFail (yystack][]b4_pure_args[, "ambiguity detected");
01241d47
PH
1529}
1530
1531
1532/** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
1533 * actions, and return the result. */
1534static YYRESULTTAG
fb8135fa 1535yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack,
2a8d363a 1536 YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
01241d47
PH
1537{
1538 yySemanticOption* yybest;
1539 yySemanticOption* yyp;
63cb01d6 1540 yybool yymerge;
01241d47 1541
fb8135fa 1542 yybest = yyoptionList;
63cb01d6 1543 yymerge = yyfalse;
fb8135fa 1544 for (yyp = yyoptionList->yynext; yyp != NULL; yyp = yyp->yynext)
01241d47
PH
1545 {
1546 if (yyidenticalOptions (yybest, yyp))
1547 yymergeOptionSets (yybest, yyp);
1548 else
fb8135fa 1549 switch (yypreference (yybest, yyp))
01241d47
PH
1550 {
1551 case 0:
2a8d363a 1552 yyreportAmbiguity (yybest, yyp, yystack]b4_pure_args[);
01241d47
PH
1553 break;
1554 case 1:
63cb01d6 1555 yymerge = yytrue;
01241d47
PH
1556 break;
1557 case 2:
1558 break;
1559 case 3:
1560 yybest = yyp;
63cb01d6 1561 yymerge = yyfalse;
01241d47
PH
1562 break;
1563 }
1564 }
1565
fb8135fa 1566 if (yymerge)
01241d47
PH
1567 {
1568 int yyprec = yydprec[yybest->yyrule];
2a8d363a 1569 YYCHK (yyresolveAction (yybest, yystack, yyvalp, yylocp]b4_user_args[));
fb8135fa 1570 for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext)
01241d47 1571 {
fb8135fa 1572 if (yyprec == yydprec[yyp->yyrule])
01241d47
PH
1573 {
1574 YYSTYPE yyval1;
1575 YYLTYPE yydummy;
2a8d363a 1576 YYCHK (yyresolveAction (yyp, yystack, &yyval1, &yydummy]b4_user_args[));
7b98f503 1577 yyuserMerge (yymerger[yyp->yyrule], yyvalp, &yyval1);
01241d47
PH
1578 }
1579 }
1580 return yyok;
1581 }
1582 else
2a8d363a 1583 return yyresolveAction (yybest, yystack, yyvalp, yylocp]b4_user_args[);
01241d47
PH
1584}
1585
1586static YYRESULTTAG
2a8d363a 1587yyresolveStack (yyGLRStack* yystack]b4_user_formals[)
01241d47 1588{
fb8135fa 1589 if (yystack->yysplitPoint != NULL)
01241d47
PH
1590 {
1591 yyGLRState* yys;
1592 int yyn;
1593
fb8135fa
AD
1594 for (yyn = 0, yys = yystack->yytops.yystates[0];
1595 yys != yystack->yysplitPoint;
01241d47 1596 yys = yys->yypred, yyn += 1)
ee16363f 1597 continue;
e7cb57c0 1598 YYCHK (yyresolveStates (yystack->yytops.yystates[0], yyn, yystack
2a8d363a 1599 ]b4_user_args[));
01241d47
PH
1600 }
1601 return yyok;
1602}
1603
1604static void
fb8135fa 1605yycompressStack (yyGLRStack* yystack)
01241d47
PH
1606{
1607 yyGLRState* yyp, *yyq, *yyr;
1608
1609 if (yystack->yytops.yysize != 1 || yystack->yysplitPoint == NULL)
1610 return;
1611
fb8135fa
AD
1612 for (yyp = yystack->yytops.yystates[0], yyq = yyp->yypred, yyr = NULL;
1613 yyp != yystack->yysplitPoint;
01241d47
PH
1614 yyr = yyp, yyp = yyq, yyq = yyp->yypred)
1615 yyp->yypred = yyr;
fb8135fa 1616
01241d47
PH
1617 yystack->yyspaceLeft += yystack->yynextFree - yystack->yyitems;
1618 yystack->yynextFree = ((yyGLRStackItem*) yystack->yysplitPoint) + 1;
1619 yystack->yyspaceLeft -= yystack->yynextFree - yystack->yyitems;
1620 yystack->yysplitPoint = NULL;
1621 yystack->yylastDeleted = NULL;
fb8135fa
AD
1622
1623 while (yyr != NULL)
1624 {
01241d47
PH
1625 yystack->yynextFree->yystate = *yyr;
1626 yyr = yyr->yypred;
1627 yystack->yynextFree->yystate.yypred = & yystack->yynextFree[-1].yystate;
1628 yystack->yytops.yystates[0] = &yystack->yynextFree->yystate;
1629 yystack->yynextFree += 1;
1630 yystack->yyspaceLeft -= 1;
1631 }
1632}
1633
1634static YYRESULTTAG
63cb01d6 1635yyprocessOneStack (yyGLRStack* yystack, size_t yyk,
e7cb57c0 1636 size_t yyposn, YYSTYPE* yylvalp, YYLTYPE* yyllocp
63cb01d6 1637 ]b4_pure_formals[)
01241d47
PH
1638{
1639 int yyaction;
779e7ceb 1640 const short int* yyconflicts;
01241d47
PH
1641 yyRuleNum yyrule;
1642 yySymbol* const yytokenp = yystack->yytokenp;
1643
fb8135fa 1644 while (yystack->yytops.yystates[yyk] != NULL)
01241d47
PH
1645 {
1646 yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState;
63cb01d6
PE
1647 YYDPRINTF ((stderr, "Stack %lu Entering state %d\n",
1648 (unsigned long int) yyk, yystate));
01241d47 1649
64c4fd52
PE
1650 YYASSERT (yystate != YYFINAL);
1651
fb8135fa 1652 if (yyisDefaultedState (yystate))
01241d47
PH
1653 {
1654 yyrule = yydefaultAction (yystate);
fb8135fa 1655 if (yyrule == 0)
01241d47 1656 {
63cb01d6
PE
1657 YYDPRINTF ((stderr, "Stack %lu dies.\n",
1658 (unsigned long int) yyk));
01241d47
PH
1659 yymarkStackDeleted (yystack, yyk);
1660 return yyok;
1661 }
2a8d363a 1662 YYCHK (yyglrReduce (yystack, yyk, yyrule, yyfalse]b4_lpure_args[));
01241d47 1663 }
fb8135fa 1664 else
01241d47 1665 {
fb8135fa 1666 if (*yytokenp == YYEMPTY)
01241d47 1667 {
2a1fe6ed 1668 YYDPRINTF ((stderr, "Reading a token: "));
01241d47 1669 yychar = YYLEX;
b0400cc6 1670 *yytokenp = YYTRANSLATE (yychar);
284acc8b 1671 YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp);
5e6f62f2 1672 YYDPRINTF ((stderr, "\n"));
01241d47
PH
1673 }
1674 yygetLRActions (yystate, *yytokenp, &yyaction, &yyconflicts);
1675
fb8135fa 1676 while (*yyconflicts != 0)
01241d47 1677 {
63cb01d6
PE
1678 size_t yynewStack = yysplitStack (yystack, yyk]b4_pure_args[);
1679 YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
1680 (unsigned long int) yynewStack,
1681 (unsigned long int) yyk));
e7cb57c0 1682 YYCHK (yyglrReduce (yystack, yynewStack,
2a8d363a 1683 *yyconflicts, yyfalse]b4_lpure_args[));
fb8135fa 1684 YYCHK (yyprocessOneStack (yystack, yynewStack, yyposn,
63cb01d6 1685 yylvalp, yyllocp]b4_pure_args[));
01241d47
PH
1686 yyconflicts += 1;
1687 }
fb8135fa
AD
1688
1689 if (yyisShiftAction (yyaction))
01241d47 1690 {
63cb01d6 1691 YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long int) yyk));
3fc16193 1692 YY_SYMBOL_PRINT ("shifting", *yytokenp, yylvalp, yyllocp);
2a8d363a
AD
1693 yyglrShift (yystack, yyk, yyaction, yyposn+1,
1694 *yylvalp, yyllocp]b4_user_args[);
1576d44d 1695 YYDPRINTF ((stderr, ", now in state #%d\n",
01241d47
PH
1696 yystack->yytops.yystates[yyk]->yylrState));
1697 break;
1698 }
fb8135fa 1699 else if (yyisErrorAction (yyaction))
01241d47 1700 {
63cb01d6
PE
1701 YYDPRINTF ((stderr, "Stack %lu dies.\n",
1702 (unsigned long int) yyk));
01241d47
PH
1703 yymarkStackDeleted (yystack, yyk);
1704 break;
1705 }
1706 else
2a8d363a 1707 YYCHK (yyglrReduce (yystack, yyk, -yyaction, yyfalse]b4_lpure_args[));
01241d47
PH
1708 }
1709 }
1710 return yyok;
1711}
1712
1713static void
ee16363f
PE
1714yyreportSyntaxError (yyGLRStack* yystack,
1715 YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[)
01241d47 1716{
1154cced
AD
1717 /* `Unused' warnings. */
1718 (void) yylvalp;
1719 (void) yyllocp;
01241d47
PH
1720
1721 if (yystack->yyerrState == 0)
1722 {
fb8135fa 1723#if YYERROR_VERBOSE
1154cced 1724 yySymbol* const yytokenp = yystack->yytokenp;
93a0df69 1725 int yyn;
01241d47 1726 yyn = yypact[yystack->yytops.yystates[0]->yylrState];
12b0043a 1727 if (YYPACT_NINF < yyn && yyn < YYLAST)
01241d47 1728 {
63cb01d6
PE
1729 size_t yysize0 = strlen (yytokenName (*yytokenp));
1730 size_t yysize = yysize0;
1731 size_t yysize1;
1732 yybool yysize_overflow = yyfalse;
1733 char* yymsg = NULL;
1734 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1735 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
93a0df69 1736 int yyx;
63cb01d6
PE
1737 char *yyfmt;
1738 char const *yyf;
1739 static char const yyunexpected[] = "syntax error, unexpected %s";
1740 static char const yyexpecting[] = ", expecting %s";
1741 static char const yyor[] = " or %s";
1742 char yyformat[sizeof yyunexpected
1743 + sizeof yyexpecting - 1
1744 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1745 * (sizeof yyor - 1))];
1746 char const *yyprefix = yyexpecting;
93a0df69 1747
01241d47
PH
1748 /* Start YYX at -YYN if negative to avoid negative indexes in
1749 YYCHECK. */
c4749565 1750 int yyxbegin = yyn < 0 ? -yyn : 0;
93a0df69
PE
1751
1752 /* Stay within bounds of both yycheck and yytname. */
1753 int yychecklim = YYLAST - yyn;
c4749565 1754 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
63cb01d6
PE
1755 int yycount = 1;
1756
1757 yyarg[0] = yytokenName (*yytokenp);
1758 yyfmt = yystpcpy (yyformat, yyunexpected);
93a0df69 1759
c4749565 1760 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
217598da 1761 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
93a0df69 1762 {
63cb01d6 1763 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
01241d47 1764 {
63cb01d6
PE
1765 yycount = 1;
1766 yysize = yysize0;
1767 yyformat[sizeof yyunexpected - 1] = '\0';
93a0df69 1768 break;
01241d47 1769 }
63cb01d6
PE
1770 yyarg[yycount++] = yytokenName (yyx);
1771 yysize1 = yysize + strlen (yytokenName (yyx));
1772 yysize_overflow |= yysize1 < yysize;
1773 yysize = yysize1;
1774 yyfmt = yystpcpy (yyfmt, yyprefix);
1775 yyprefix = yyor;
93a0df69 1776 }
63cb01d6
PE
1777
1778 yyf = yyformat;
1779 yysize1 = yysize + (yyfmt - yyformat);
1780 yysize_overflow |= yysize1 < yysize;
1781 yysize = yysize1;
1782
1783 if (!yysize_overflow)
1784 yymsg = (char *) YYMALLOC (yysize);
1785
1786 if (yymsg)
93a0df69 1787 {
63cb01d6
PE
1788 char *yyp = yymsg;
1789 int yyi = 0;
1790 while ((*yyp = *yyf))
93a0df69 1791 {
63cb01d6
PE
1792 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1793 {
1794 yyp = yystpcpy (yyp, yyarg[yyi++]);
1795 yyf += 2;
1796 }
1797 else
1798 {
1799 yyp++;
1800 yyf++;
1801 }
93a0df69
PE
1802 }
1803 yyerror (]b4_lyyerror_args[yymsg);
a525b568 1804 YYFREE (yymsg);
01241d47 1805 }
93a0df69
PE
1806 else
1807 yyerror (]b4_lyyerror_args["syntax error; also virtual memory exhausted");
01241d47
PH
1808 }
1809 else
93a0df69 1810#endif /* YYERROR_VERBOSE */
6e649e65 1811 yyerror (]b4_lyyerror_args["syntax error");
01241d47
PH
1812 yynerrs += 1;
1813 }
1814}
1815
f50adbbd 1816/* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
01241d47 1817 YYLVALP, and YYLLOCP point to the syntactic category, semantic
8dd162d3 1818 value, and location of the look-ahead. */
fb8135fa 1819static void
ee16363f 1820yyrecoverSyntaxError (yyGLRStack* yystack,
80a18357 1821 YYSTYPE* yylvalp,
43d3b664 1822 YYLTYPE* YYOPTIONAL_LOC (yyllocp)
80a18357 1823 ]b4_user_formals[)
01241d47
PH
1824{
1825 yySymbol* const yytokenp = yystack->yytokenp;
1154cced
AD
1826 size_t yyk;
1827 int yyj;
01241d47 1828
25005f6a 1829 if (yystack->yyerrState == 3)
2a1fe6ed
AD
1830 /* We just shifted the error token and (perhaps) took some
1831 reductions. Skip tokens until we can proceed. */
1832 while (yytrue)
1833 {
01241d47 1834 if (*yytokenp == YYEOF)
7bd6c77e 1835 {
25005f6a 1836 /* Now pop stack until empty and fail. */
7bd6c77e
AD
1837 while (yystack->yytops.yystates[0] != NULL)
1838 {
1839 yyGLRState *yys = yystack->yytops.yystates[0];
63d72da7 1840]b4_location_if([[ yystack->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
a0e68930
AD
1841 yydestruct ("Error: popping",
1842 yystos[yys->yylrState],
7bd6c77e
AD
1843 &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
1844 yystack->yytops.yystates[0] = yys->yypred;
1845 yystack->yynextFree -= 1;
1846 yystack->yyspaceLeft += 1;
1847 }
1848 yyFail (yystack][]b4_lpure_args[, NULL);
1849 }
01241d47 1850 if (*yytokenp != YYEMPTY)
e342c3be
AD
1851 {]b4_location_if([[
1852 /* We throw away the lookahead, but the error range
1853 of the shifted error token must take it into account. */
1854 yyGLRState *yys = yystack->yytops.yystates[0];
63d72da7
PE
1855 yyGLRStackItem yyerror_range[3];
1856 yyerror_range[1].yystate.yyloc = yys->yyloc;
1857 yyerror_range[2].yystate.yyloc = *yyllocp;
1858 YYLLOC_DEFAULT (yys->yyloc, yyerror_range, 2);]])[
e342c3be
AD
1859 yydestruct ("Error: discarding",
1860 *yytokenp, yylvalp]b4_location_if([, yyllocp])[);
1861 }
2a1fe6ed 1862 YYDPRINTF ((stderr, "Reading a token: "));
01241d47
PH
1863 yychar = YYLEX;
1864 *yytokenp = YYTRANSLATE (yychar);
284acc8b 1865 YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp);
5e6f62f2 1866 YYDPRINTF ((stderr, "\n"));
01241d47 1867 yyj = yypact[yystack->yytops.yystates[0]->yylrState];
944ed9f4 1868 if (yyis_pact_ninf (yyj))
25005f6a 1869 return;
01241d47 1870 yyj += *yytokenp;
ea99527d 1871 if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != *yytokenp)
01241d47
PH
1872 {
1873 if (yydefact[yystack->yytops.yystates[0]->yylrState] != 0)
1874 return;
1875 }
944ed9f4 1876 else if (yytable[yyj] != 0 && ! yyis_table_ninf (yytable[yyj]))
01241d47 1877 return;
2a1fe6ed 1878 }
fb8135fa 1879
2a1fe6ed 1880 /* Reduce to one stack. */
01241d47
PH
1881 for (yyk = 0; yyk < yystack->yytops.yysize; yyk += 1)
1882 if (yystack->yytops.yystates[yyk] != NULL)
1883 break;
1884 if (yyk >= yystack->yytops.yysize)
2a8d363a 1885 yyFail (yystack][]b4_lpure_args[, NULL);
01241d47
PH
1886 for (yyk += 1; yyk < yystack->yytops.yysize; yyk += 1)
1887 yymarkStackDeleted (yystack, yyk);
1888 yyremoveDeletes (yystack);
1889 yycompressStack (yystack);
1890
1891 /* Now pop stack until we find a state that shifts the error token. */
25005f6a 1892 yystack->yyerrState = 3;
fb8135fa 1893 while (yystack->yytops.yystates[0] != NULL)
01241d47 1894 {
7bd6c77e
AD
1895 yyGLRState *yys = yystack->yytops.yystates[0];
1896 yyj = yypact[yys->yylrState];
944ed9f4 1897 if (! yyis_pact_ninf (yyj))
01241d47 1898 {
944ed9f4
PE
1899 yyj += YYTERROR;
1900 if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR
1901 && yyisShiftAction (yytable[yyj]))
1902 {
e342c3be
AD
1903 /* Shift the error token having adjusted its location. */
1904 YYLTYPE yyerrloc;]b4_location_if([[
63d72da7
PE
1905 yystack->yyerror_range[2].yystate.yyloc = *yyllocp;
1906 YYLLOC_DEFAULT (yyerrloc, yystack->yyerror_range, 2);]])[
1576d44d 1907 YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]],
e342c3be 1908 yylvalp, &yyerrloc);
5e6f62f2 1909 YYDPRINTF ((stderr, "\n"));
944ed9f4 1910 yyglrShift (yystack, 0, yytable[yyj],
e342c3be
AD
1911 yys->yyposn, *yylvalp, &yyerrloc]b4_user_args[);
1912 yys = yystack->yytops.yystates[0];
944ed9f4
PE
1913 break;
1914 }
01241d47 1915 }
63d72da7 1916]b4_location_if([[ yystack->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
a0e68930
AD
1917 yydestruct ("Error: popping",
1918 yystos[yys->yylrState],
5cc16ecc 1919 &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
7bd6c77e 1920 yystack->yytops.yystates[0] = yys->yypred;
01241d47
PH
1921 yystack->yynextFree -= 1;
1922 yystack->yyspaceLeft += 1;
1923 }
1924 if (yystack->yytops.yystates[0] == NULL)
2a8d363a 1925 yyFail (yystack][]b4_lpure_args[, NULL);
fb8135fa
AD
1926}
1927
01241d47
PH
1928#define YYCHK1(YYE) \
1929 do { \
1930 switch (YYE) { \
1931 default: \
1932 break; \
1933 case yyabort: \
1934 yystack.yyerrflag = 1; \
1935 goto yyDone; \
1936 case yyaccept: \
1937 yystack.yyerrflag = 0; \
1938 goto yyDone; \
1939 case yyerr: \
1940 goto yyuser_error; \
1941 } \
fb8135fa 1942 } while (0)
01241d47 1943
0245f82d
AD
1944
1945/*----------.
1946| yyparse. |
1947`----------*/
1948
1949]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[
01241d47 1950{
fd2df2ed 1951 yySymbol yytoken;
01241d47
PH
1952 yyGLRStack yystack;
1953 size_t yyposn;
1954]b4_pure_if(
1955[
1956 YYSTYPE yylval;
1957 YYLTYPE yylloc;
1958 #undef yychar
1959 #define yychar (yystack.yyrawchar)
1960])[
1961
1962 YYSTYPE* const yylvalp = &yylval;
1963 YYLTYPE* const yyllocp = &yylloc;
fb8135fa 1964
2a1fe6ed
AD
1965 YYDPRINTF ((stderr, "Starting parse\n"));
1966
fd2df2ed
PE
1967 yytoken = YYEMPTY;
1968
01241d47
PH
1969 if (setjmp (yystack.yyexception_buffer) != 0)
1970 goto yyDone;
1971
63cb01d6
PE
1972 if (! yyinitGLRStack (&yystack, YYINITDEPTH))
1973 goto yyDone;
1974 yystack.yytokenp = &yytoken;
1975
b8458aa5
AD
1976 yylval = yyval_default;
1977]b4_location_if([
1978#if YYLTYPE_IS_TRIVIAL
1979 yylloc.first_line = yylloc.last_line = 1;
1980 yylloc.first_column = yylloc.last_column = 0;
1981#endif
1982])
1983m4_ifdef([b4_initial_action], [
1c02d4bf
AD
1984m4_pushdef([b4_at_dollar], [yylloc])dnl
1985m4_pushdef([b4_dollar_dollar], [yylval])dnl
b8458aa5
AD
1986 /* User initialization code. */
1987 b4_initial_action
1988m4_popdef([b4_dollar_dollar])dnl
1989m4_popdef([b4_at_dollar])dnl
1990/* Line __line__ of glr.c. */
1991b4_syncline([@oline@], [@ofile@])])dnl
1992[
1993 yyglrShift (&yystack, 0, 0, 0, yylval, &yylloc]b4_user_args[);
01241d47
PH
1994 yyposn = 0;
1995
fb8135fa 1996 while (yytrue)
01241d47 1997 {
21964f43
AD
1998 /* For efficiency, we have two loops, the first of which is
1999 specialized to deterministic operation (single stack, no
2000 potential ambiguity). */
01241d47 2001 /* Standard mode */
fb8135fa 2002 while (yytrue)
01241d47
PH
2003 {
2004 yyRuleNum yyrule;
2005 int yyaction;
779e7ceb 2006 const short int* yyconflicts;
01241d47
PH
2007
2008 yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
b0937b22 2009 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
01241d47
PH
2010 if (yystate == YYFINAL)
2011 goto yyDone;
fb8135fa 2012 if (yyisDefaultedState (yystate))
01241d47
PH
2013 {
2014 yyrule = yydefaultAction (yystate);
fb8135fa 2015 if (yyrule == 0)
01241d47 2016 {
63d72da7 2017]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = *yyllocp;]])[
ee16363f 2018 yyreportSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[);
01241d47
PH
2019 goto yyuser_error;
2020 }
2a8d363a 2021 YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue]b4_lpure_args[));
01241d47 2022 }
fb8135fa 2023 else
01241d47 2024 {
fb8135fa 2025 if (yytoken == YYEMPTY)
01241d47 2026 {
2a1fe6ed 2027 YYDPRINTF ((stderr, "Reading a token: "));
01241d47
PH
2028 yychar = YYLEX;
2029 yytoken = YYTRANSLATE (yychar);
284acc8b 2030 YY_SYMBOL_PRINT ("Next token is", yytoken, yylvalp, yyllocp);
5e6f62f2 2031 YYDPRINTF ((stderr, "\n"));
01241d47
PH
2032 }
2033 yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
2034 if (*yyconflicts != 0)
2035 break;
fb8135fa 2036 if (yyisShiftAction (yyaction))
01241d47 2037 {
1576d44d 2038 YY_SYMBOL_PRINT ("Shifting", yytoken, yylvalp, yyllocp);
5e6f62f2 2039 YYDPRINTF ((stderr, "\n"));
01241d47
PH
2040 if (yytoken != YYEOF)
2041 yytoken = YYEMPTY;
2042 yyposn += 1;
2a8d363a
AD
2043 yyglrShift (&yystack, 0, yyaction, yyposn,
2044 yylval, yyllocp]b4_user_args[);
39912f52 2045 if (0 < yystack.yyerrState)
01241d47 2046 yystack.yyerrState -= 1;
01241d47
PH
2047 }
2048 else if (yyisErrorAction (yyaction))
2049 {
63d72da7 2050]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = *yyllocp;]])[
ee16363f 2051 yyreportSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[);
01241d47
PH
2052 goto yyuser_error;
2053 }
2054 else
2a8d363a 2055 YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue]b4_lpure_args[));
01241d47
PH
2056 }
2057 }
2058
fb8135fa 2059 while (yytrue)
01241d47 2060 {
63cb01d6
PE
2061 size_t yys;
2062 size_t yyn = yystack.yytops.yysize;
01241d47
PH
2063 for (yys = 0; yys < yyn; yys += 1)
2064 YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn,
63cb01d6 2065 yylvalp, yyllocp]b4_lpure_args[));
01241d47
PH
2066 yytoken = YYEMPTY;
2067 yyposn += 1;
2068 yyremoveDeletes (&yystack);
2069 if (yystack.yytops.yysize == 0)
2070 {
2071 yyundeleteLastStack (&yystack);
2072 if (yystack.yytops.yysize == 0)
6e649e65 2073 yyFail (&yystack][]b4_lpure_args[, "syntax error");
2a8d363a 2074 YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
01241d47 2075 YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
63d72da7 2076]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = *yyllocp;]])[
ee16363f 2077 yyreportSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[);
01241d47
PH
2078 goto yyuser_error;
2079 }
fb8135fa 2080 else if (yystack.yytops.yysize == 1)
01241d47 2081 {
2a8d363a 2082 YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
01241d47
PH
2083 YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
2084 yycompressStack (&yystack);
2085 break;
2086 }
2087 }
2088 continue;
2089 yyuser_error:
ee16363f 2090 yyrecoverSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[);
01241d47
PH
2091 yyposn = yystack.yytops.yystates[0]->yyposn;
2092 }
2093 yyDone:
e757bb10
AD
2094 /* On YYABORT, free the lookahead. */
2095 if (yystack.yyerrflag == 1 && yytoken != YYEMPTY)
a0e68930
AD
2096 yydestruct ("Error: discarding lookahead",
2097 yytoken, yylvalp]b4_location_if([, yyllocp])[);
01241d47
PH
2098
2099 yyfreeGLRStack (&yystack);
2100 return yystack.yyerrflag;
2101}
2102
2103/* DEBUGGING ONLY */
417141dd 2104#ifdef YYDEBUG
63cb01d6 2105static void yypstack (yyGLRStack* yystack, size_t yyk) ATTRIBUTE_UNUSED;
1154cced 2106static void yypdumpstack (yyGLRStack* yystack) ATTRIBUTE_UNUSED;
01241d47 2107
1154cced 2108static void
cf126971 2109yy_yypstack (yyGLRState* yys)
01241d47 2110{
cf126971 2111 if (yys->yypred)
01241d47 2112 {
cf126971
PE
2113 yy_yypstack (yys->yypred);
2114 fprintf (stderr, " -> ");
01241d47 2115 }
779e7ceb 2116 fprintf (stderr, "%d@@%lu", yys->yylrState, (unsigned long int) yys->yyposn);
cf126971 2117}
01241d47 2118
cf126971
PE
2119static void
2120yypstates (yyGLRState* yyst)
2121{
fb8135fa 2122 if (yyst == NULL)
01241d47 2123 fprintf (stderr, "<null>");
fb8135fa 2124 else
01241d47
PH
2125 yy_yypstack (yyst);
2126 fprintf (stderr, "\n");
2127}
2128
1154cced 2129static void
63cb01d6 2130yypstack (yyGLRStack* yystack, size_t yyk)
01241d47
PH
2131{
2132 yypstates (yystack->yytops.yystates[yyk]);
2133}
2134
5cc16ecc 2135#define YYINDEX(YYX) \
01241d47
PH
2136 ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
2137
2138
1154cced 2139static void
fb8135fa 2140yypdumpstack (yyGLRStack* yystack)
01241d47
PH
2141{
2142 yyGLRStackItem* yyp;
1154cced 2143 size_t yyi;
fb8135fa 2144 for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1)
01241d47 2145 {
779e7ceb 2146 fprintf (stderr, "%3lu. ", (unsigned long int) (yyp - yystack->yyitems));
f7c398aa 2147 if (*(yybool *) yyp)
01241d47 2148 {
cf126971 2149 fprintf (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
fb8135fa 2150 yyp->yystate.yyresolved, yyp->yystate.yylrState,
779e7ceb
PE
2151 (unsigned long int) yyp->yystate.yyposn,
2152 (long int) YYINDEX (yyp->yystate.yypred));
fb8135fa 2153 if (! yyp->yystate.yyresolved)
cf126971 2154 fprintf (stderr, ", firstVal: %ld",
779e7ceb 2155 (long int) YYINDEX (yyp->yystate.yysemantics.yyfirstVal));
01241d47 2156 }
fb8135fa 2157 else
01241d47 2158 {
cf126971
PE
2159 fprintf (stderr, "Option. rule: %d, state: %ld, next: %ld",
2160 yyp->yyoption.yyrule,
779e7ceb
PE
2161 (long int) YYINDEX (yyp->yyoption.yystate),
2162 (long int) YYINDEX (yyp->yyoption.yynext));
01241d47
PH
2163 }
2164 fprintf (stderr, "\n");
2165 }
2166 fprintf (stderr, "Tops:");
2167 for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1)
779e7ceb
PE
2168 fprintf (stderr, "%lu: %ld; ", (unsigned long int) yyi,
2169 (long int) YYINDEX (yystack->yytops.yystates[yyi]));
01241d47
PH
2170 fprintf (stderr, "\n");
2171}
417141dd 2172#endif
01241d47
PH
2173]
2174
2175b4_epilogue
2176m4_if(b4_defines_flag, 0, [],
947427ae 2177[@output @output_header_name@
010f91c3
PE
2178b4_copyright([Skeleton parser for GLR parsing with Bison],
2179 [2002, 2003, 2004, 2005])
01241d47
PH
2180
2181b4_token_defines(b4_tokens)
2182
fa8c3ebc 2183#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
01241d47 2184m4_ifdef([b4_stype],
437c2d80 2185[b4_syncline([b4_stype_line], [b4_filename])
fa8c3ebc 2186typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE;
996b1c7e 2187/* Line __line__ of glr.c. */
947427ae 2188b4_syncline([@oline@], [@ofile@])],
fa8c3ebc
PE
2189[typedef int YYSTYPE;])
2190# define YYSTYPE_IS_DECLARED 1
947427ae 2191# define YYSTYPE_IS_TRIVIAL 1
01241d47
PH
2192#endif
2193
2194b4_pure_if([],
2195[extern YYSTYPE b4_prefix[]lval;])
2196
25005f6a 2197#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
fa8c3ebc 2198typedef struct YYLTYPE
01241d47 2199{
25005f6a 2200b4_location_if([
f50adbbd
AD
2201 int first_line;
2202 int first_column;
2203 int last_line;
2204 int last_column;
5cc16ecc
PE
2205],[
2206 char yydummy;
25005f6a 2207])
fa8c3ebc
PE
2208} YYLTYPE;
2209# define YYLTYPE_IS_DECLARED 1
2210# define YYLTYPE_IS_TRIVIAL 1
01241d47
PH
2211#endif
2212
e342c3be 2213b4_location_if([b4_pure_if([],
01241d47
PH
2214[extern YYLTYPE b4_prefix[]lloc;])
2215])
01241d47 2216])