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