1 m4_divert(-1) -*- C
-*-
3 # GLR skeleton for Bison
4 # Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
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.
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.
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
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 ## ---------------- ##
24 ## ---------------- ##
27 m4_define_default([b4_stack_depth_max
], [10000])
28 m4_define_default([b4_stack_depth_init
], [200])
32 ## ------------------------ ##
33 ## Pure/impure interfaces. ##
34 ## ------------------------ ##
39 # Accumule in b4_lex_param all the yylex arguments.
40 # Yes, this is quite ugly...
41 m4_define([b4_lex_param
],
42 m4_dquote(b4_pure_if([[[[YYSTYPE
*]], [[yylvalp]]][]dnl
43 b4_location_if([, [[YYLTYPE
*], [yyllocp
]]])])dnl
44 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
)))
49 m4_define([b4_user_formals
],
50 [m4_ifset([b4_parse_param
], [, b4_c_ansi_formals(b4_parse_param
)])])
55 # Arguments passed to yyerror: user args plus yylloc.
56 m4_define([b4_yyerror_args
],
57 [b4_pure_if([b4_location_if([yylocp
, ])])dnl
58 m4_ifset([b4_parse_param
], [b4_c_args(b4_parse_param
), ])])
63 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
64 m4_define([b4_lyyerror_args
],
65 [b4_pure_if([b4_location_if([yyllocp
, ])])dnl
66 m4_ifset([b4_parse_param
], [b4_c_args(b4_parse_param
), ])])
71 # Arguments needed by yyerror: user args plus yylloc.
72 m4_define([b4_pure_args
],
73 [b4_pure_if([b4_location_if([, yylocp
])])[]b4_user_args
])
78 # Arguments passed to yyerror: user formals plus yyllocp.
79 m4_define([b4_pure_formals
],
80 [b4_pure_if([b4_location_if([, YYLTYPE
*yylocp
])])[]b4_user_formals
])
85 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
86 m4_define([b4_lpure_args
],
87 [b4_pure_if([b4_location_if([, yyllocp
])])[]b4_user_args
])
92 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
93 m4_define([b4_lpure_formals
],
94 [b4_pure_if([b4_location_if([YYLTYPE
*yyllocp
])])[]b4_user_formals
])
97 ## ----------------- ##
98 ## Semantic Values. ##
99 ## ----------------- ##
102 # b4_lhs_value([TYPE])
103 # --------------------
104 # Expansion of $<TYPE>$.
105 m4_define([b4_lhs_value
],
106 [((*yyvalp
)[]m4_ifval([$
1], [.$
1]))])
109 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
110 # --------------------------------------
111 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
113 m4_define([b4_rhs_value
],
114 [(((yyGLRStackItem
const *)yyvsp
)@
{YYFILL (m4_eval([$
2 - $
1]))@
}.yystate
.yysemantics
.yysval
[]m4_ifval([$
3], [.$
3]))])
125 m4_define([b4_lhs_location
],
129 # b4_rhs_location(RULE-LENGTH, NUM)
130 # ---------------------------------
131 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
133 m4_define([b4_rhs_location
],
134 [(((yyGLRStackItem
const *)yyvsp
)@
{YYFILL (m4_eval([$
2 - $
1]))@
}.yystate
.yyloc
)])
136 # We do want M4 expansion after # for CPP macros.
139 @output @output_parser_name@
140 b4_copyright([Skeleton parser
for GLR parsing with Bison
],
141 [2002, 2003, 2004, 2005])
143 /* This is the parser code for GLR (Generalized LR) parser. */
146 m4_if(b4_prefix
[], [yy
], [],
147 [/* Substitute the variable and function names. */
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
155 #define yylloc b4_prefix[]lloc])
157 b4_token_defines(b4_tokens
)
159 /* Copy the first part of user declarations. */
162 /* Enabling traces. */
164 # define YYDEBUG ]b4_debug[
167 /* Enabling verbose error messages. */
168 #ifdef YYERROR_VERBOSE
169 # undef YYERROR_VERBOSE
170 # define YYERROR_VERBOSE 1
172 # define YYERROR_VERBOSE ]b4_error_verbose[
175 /* Enabling the token table. */
176 #ifndef YYTOKEN_TABLE
177 # define YYTOKEN_TABLE ]b4_token_table[
180 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
181 ]m4_ifdef([b4_stype
],
182 [b4_syncline([b4_stype_line
], [b4_filename
])
183 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
184 /* Line __line__ of glr.c. */
185 b4_syncline([@oline@
], [@ofile@
])],
186 [typedef int YYSTYPE
;])[
187 # define YYSTYPE_IS_DECLARED 1
188 # define YYSTYPE_IS_TRIVIAL 1
191 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
192 typedef struct YYLTYPE
203 # define YYLTYPE_IS_DECLARED 1
204 # define YYLTYPE_IS_TRIVIAL 1
207 /* Default (constant) value used for initialization for null
208 right-hand sides. Unlike the standard yacc.c template,
209 here we set the default value of $$ to a zeroed-out value.
210 Since the default value is undefined, this behavior is
211 technically correct. */
212 static YYSTYPE yyval_default
;
214 /* Copy the second part of user declarations. */
217 ]/* Line __line__ of glr.c. */
218 b4_syncline([@oline@
], [@ofile@
])
229 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
230 # define YY_(msgid) dgettext ("bison-runtime", msgid)
234 # define YY_(msgid) msgid
242 # define YYMALLOC malloc
245 # define YYREALLOC realloc
248 #define YYSIZEMAX ((size_t) -1)
253 typedef unsigned char yybool
;
262 #ifndef __attribute__
263 /* This feature is available in gcc versions 2.5 and later. */
264 # if (!defined (__GNUC__) || __GNUC__ < 2 \
265 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
266 # define __attribute__(Spec) /* empty */
270 ]b4_location_if([#define YYOPTIONAL_LOC(Name) Name],[
272 # define YYOPTIONAL_LOC(Name) /* empty */
274 # define YYOPTIONAL_LOC(Name) Name __attribute__ ((__unused__))
278 # define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
281 /* YYFINAL -- State number of the termination state. */
282 #define YYFINAL ]b4_final_state_number[
283 /* YYLAST -- Last index in YYTABLE. */
284 #define YYLAST ]b4_last[
286 /* YYNTOKENS -- Number of terminals. */
287 #define YYNTOKENS ]b4_tokens_number[
288 /* YYNNTS -- Number of nonterminals. */
289 #define YYNNTS ]b4_nterms_number[
290 /* YYNRULES -- Number of rules. */
291 #define YYNRULES ]b4_rules_number[
292 /* YYNRULES -- Number of states. */
293 #define YYNSTATES ]b4_states_number[
294 /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
295 #define YYMAXRHS ]b4_r2_max[
296 /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
297 accessed by $0, $-1, etc., in any rule. */
298 #define YYMAXLEFT ]b4_max_left_semantic_context[
300 /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
301 #define YYUNDEFTOK ]b4_undef_token_number[
302 #define YYMAXUTOK ]b4_user_token_number_max[
304 #define YYTRANSLATE(YYX) \
305 ((YYX <= 0) ? YYEOF : \
306 (unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
308 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
309 static const ]b4_int_type_for([b4_translate
])[ yytranslate
[] =
315 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
317 static const ]b4_int_type_for([b4_prhs
])[ yyprhs
[] =
322 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
323 static const ]b4_int_type_for([b4_rhs
])[ yyrhs
[] =
328 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
329 static const ]b4_int_type_for([b4_rline
])[ yyrline
[] =
335 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
336 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
337 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
338 static const char *const yytname
[] =
344 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
345 static const ]b4_int_type_for([b4_r1
])[ yyr1
[] =
350 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
351 static const ]b4_int_type_for([b4_r2
])[ yyr2
[] =
356 /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
357 static const ]b4_int_type_for([b4_dprec
])[ yydprec
[] =
362 /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
363 static const ]b4_int_type_for([b4_merger
])[ yymerger
[] =
368 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
369 doesn't specify something else to do. Zero means the default is an
371 static const ]b4_int_type_for([b4_defact
])[ yydefact
[] =
376 /* YYPDEFGOTO[NTERM-NUM]. */
377 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto
[] =
382 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
384 #define YYPACT_NINF ]b4_pact_ninf[
385 static const ]b4_int_type_for([b4_pact
])[ yypact
[] =
390 /* YYPGOTO[NTERM-NUM]. */
391 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto
[] =
396 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
397 positive, shift that token. If negative, reduce the rule which
398 number is the opposite. If zero, do what YYDEFACT says.
399 If YYTABLE_NINF, syntax error. */
400 #define YYTABLE_NINF ]b4_table_ninf[
401 static const ]b4_int_type_for([b4_table
])[ yytable
[] =
406 /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
407 list of conflicting reductions corresponding to action entry for
408 state STATE-NUM in yytable. 0 means no conflicts. The list in
409 yyconfl is terminated by a rule number of 0. */
410 static const ]b4_int_type_for([b4_conflict_list_heads
])[ yyconflp
[] =
412 ]b4_conflict_list_heads
[
415 /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
416 0, pointed into by YYCONFLP. */
417 ]dnl Do
not use b4_int_type_for here
, since there are places where
418 dnl pointers onto yyconfl are taken
, which type is
"short int *".
419 dnl We probably ought to introduce a type
for confl
.
420 [static const short int yyconfl
[] =
422 ]b4_conflicting_rules
[
425 static const ]b4_int_type_for([b4_check
])[ yycheck
[] =
430 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
431 symbol of state STATE-NUM. */
432 static const ]b4_int_type_for([b4_stos
])[ yystos
[] =
438 /* Prevent warning if -Wmissing-prototypes. */
439 ]b4_c_ansi_function_decl([yyparse
], [int], b4_parse_param
)[
441 /* Error token number */
444 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
445 If N is 0, then set CURRENT to the empty location which ends
446 the previous symbol: RHS[0] (always defined). */
449 #define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
450 #ifndef YYLLOC_DEFAULT
451 # define YYLLOC_DEFAULT(Current, Rhs, N) \
455 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
456 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
457 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
458 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
462 (Current).first_line = (Current).last_line = \
463 YYRHSLOC (Rhs, 0).last_line; \
464 (Current).first_column = (Current).last_column = \
465 YYRHSLOC (Rhs, 0).last_column; \
469 /* YY_LOCATION_PRINT -- Print the location on the stream.
470 This macro was not mandated originally: define only if we know
471 we won't break user code: when these are the locations we know. */
473 # define YY_LOCATION_PRINT(File, Loc) \
474 fprintf (File, "%d.%d-%d.%d", \
475 (Loc).first_line, (Loc).first_column, \
476 (Loc).last_line, (Loc).last_column)
479 #ifndef YYLLOC_DEFAULT
480 # define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)
484 #ifndef YY_LOCATION_PRINT
485 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
489 /* YYLEX -- calling `yylex' with the right arguments. */
490 #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
495 #define yynerrs (yystack->yyerrcnt)
497 #define yychar (yystack->yyrawchar)],
505 static const int YYEOF
= 0;
506 static const int YYEMPTY
= -2;
508 typedef enum { yyok
, yyaccept
, yyabort
, yyerr
} YYRESULTTAG
;
511 do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
516 #if ! defined (YYFPRINTF)
517 # define YYFPRINTF fprintf
520 # define YYDPRINTF(Args) \
526 ]b4_yysymprint_generate([b4_c_ansi_function_def
])[
528 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
532 YYFPRINTF (stderr, "%s ", Title); \
533 yysymprint (stderr, \
534 Type, Value]b4_location_if([, Location])[); \
535 YYFPRINTF (stderr, "\n"); \
539 /* Nonzero means print parse trace. It is left uninitialized so that
540 multiple parsers can coexist. */
545 # define YYDPRINTF(Args)
546 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
548 #endif /* !YYDEBUG */
550 /* YYINITDEPTH -- initial size of the parser's stacks. */
552 # define YYINITDEPTH ]b4_stack_depth_init[
555 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
556 if the built-in stack extension method is used).
558 Do not make this value too large; the results are undefined if
559 SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
560 evaluated with infinite-precision integer arithmetic. */
563 # define YYMAXDEPTH ]b4_stack_depth_max[
566 /* Minimum number of free items on the stack allowed after an
567 allocation. This is to allow allocation and initialization
568 to be completed by functions that call yyexpandGLRStack before the
569 stack is expanded, thus insuring that all necessary pointers get
570 properly redirected to new data. */
573 #ifndef YYSTACKEXPANDABLE
574 # if (! defined (__cplusplus) \
575 || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \
576 && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))
577 # define YYSTACKEXPANDABLE 1
579 # define YYSTACKEXPANDABLE 0
586 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
587 # define yystpcpy stpcpy
589 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
592 yystpcpy (char *yydest
, const char *yysrc
)
595 const char *yys
= yysrc
;
597 while ((*yyd
++ = *yys
++) != '\0')
606 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
607 quotes and backslashes, so that it's suitable for yyerror. The
608 heuristic is that double-quoting is unnecessary unless the string
609 contains an apostrophe, a comma, or backslash (other than
610 backslash-backslash). YYSTR is taken from yytname. If YYRES is
611 null, do not copy; instead, return the length of what the result
614 yytnamerr (char *yyres
, const char *yystr
)
619 char const *yyp
= yystr
;
626 goto do_not_strip_quotes
;
630 goto do_not_strip_quotes
;
643 do_not_strip_quotes
: ;
647 return strlen (yystr
);
649 return yystpcpy (yyres
, yystr
) - yyres
;
653 #endif /* !YYERROR_VERBOSE */
655 /** State numbers, as in LALR(1) machine */
656 typedef int yyStateNum
;
658 /** Rule numbers, as in LALR(1) machine */
659 typedef int yyRuleNum
;
661 /** Grammar symbol */
662 typedef short int yySymbol
;
664 /** Item references, as in LALR(1) machine */
665 typedef short int yyItemNum
;
667 typedef struct yyGLRState yyGLRState
;
668 typedef struct yySemanticOption yySemanticOption
;
669 typedef union yyGLRStackItem yyGLRStackItem
;
670 typedef struct yyGLRStack yyGLRStack
;
671 typedef struct yyGLRStateSet yyGLRStateSet
;
674 /** Type tag: always true. */
676 /** Type tag for yysemantics. If true, yysval applies, otherwise
677 * yyfirstVal applies. */
679 /** Number of corresponding LALR(1) machine state. */
680 yyStateNum yylrState
;
681 /** Preceding state in this stack */
683 /** Source position of the first token produced by my symbol */
686 /** First in a chain of alternative reductions producing the
687 * non-terminal corresponding to this state, threaded through
689 yySemanticOption
* yyfirstVal
;
690 /** Semantic value for this state. */
693 /** Source location for this state. */
697 struct yyGLRStateSet
{
698 yyGLRState
** yystates
;
699 size_t yysize
, yycapacity
;
702 struct yySemanticOption
{
703 /** Type tag: always false. */
705 /** Rule number for this reduction */
707 /** The last RHS state in the list of states to be reduced. */
709 /** Next sibling in chain of options. To facilitate merging,
710 * options are chained in decreasing order by address. */
711 yySemanticOption
* yynext
;
714 /** Type of the items in the GLR stack. The yyisState field
715 * indicates which item of the union is valid. */
716 union yyGLRStackItem
{
718 yySemanticOption yyoption
;
723 ]b4_location_if([[ /* To compute the location of the error token. */
724 yyGLRStackItem yyerror_range
[3];]])[
731 jmp_buf yyexception_buffer
;
732 yyGLRStackItem
* yyitems
;
733 yyGLRStackItem
* yynextFree
;
735 yyGLRState
* yysplitPoint
;
736 yyGLRState
* yylastDeleted
;
737 yyGLRStateSet yytops
;
740 static void yyexpandGLRStack (yyGLRStack
* yystack
);
742 static void yyFail (yyGLRStack
* yystack
]b4_pure_formals
[, const char* yymsg
)
743 __attribute__ ((__noreturn__
));
745 yyFail (yyGLRStack
* yystack
]b4_pure_formals
[, const char* yymsg
)
748 yyerror (]b4_yyerror_args
[yymsg
);
749 longjmp (yystack
->yyexception_buffer
, 1);
752 static void yyMemoryExhausted (yyGLRStack
* yystack
)
753 __attribute__ ((__noreturn__
));
755 yyMemoryExhausted (yyGLRStack
* yystack
)
757 longjmp (yystack
->yyexception_buffer
, 2);
760 #if YYDEBUG || YYERROR_VERBOSE
761 /** A printable representation of TOKEN. */
762 static inline const char*
763 yytokenName (yySymbol yytoken
)
765 if (yytoken
== YYEMPTY
)
768 return yytname
[yytoken
];
772 /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
773 * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
774 * containing the pointer to the next state in the chain. Assumes
775 * YYLOW1 < YYLOW0. */
776 static void yyfillin (yyGLRStackItem
*, int, int) __attribute__ ((__unused__
));
778 yyfillin (yyGLRStackItem
*yyvsp
, int yylow0
, int yylow1
)
782 s
= yyvsp
[yylow0
].yystate
.yypred
;
783 for (i
= yylow0
-1; i
>= yylow1
; i
-= 1)
785 YYASSERT (s
->yyresolved
);
786 yyvsp
[i
].yystate
.yyresolved
= yytrue
;
787 yyvsp
[i
].yystate
.yysemantics
.yysval
= s
->yysemantics
.yysval
;
788 yyvsp
[i
].yystate
.yyloc
= s
->yyloc
;
789 s
= yyvsp
[i
].yystate
.yypred
= s
->yypred
;
793 /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
794 YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
795 For convenience, always return YYLOW1. */
796 static inline int yyfill (yyGLRStackItem
*, int *, int, yybool
)
797 __attribute__ ((__unused__
));
799 yyfill (yyGLRStackItem
*yyvsp
, int *yylow
, int yylow1
, yybool yynormal
)
801 if (!yynormal
&& yylow1
< *yylow
)
803 yyfillin (yyvsp
, *yylow
, yylow1
);
809 /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
810 * and top stack item YYVSP. YYLVALP points to place to put semantic
811 * value ($$), and yylocp points to place for location information
812 * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
813 * yyerr for YYERROR, yyabort for YYABORT. */
815 yyuserAction (yyRuleNum yyn
, int yyrhslen
, yyGLRStackItem
* yyvsp
,
817 YYLTYPE
* YYOPTIONAL_LOC (yylocp
),
821 yybool yynormal
__attribute__ ((__unused__
)) =
822 (yystack
->yysplitPoint
== NULL
);
826 # define yyerrok (yystack->yyerrState = 0)
828 # define YYACCEPT return yyaccept
830 # define YYABORT return yyabort
832 # define YYERROR return yyerrok, yyerr
834 # define YYRECOVERING (yystack->yyerrState != 0)
836 # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)
838 # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
840 # define YYBACKUP(Token, Value) \
841 return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
846 *yyvalp
= yyval_default
;
848 *yyvalp
= yyvsp
[YYFILL (1-yyrhslen
)].yystate
.yysemantics
.yysval
;
849 YYLLOC_DEFAULT (*yylocp
, yyvsp
- yyrhslen
, yyrhslen
);
850 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= *yylocp
;
866 /* Line __line__ of glr.c. */
867 b4_syncline([@oline@
], [@ofile@
])
872 yyuserMerge (int yyn
, YYSTYPE
* yy0
, YYSTYPE
* yy1
)
874 /* `Use' the arguments. */
885 /* Bison grammar-table manipulation. */
887 ]b4_yydestruct_generate([b4_c_ansi_function_def
])[
889 /** Number of symbols composing the right hand side of rule #RULE. */
891 yyrhsLength (yyRuleNum yyrule
)
897 yydestroyGLRState (char const *yymsg
, yyGLRState
*yys
)
900 yydestruct (yymsg
, yystos
[yys
->yylrState
],
901 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[);
907 YYFPRINTF (stderr
, "%s unresolved ", yymsg
);
908 yysymprint (stderr
, yystos
[yys
->yylrState
],
909 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[);
910 YYFPRINTF (stderr
, "\n");
914 if (yys
->yysemantics
.yyfirstVal
)
916 yySemanticOption
*yyoption
= yys
->yysemantics
.yyfirstVal
;
919 for (yyrhs
= yyoption
->yystate
, yyn
= yyrhsLength (yyoption
->yyrule
);
921 yyrhs
= yyrhs
->yypred
, yyn
-= 1)
922 yydestroyGLRState (yymsg
, yyrhs
);
927 /** Left-hand-side symbol for rule #RULE. */
928 static inline yySymbol
929 yylhsNonterm (yyRuleNum yyrule
)
934 #define yyis_pact_ninf(yystate) \
935 ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), 1,
937 ((yystate
) == YYPACT_NINF
))[
939 /** True iff LR state STATE has only a default reduction (regardless
942 yyisDefaultedState (yyStateNum yystate
)
944 return yyis_pact_ninf (yypact
[yystate
]);
947 /** The default reduction for STATE, assuming it has one. */
948 static inline yyRuleNum
949 yydefaultAction (yyStateNum yystate
)
951 return yydefact
[yystate
];
954 #define yyis_table_ninf(yytable_value) \
955 ]m4_if(m4_eval(b4_table_ninf < b4_table_min), 1,
957 ((yytable_value
) == YYTABLE_NINF
))[
959 /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
961 * R < 0: Reduce on rule -R.
963 * R > 0: Shift to state R.
964 * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
965 * conflicting reductions.
968 yygetLRActions (yyStateNum yystate
, int yytoken
,
969 int* yyaction
, const short int** yyconflicts
)
971 int yyindex
= yypact
[yystate
] + yytoken
;
972 if (yyindex
< 0 || YYLAST
< yyindex
|| yycheck
[yyindex
] != yytoken
)
974 *yyaction
= -yydefact
[yystate
];
975 *yyconflicts
= yyconfl
;
977 else if (! yyis_table_ninf (yytable
[yyindex
]))
979 *yyaction
= yytable
[yyindex
];
980 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
985 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
989 static inline yyStateNum
990 yyLRgotoState (yyStateNum yystate
, yySymbol yylhs
)
993 yyr
= yypgoto
[yylhs
- YYNTOKENS
] + yystate
;
994 if (0 <= yyr
&& yyr
<= YYLAST
&& yycheck
[yyr
] == yystate
)
997 return yydefgoto
[yylhs
- YYNTOKENS
];
1000 static inline yybool
1001 yyisShiftAction (int yyaction
)
1003 return 0 < yyaction
;
1006 static inline yybool
1007 yyisErrorAction (int yyaction
)
1009 return yyaction
== 0;
1015 yyaddDeferredAction (yyGLRStack
* yystack
, yyGLRState
* yystate
,
1016 yyGLRState
* rhs
, yyRuleNum yyrule
)
1018 yySemanticOption
* yynewItem
;
1019 yynewItem
= &yystack
->yynextFree
->yyoption
;
1020 yystack
->yyspaceLeft
-= 1;
1021 yystack
->yynextFree
+= 1;
1022 yynewItem
->yyisState
= yyfalse
;
1023 yynewItem
->yystate
= rhs
;
1024 yynewItem
->yyrule
= yyrule
;
1025 yynewItem
->yynext
= yystate
->yysemantics
.yyfirstVal
;
1026 yystate
->yysemantics
.yyfirstVal
= yynewItem
;
1027 if (yystack
->yyspaceLeft
< YYHEADROOM
)
1028 yyexpandGLRStack (yystack
);
1033 /** Initialize SET to a singleton set containing an empty stack. */
1035 yyinitStateSet (yyGLRStateSet
* yyset
)
1038 yyset
->yycapacity
= 16;
1039 yyset
->yystates
= (yyGLRState
**) YYMALLOC (16 * sizeof yyset
->yystates
[0]);
1040 if (! yyset
->yystates
)
1042 yyset
->yystates
[0] = NULL
;
1046 static void yyfreeStateSet (yyGLRStateSet
* yyset
)
1048 YYFREE (yyset
->yystates
);
1051 /** Initialize STACK to a single empty stack, with total maximum
1052 * capacity for all stacks of SIZE. */
1054 yyinitGLRStack (yyGLRStack
* yystack
, size_t yysize
)
1056 yystack
->yyerrState
= 0;
1058 yystack
->yyspaceLeft
= yysize
;
1060 (yyGLRStackItem
*) YYMALLOC (yysize
* sizeof yystack
->yynextFree
[0]);
1061 if (!yystack
->yyitems
)
1063 yystack
->yynextFree
= yystack
->yyitems
;
1064 yystack
->yysplitPoint
= NULL
;
1065 yystack
->yylastDeleted
= NULL
;
1066 return yyinitStateSet (&yystack
->yytops
);
1069 #define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
1070 &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
1072 /** If STACK is expandable, extend it. WARNING: Pointers into the
1073 stack from outside should be considered invalid after this call.
1074 We always expand when there are 1 or fewer items left AFTER an
1075 allocation, so that we can avoid having external pointers exist
1076 across an allocation. */
1078 yyexpandGLRStack (yyGLRStack
* yystack
)
1080 #if YYSTACKEXPANDABLE
1081 yyGLRStackItem
* yynewItems
;
1082 yyGLRStackItem
* yyp0
, *yyp1
;
1083 size_t yysize
, yynewSize
;
1085 yysize
= yystack
->yynextFree
- yystack
->yyitems
;
1086 if (YYMAXDEPTH
<= yysize
)
1087 yyMemoryExhausted (yystack
);
1088 yynewSize
= 2*yysize
;
1089 if (YYMAXDEPTH
< yynewSize
)
1090 yynewSize
= YYMAXDEPTH
;
1091 yynewItems
= (yyGLRStackItem
*) YYMALLOC (yynewSize
* sizeof yynewItems
[0]);
1093 yyMemoryExhausted (yystack
);
1094 for (yyp0
= yystack
->yyitems
, yyp1
= yynewItems
, yyn
= yysize
;
1096 yyn
-= 1, yyp0
+= 1, yyp1
+= 1)
1099 if (*(yybool
*) yyp0
)
1101 yyGLRState
* yys0
= &yyp0
->yystate
;
1102 yyGLRState
* yys1
= &yyp1
->yystate
;
1103 if (yys0
->yypred
!= NULL
)
1105 YYRELOC (yyp0
, yyp1
, yys0
->yypred
, yystate
);
1106 if (! yys0
->yyresolved
&& yys0
->yysemantics
.yyfirstVal
!= NULL
)
1107 yys1
->yysemantics
.yyfirstVal
=
1108 YYRELOC(yyp0
, yyp1
, yys0
->yysemantics
.yyfirstVal
, yyoption
);
1112 yySemanticOption
* yyv0
= &yyp0
->yyoption
;
1113 yySemanticOption
* yyv1
= &yyp1
->yyoption
;
1114 if (yyv0
->yystate
!= NULL
)
1115 yyv1
->yystate
= YYRELOC (yyp0
, yyp1
, yyv0
->yystate
, yystate
);
1116 if (yyv0
->yynext
!= NULL
)
1117 yyv1
->yynext
= YYRELOC (yyp0
, yyp1
, yyv0
->yynext
, yyoption
);
1120 if (yystack
->yysplitPoint
!= NULL
)
1121 yystack
->yysplitPoint
= YYRELOC (yystack
->yyitems
, yynewItems
,
1122 yystack
->yysplitPoint
, yystate
);
1124 for (yyn
= 0; yyn
< yystack
->yytops
.yysize
; yyn
+= 1)
1125 if (yystack
->yytops
.yystates
[yyn
] != NULL
)
1126 yystack
->yytops
.yystates
[yyn
] =
1127 YYRELOC (yystack
->yyitems
, yynewItems
,
1128 yystack
->yytops
.yystates
[yyn
], yystate
);
1129 YYFREE (yystack
->yyitems
);
1130 yystack
->yyitems
= yynewItems
;
1131 yystack
->yynextFree
= yynewItems
+ yysize
;
1132 yystack
->yyspaceLeft
= yynewSize
- yysize
;
1135 yyMemoryExhausted (yystack
);
1140 yyfreeGLRStack (yyGLRStack
* yystack
)
1142 YYFREE (yystack
->yyitems
);
1143 yyfreeStateSet (&yystack
->yytops
);
1146 /** Assuming that S is a GLRState somewhere on STACK, update the
1147 * splitpoint of STACK, if needed, so that it is at least as deep as
1150 yyupdateSplit (yyGLRStack
* yystack
, yyGLRState
* yys
)
1152 if (yystack
->yysplitPoint
!= NULL
&& yystack
->yysplitPoint
> yys
)
1153 yystack
->yysplitPoint
= yys
;
1156 /** Invalidate stack #K in STACK. */
1158 yymarkStackDeleted (yyGLRStack
* yystack
, size_t yyk
)
1160 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1161 yystack
->yylastDeleted
= yystack
->yytops
.yystates
[yyk
];
1162 yystack
->yytops
.yystates
[yyk
] = NULL
;
1165 /** Undelete the last stack that was marked as deleted. Can only be
1166 done once after a deletion, and only when all other stacks have
1169 yyundeleteLastStack (yyGLRStack
* yystack
)
1171 if (yystack
->yylastDeleted
== NULL
|| yystack
->yytops
.yysize
!= 0)
1173 yystack
->yytops
.yystates
[0] = yystack
->yylastDeleted
;
1174 yystack
->yytops
.yysize
= 1;
1175 YYDPRINTF ((stderr
, "Restoring last deleted stack as stack #0.\n"));
1176 yystack
->yylastDeleted
= NULL
;
1180 yyremoveDeletes (yyGLRStack
* yystack
)
1184 while (yyj
< yystack
->yytops
.yysize
)
1186 if (yystack
->yytops
.yystates
[yyi
] == NULL
)
1190 YYDPRINTF ((stderr
, "Removing dead stacks.\n"));
1192 yystack
->yytops
.yysize
-= 1;
1196 yystack
->yytops
.yystates
[yyj
] = yystack
->yytops
.yystates
[yyi
];
1199 YYDPRINTF ((stderr
, "Rename stack %lu -> %lu.\n",
1200 (unsigned long int) yyi
, (unsigned long int) yyj
));
1208 /** Shift to a new state on stack #K of STACK, corresponding to LR state
1209 * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
1211 yyglrShift (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1213 YYSTYPE yysval
, YYLTYPE
* yylocp
)
1215 yyGLRStackItem
* yynewItem
;
1217 yynewItem
= yystack
->yynextFree
;
1218 yystack
->yynextFree
+= 1;
1219 yystack
->yyspaceLeft
-= 1;
1220 yynewItem
->yystate
.yyisState
= yytrue
;
1221 yynewItem
->yystate
.yylrState
= yylrState
;
1222 yynewItem
->yystate
.yyposn
= yyposn
;
1223 yynewItem
->yystate
.yyresolved
= yytrue
;
1224 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1225 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1226 yynewItem
->yystate
.yysemantics
.yysval
= yysval
;
1227 yynewItem
->yystate
.yyloc
= *yylocp
;
1228 if (yystack
->yyspaceLeft
< YYHEADROOM
)
1229 yyexpandGLRStack (yystack
);
1232 /** Shift stack #K of YYSTACK, to a new state corresponding to LR
1233 * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
1234 * semantic value of YYRHS under the action for YYRULE. */
1236 yyglrShiftDefer (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1237 size_t yyposn
, yyGLRState
* rhs
, yyRuleNum yyrule
)
1239 yyGLRStackItem
* yynewItem
;
1241 yynewItem
= yystack
->yynextFree
;
1242 yynewItem
->yystate
.yyisState
= yytrue
;
1243 yynewItem
->yystate
.yylrState
= yylrState
;
1244 yynewItem
->yystate
.yyposn
= yyposn
;
1245 yynewItem
->yystate
.yyresolved
= yyfalse
;
1246 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1247 yynewItem
->yystate
.yysemantics
.yyfirstVal
= NULL
;
1248 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1249 yystack
->yynextFree
+= 1;
1250 yystack
->yyspaceLeft
-= 1;
1251 yyaddDeferredAction (yystack
, &yynewItem
->yystate
, rhs
, yyrule
);
1254 /** Pop the symbols consumed by reduction #RULE from the top of stack
1255 * #K of STACK, and perform the appropriate semantic action on their
1256 * semantic values. Assumes that all ambiguities in semantic values
1257 * have been previously resolved. Set *VALP to the resulting value,
1258 * and *LOCP to the computed location (if any). Return value is as
1259 * for userAction. */
1260 static inline YYRESULTTAG
1261 yydoAction (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1262 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1264 int yynrhs
= yyrhsLength (yyrule
);
1266 if (yystack
->yysplitPoint
== NULL
)
1268 /* Standard special case: single stack. */
1269 yyGLRStackItem
* rhs
= (yyGLRStackItem
*) yystack
->yytops
.yystates
[yyk
];
1270 YYASSERT (yyk
== 0);
1271 yystack
->yynextFree
-= yynrhs
;
1272 yystack
->yyspaceLeft
+= yynrhs
;
1273 yystack
->yytops
.yystates
[0] = & yystack
->yynextFree
[-1].yystate
;
1274 return yyuserAction (yyrule
, yynrhs
, rhs
,
1275 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1281 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1282 yys
= yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
1283 = yystack
->yytops
.yystates
[yyk
];
1284 for (yyi
= 0; yyi
< yynrhs
; yyi
+= 1)
1289 yyupdateSplit (yystack
, yys
);
1290 yystack
->yytops
.yystates
[yyk
] = yys
;
1291 return yyuserAction (yyrule
, yynrhs
, yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1292 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1297 # define YY_REDUCE_PRINT(K, Rule)
1299 # define YY_REDUCE_PRINT(K, Rule) \
1302 yy_reduce_print (K, Rule); \
1305 /*----------------------------------------------------------.
1306 | Report that the RULE is going to be reduced on stack #K. |
1307 `----------------------------------------------------------*/
1310 yy_reduce_print (size_t yyk
, yyRuleNum yyrule
)
1313 YYFPRINTF (stderr
, "Reducing stack %lu by rule %d (line %lu), ",
1314 (unsigned long int) yyk
, yyrule
- 1,
1315 (unsigned long int) yyrline
[yyrule
]);
1316 /* Print the symbols being reduced, and their result. */
1317 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
1318 YYFPRINTF (stderr
, "%s ", yytokenName (yyrhs
[yyi
]));
1319 YYFPRINTF (stderr
, "-> %s\n", yytokenName (yyr1
[yyrule
]));
1323 /** Pop items off stack #K of STACK according to grammar rule RULE,
1324 * and push back on the resulting nonterminal symbol. Perform the
1325 * semantic action associated with RULE and store its value with the
1326 * newly pushed state, if FORCEEVAL or if STACK is currently
1327 * unambiguous. Otherwise, store the deferred semantic action with
1328 * the new state. If the new state would have an identical input
1329 * position, LR state, and predecessor to an existing state on the stack,
1330 * it is identified with that existing state, eliminating stack #K from
1331 * the STACK. In this case, the (necessarily deferred) semantic value is
1332 * added to the options for the existing state's semantic value.
1334 static inline YYRESULTTAG
1335 yyglrReduce (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1336 yybool yyforceEval
]b4_user_formals
[)
1338 size_t yyposn
= yystack
->yytops
.yystates
[yyk
]->yyposn
;
1340 if (yyforceEval
|| yystack
->yysplitPoint
== NULL
)
1345 YY_REDUCE_PRINT (yyk
, yyrule
);
1346 YYCHK (yydoAction (yystack
, yyk
, yyrule
, &yysval
, &yyloc
]b4_user_args
[));
1347 yyglrShift (yystack
, yyk
,
1348 yyLRgotoState (yystack
->yytops
.yystates
[yyk
]->yylrState
,
1349 yylhsNonterm (yyrule
)),
1350 yyposn
, yysval
, &yyloc
);
1356 yyGLRState
* yys
, *yys0
= yystack
->yytops
.yystates
[yyk
];
1357 yyStateNum yynewLRState
;
1359 for (yys
= yystack
->yytops
.yystates
[yyk
], yyn
= yyrhsLength (yyrule
);
1365 yyupdateSplit (yystack
, yys
);
1366 yynewLRState
= yyLRgotoState (yys
->yylrState
, yylhsNonterm (yyrule
));
1368 "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
1369 (unsigned long int) yyk
, yyrule
- 1, yynewLRState
));
1370 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
1371 if (yyi
!= yyk
&& yystack
->yytops
.yystates
[yyi
] != NULL
)
1373 yyGLRState
* yyp
, *yysplit
= yystack
->yysplitPoint
;
1374 yyp
= yystack
->yytops
.yystates
[yyi
];
1375 while (yyp
!= yys
&& yyp
!= yysplit
&& yyp
->yyposn
>= yyposn
)
1377 if (yyp
->yylrState
== yynewLRState
&& yyp
->yypred
== yys
)
1379 yyaddDeferredAction (yystack
, yyp
, yys0
, yyrule
);
1380 yymarkStackDeleted (yystack
, yyk
);
1381 YYDPRINTF ((stderr
, "Merging stack %lu into stack %lu.\n",
1382 (unsigned long int) yyk
,
1383 (unsigned long int) yyi
));
1389 yystack
->yytops
.yystates
[yyk
] = yys
;
1390 yyglrShiftDefer (yystack
, yyk
, yynewLRState
, yyposn
, yys0
, yyrule
);
1396 yysplitStack (yyGLRStack
* yystack
, size_t yyk
)
1398 if (yystack
->yysplitPoint
== NULL
)
1400 YYASSERT (yyk
== 0);
1401 yystack
->yysplitPoint
= yystack
->yytops
.yystates
[yyk
];
1403 if (yystack
->yytops
.yysize
>= yystack
->yytops
.yycapacity
)
1405 yyGLRState
** yynewStates
;
1406 if (! ((yystack
->yytops
.yycapacity
1407 <= (YYSIZEMAX
/ (2 * sizeof yynewStates
[0])))
1409 (yyGLRState
**) YYREALLOC (yystack
->yytops
.yystates
,
1410 ((yystack
->yytops
.yycapacity
*= 2)
1411 * sizeof yynewStates
[0])))))
1412 yyMemoryExhausted (yystack
);
1413 yystack
->yytops
.yystates
= yynewStates
;
1415 yystack
->yytops
.yystates
[yystack
->yytops
.yysize
]
1416 = yystack
->yytops
.yystates
[yyk
];
1417 yystack
->yytops
.yysize
+= 1;
1418 return yystack
->yytops
.yysize
-1;
1421 /** True iff Y0 and Y1 represent identical options at the top level.
1422 * That is, they represent the same rule applied to RHS symbols
1423 * that produce the same terminal symbols. */
1425 yyidenticalOptions (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1427 if (yyy0
->yyrule
== yyy1
->yyrule
)
1429 yyGLRState
*yys0
, *yys1
;
1431 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1432 yyn
= yyrhsLength (yyy0
->yyrule
);
1434 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1435 if (yys0
->yyposn
!= yys1
->yyposn
)
1443 /** Assuming identicalOptions (Y0,Y1), destructively merge the
1444 * alternative semantic values for the RHS-symbols of Y1 and Y0. */
1446 yymergeOptionSets (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1448 yyGLRState
*yys0
, *yys1
;
1450 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1451 yyn
= yyrhsLength (yyy0
->yyrule
);
1453 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1457 else if (yys0
->yyresolved
)
1459 yys1
->yyresolved
= yytrue
;
1460 yys1
->yysemantics
.yysval
= yys0
->yysemantics
.yysval
;
1462 else if (yys1
->yyresolved
)
1464 yys0
->yyresolved
= yytrue
;
1465 yys0
->yysemantics
.yysval
= yys1
->yysemantics
.yysval
;
1469 yySemanticOption
** yyz0p
;
1470 yySemanticOption
* yyz1
;
1471 yyz0p
= &yys0
->yysemantics
.yyfirstVal
;
1472 yyz1
= yys1
->yysemantics
.yyfirstVal
;
1475 if (yyz1
== *yyz0p
|| yyz1
== NULL
)
1477 else if (*yyz0p
== NULL
)
1482 else if (*yyz0p
< yyz1
)
1484 yySemanticOption
* yyz
= *yyz0p
;
1486 yyz1
= yyz1
->yynext
;
1487 (*yyz0p
)->yynext
= yyz
;
1489 yyz0p
= &(*yyz0p
)->yynext
;
1491 yys1
->yysemantics
.yyfirstVal
= yys0
->yysemantics
.yyfirstVal
;
1496 /** Y0 and Y1 represent two possible actions to take in a given
1497 * parsing state; return 0 if no combination is possible,
1498 * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
1500 yypreference (yySemanticOption
* y0
, yySemanticOption
* y1
)
1502 yyRuleNum r0
= y0
->yyrule
, r1
= y1
->yyrule
;
1503 int p0
= yydprec
[r0
], p1
= yydprec
[r1
];
1507 if (yymerger
[r0
] == 0 || yymerger
[r0
] != yymerger
[r1
])
1512 if (p0
== 0 || p1
== 0)
1521 static YYRESULTTAG
yyresolveValue (yySemanticOption
* yyoptionList
,
1522 yyGLRStack
* yystack
, YYSTYPE
* yyvalp
,
1523 YYLTYPE
* yylocp
]b4_user_formals
[);
1526 yyresolveStates (yyGLRState
* yys
, int yyn
, yyGLRStack
* yystack
]b4_user_formals
[)
1531 YYASSERT (yys
->yypred
);
1532 yyflag
= yyresolveStates (yys
->yypred
, yyn
-1, yystack
]b4_user_args
[);
1535 if (! yys
->yyresolved
)
1537 yyflag
= yyresolveValue (yys
->yysemantics
.yyfirstVal
, yystack
,
1538 &yys
->yysemantics
.yysval
, &yys
->yyloc
1542 yys
->yyresolved
= yytrue
;
1549 yyresolveAction (yySemanticOption
* yyopt
, yyGLRStack
* yystack
,
1550 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1552 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1555 yynrhs
= yyrhsLength (yyopt
->yyrule
);
1556 YYCHK (yyresolveStates (yyopt
->yystate
, yynrhs
, yystack
]b4_user_args
[));
1557 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
= yyopt
->yystate
;
1558 return yyuserAction (yyopt
->yyrule
, yynrhs
,
1559 yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1560 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1565 yyreportTree (yySemanticOption
* yyx
, int yyindent
)
1567 int yynrhs
= yyrhsLength (yyx
->yyrule
);
1570 yyGLRState
* yystates
[YYMAXRHS
];
1571 yyGLRState yyleftmost_state
;
1573 for (yyi
= yynrhs
, yys
= yyx
->yystate
; 0 < yyi
; yyi
-= 1, yys
= yys
->yypred
)
1574 yystates
[yyi
] = yys
;
1577 yyleftmost_state
.yyposn
= 0;
1578 yystates
[0] = &yyleftmost_state
;
1583 if (yyx
->yystate
->yyposn
< yys
->yyposn
+ 1)
1584 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, empty>\n",
1585 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1588 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
1589 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1590 yyx
->yyrule
, (unsigned long int) (yys
->yyposn
+ 1),
1591 (unsigned long int) yyx
->yystate
->yyposn
);
1592 for (yyi
= 1; yyi
<= yynrhs
; yyi
+= 1)
1594 if (yystates
[yyi
]->yyresolved
)
1596 if (yystates
[yyi
-1]->yyposn
+1 > yystates
[yyi
]->yyposn
)
1597 YYFPRINTF (stderr
, "%*s%s <empty>\n", yyindent
+2, "",
1598 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]));
1600 YYFPRINTF (stderr
, "%*s%s <tokens %lu .. %lu>\n", yyindent
+2, "",
1601 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]),
1602 (unsigned long int) (yystates
[yyi
- 1]->yyposn
+ 1),
1603 (unsigned long int) yystates
[yyi
]->yyposn
);
1606 yyreportTree (yystates
[yyi
]->yysemantics
.yyfirstVal
, yyindent
+2);
1611 static void yyreportAmbiguity (yySemanticOption
* yyx0
, yySemanticOption
* yyx1
,
1612 yyGLRStack
* yystack
]b4_pure_formals
[)
1613 __attribute__ ((__noreturn__
));
1615 yyreportAmbiguity (yySemanticOption
* yyx0
, yySemanticOption
* yyx1
,
1616 yyGLRStack
* yystack
]b4_pure_formals
[)
1618 /* `Unused' warnings. */
1623 YYFPRINTF (stderr
, "Ambiguity detected.\n");
1624 YYFPRINTF (stderr
, "Option 1,\n");
1625 yyreportTree (yyx0
, 2);
1626 YYFPRINTF (stderr
, "\nOption 2,\n");
1627 yyreportTree (yyx1
, 2);
1628 YYFPRINTF (stderr
, "\n");
1630 yyFail (yystack
][]b4_pure_args
[, YY_("syntax is ambiguous"));
1634 /** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
1635 * actions, and return the result. */
1637 yyresolveValue (yySemanticOption
* yyoptionList
, yyGLRStack
* yystack
,
1638 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1640 yySemanticOption
* yybest
;
1641 yySemanticOption
** yypp
;
1644 yybest
= yyoptionList
;
1646 for (yypp
= &yyoptionList
->yynext
; *yypp
!= NULL
; )
1648 yySemanticOption
* yyp
= *yypp
;
1650 if (yyidenticalOptions (yybest
, yyp
))
1652 yymergeOptionSets (yybest
, yyp
);
1653 *yypp
= yyp
->yynext
;
1657 switch (yypreference (yybest
, yyp
))
1660 yyreportAmbiguity (yybest
, yyp
, yystack
]b4_pure_args
[);
1672 yypp
= &yyp
->yynext
;
1678 yySemanticOption
* yyp
;
1679 int yyprec
= yydprec
[yybest
->yyrule
];
1680 YYCHK (yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[));
1681 for (yyp
= yybest
->yynext
; yyp
!= NULL
; yyp
= yyp
->yynext
)
1683 if (yyprec
== yydprec
[yyp
->yyrule
])
1687 YYCHK (yyresolveAction (yyp
, yystack
, &yyval1
, &yydummy
]b4_user_args
[));
1688 yyuserMerge (yymerger
[yyp
->yyrule
], yyvalp
, &yyval1
);
1694 return yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[);
1698 yyresolveStack (yyGLRStack
* yystack
]b4_user_formals
[)
1700 if (yystack
->yysplitPoint
!= NULL
)
1705 for (yyn
= 0, yys
= yystack
->yytops
.yystates
[0];
1706 yys
!= yystack
->yysplitPoint
;
1707 yys
= yys
->yypred
, yyn
+= 1)
1709 YYCHK (yyresolveStates (yystack
->yytops
.yystates
[0], yyn
, yystack
1716 yycompressStack (yyGLRStack
* yystack
)
1718 yyGLRState
* yyp
, *yyq
, *yyr
;
1720 if (yystack
->yytops
.yysize
!= 1 || yystack
->yysplitPoint
== NULL
)
1723 for (yyp
= yystack
->yytops
.yystates
[0], yyq
= yyp
->yypred
, yyr
= NULL
;
1724 yyp
!= yystack
->yysplitPoint
;
1725 yyr
= yyp
, yyp
= yyq
, yyq
= yyp
->yypred
)
1728 yystack
->yyspaceLeft
+= yystack
->yynextFree
- yystack
->yyitems
;
1729 yystack
->yynextFree
= ((yyGLRStackItem
*) yystack
->yysplitPoint
) + 1;
1730 yystack
->yyspaceLeft
-= yystack
->yynextFree
- yystack
->yyitems
;
1731 yystack
->yysplitPoint
= NULL
;
1732 yystack
->yylastDeleted
= NULL
;
1736 yystack
->yynextFree
->yystate
= *yyr
;
1738 yystack
->yynextFree
->yystate
.yypred
= & yystack
->yynextFree
[-1].yystate
;
1739 yystack
->yytops
.yystates
[0] = &yystack
->yynextFree
->yystate
;
1740 yystack
->yynextFree
+= 1;
1741 yystack
->yyspaceLeft
-= 1;
1746 yyprocessOneStack (yyGLRStack
* yystack
, size_t yyk
,
1747 size_t yyposn
, YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
1751 const short int* yyconflicts
;
1753 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1755 while (yystack
->yytops
.yystates
[yyk
] != NULL
)
1757 yyStateNum yystate
= yystack
->yytops
.yystates
[yyk
]->yylrState
;
1758 YYDPRINTF ((stderr
, "Stack %lu Entering state %d\n",
1759 (unsigned long int) yyk
, yystate
));
1761 YYASSERT (yystate
!= YYFINAL
);
1763 if (yyisDefaultedState (yystate
))
1765 yyrule
= yydefaultAction (yystate
);
1768 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1769 (unsigned long int) yyk
));
1770 yymarkStackDeleted (yystack
, yyk
);
1773 YYCHK (yyglrReduce (yystack
, yyk
, yyrule
, yyfalse
]b4_user_args
[));
1777 if (*yytokenp
== YYEMPTY
)
1779 YYDPRINTF ((stderr
, "Reading a token: "));
1781 *yytokenp
= YYTRANSLATE (yychar
);
1782 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1784 yygetLRActions (yystate
, *yytokenp
, &yyaction
, &yyconflicts
);
1786 while (*yyconflicts
!= 0)
1788 size_t yynewStack
= yysplitStack (yystack
, yyk
);
1789 YYDPRINTF ((stderr
, "Splitting off stack %lu from %lu.\n",
1790 (unsigned long int) yynewStack
,
1791 (unsigned long int) yyk
));
1792 YYCHK (yyglrReduce (yystack
, yynewStack
,
1793 *yyconflicts
, yyfalse
]b4_user_args
[));
1794 YYCHK (yyprocessOneStack (yystack
, yynewStack
, yyposn
,
1795 yylvalp
, yyllocp
]b4_pure_args
[));
1799 if (yyisShiftAction (yyaction
))
1801 YYDPRINTF ((stderr
, "On stack %lu, ", (unsigned long int) yyk
));
1802 YY_SYMBOL_PRINT ("shifting", *yytokenp
, yylvalp
, yyllocp
);
1803 yyglrShift (yystack
, yyk
, yyaction
, yyposn
+1,
1805 YYDPRINTF ((stderr
, "Stack %lu now in state #%d\n",
1806 (unsigned long int) yyk
,
1807 yystack
->yytops
.yystates
[yyk
]->yylrState
));
1810 else if (yyisErrorAction (yyaction
))
1812 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1813 (unsigned long int) yyk
));
1814 yymarkStackDeleted (yystack
, yyk
);
1818 YYCHK (yyglrReduce (yystack
, yyk
, -yyaction
, yyfalse
]b4_user_args
[));
1825 yyreportSyntaxError (yyGLRStack
* yystack
,
1826 YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
]b4_user_formals
[)
1828 /* `Unused' warnings. */
1832 if (yystack
->yyerrState
== 0)
1835 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1837 yyn
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1838 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1840 size_t yysize0
= yytnamerr (NULL
, yytokenName (*yytokenp
));
1841 size_t yysize
= yysize0
;
1843 yybool yysize_overflow
= yyfalse
;
1845 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1846 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1850 static char const yyunexpected
[] = "syntax error, unexpected %s";
1851 static char const yyexpecting
[] = ", expecting %s";
1852 static char const yyor
[] = " or %s";
1853 char yyformat
[sizeof yyunexpected
1854 + sizeof yyexpecting
- 1
1855 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1856 * (sizeof yyor
- 1))];
1857 char const *yyprefix
= yyexpecting
;
1859 /* Start YYX at -YYN if negative to avoid negative indexes in
1861 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1863 /* Stay within bounds of both yycheck and yytname. */
1864 int yychecklim
= YYLAST
- yyn
;
1865 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1868 yyarg
[0] = yytokenName (*yytokenp
);
1869 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1871 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1872 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1874 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1878 yyformat
[sizeof yyunexpected
- 1] = '\0';
1881 yyarg
[yycount
++] = yytokenName (yyx
);
1882 yysize1
= yysize
+ yytnamerr (NULL
, yytokenName (yyx
));
1883 yysize_overflow
|= yysize1
< yysize
;
1885 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1889 yyf
= YY_(yyformat
);
1890 yysize1
= yysize
+ strlen (yyf
);
1891 yysize_overflow
|= yysize1
< yysize
;
1894 if (!yysize_overflow
)
1895 yymsg
= (char *) YYMALLOC (yysize
);
1901 while ((*yyp
= *yyf
))
1903 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1905 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1914 yyerror (]b4_lyyerror_args
[yymsg
);
1919 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1920 yyMemoryExhausted (yystack
);
1924 #endif /* YYERROR_VERBOSE */
1925 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1930 /* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
1931 YYLVALP, and YYLLOCP point to the syntactic category, semantic
1932 value, and location of the look-ahead. */
1934 yyrecoverSyntaxError (yyGLRStack
* yystack
,
1936 YYLTYPE
* YYOPTIONAL_LOC (yyllocp
)
1939 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1943 if (yystack
->yyerrState
== 3)
1944 /* We just shifted the error token and (perhaps) took some
1945 reductions. Skip tokens until we can proceed. */
1948 if (*yytokenp
== YYEOF
)
1949 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1950 if (*yytokenp
!= YYEMPTY
)
1952 /* We throw away the lookahead, but the error range
1953 of the shifted error token must take it into account. */
1954 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
1955 yyGLRStackItem yyerror_range
[3];
1956 yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;
1957 yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
1958 YYLLOC_DEFAULT (yys
->yyloc
, yyerror_range
, 2);]])[
1959 yydestruct ("Error: discarding",
1960 *yytokenp
, yylvalp
]b4_location_if([, yyllocp
])[);
1962 YYDPRINTF ((stderr
, "Reading a token: "));
1964 *yytokenp
= YYTRANSLATE (yychar
);
1965 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1966 yyj
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1967 if (yyis_pact_ninf (yyj
))
1970 if (yyj
< 0 || YYLAST
< yyj
|| yycheck
[yyj
] != *yytokenp
)
1972 if (yydefact
[yystack
->yytops
.yystates
[0]->yylrState
] != 0)
1975 else if (yytable
[yyj
] != 0 && ! yyis_table_ninf (yytable
[yyj
]))
1979 /* Reduce to one stack. */
1980 for (yyk
= 0; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
1981 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1983 if (yyk
>= yystack
->yytops
.yysize
)
1984 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1985 for (yyk
+= 1; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
1986 yymarkStackDeleted (yystack
, yyk
);
1987 yyremoveDeletes (yystack
);
1988 yycompressStack (yystack
);
1990 /* Now pop stack until we find a state that shifts the error token. */
1991 yystack
->yyerrState
= 3;
1992 while (yystack
->yytops
.yystates
[0] != NULL
)
1994 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
1995 yyj
= yypact
[yys
->yylrState
];
1996 if (! yyis_pact_ninf (yyj
))
1999 if (0 <= yyj
&& yyj
<= YYLAST
&& yycheck
[yyj
] == YYTERROR
2000 && yyisShiftAction (yytable
[yyj
]))
2002 /* Shift the error token having adjusted its location. */
2003 YYLTYPE yyerrloc
;]b4_location_if([[
2004 yystack
->yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
2005 YYLLOC_DEFAULT (yyerrloc
, yystack
->yyerror_range
, 2);]])[
2006 YY_SYMBOL_PRINT ("Shifting", yystos
[yytable
[yyj
]],
2007 yylvalp
, &yyerrloc
);
2008 yyglrShift (yystack
, 0, yytable
[yyj
],
2009 yys
->yyposn
, *yylvalp
, &yyerrloc
);
2010 yys
= yystack
->yytops
.yystates
[0];
2014 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]])[
2015 yydestroyGLRState ("Error: popping", yys
);
2016 yystack
->yytops
.yystates
[0] = yys
->yypred
;
2017 yystack
->yynextFree
-= 1;
2018 yystack
->yyspaceLeft
+= 1;
2020 if (yystack
->yytops
.yystates
[0] == NULL
)
2021 yyFail (yystack
][]b4_lpure_args
[, NULL
);
2024 #define YYCHK1(YYE) \
2034 goto yyuser_error; \
2043 ]b4_c_ansi_function_def([yyparse
], [int], b4_parse_param
)[
2054 #define yychar (yystack.yyrawchar)
2057 YYSTYPE
* const yylvalp
= &yylval
;
2058 YYLTYPE
* const yyllocp
= &yylloc
;
2060 YYDPRINTF ((stderr
, "Starting parse\n"));
2063 yylval
= yyval_default
;
2065 #if YYLTYPE_IS_TRIVIAL
2066 yylloc
.first_line
= yylloc
.last_line
= 1;
2067 yylloc
.first_column
= yylloc
.last_column
= 0;
2070 m4_ifdef([b4_initial_action
], [
2071 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
2072 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
2073 /* User initialization code. */
2075 m4_popdef([b4_dollar_dollar
])dnl
2076 m4_popdef([b4_at_dollar
])dnl
2077 /* Line __line__ of glr.c. */
2078 b4_syncline([@oline@
], [@ofile@
])])dnl
2080 if (! yyinitGLRStack (&yystack
, YYINITDEPTH
))
2081 goto yyexhaustedlab
;
2082 switch (setjmp (yystack
.yyexception_buffer
))
2084 case 1: goto yyabortlab
;
2085 case 2: goto yyexhaustedlab
;
2087 yystack
.yytokenp
= &yytoken
;
2088 yyglrShift (&yystack
, 0, 0, 0, yylval
, &yylloc
);
2093 /* For efficiency, we have two loops, the first of which is
2094 specialized to deterministic operation (single stack, no
2095 potential ambiguity). */
2101 const short int* yyconflicts
;
2103 yyStateNum yystate
= yystack
.yytops
.yystates
[0]->yylrState
;
2104 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
2105 if (yystate
== YYFINAL
)
2107 if (yyisDefaultedState (yystate
))
2109 yyrule
= yydefaultAction (yystate
);
2112 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2113 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2116 YYCHK1 (yyglrReduce (&yystack
, 0, yyrule
, yytrue
]b4_user_args
[));
2120 if (yytoken
== YYEMPTY
)
2122 YYDPRINTF ((stderr
, "Reading a token: "));
2124 yytoken
= YYTRANSLATE (yychar
);
2125 YY_SYMBOL_PRINT ("Next token is", yytoken
, yylvalp
, yyllocp
);
2127 yygetLRActions (yystate
, yytoken
, &yyaction
, &yyconflicts
);
2128 if (*yyconflicts
!= 0)
2130 if (yyisShiftAction (yyaction
))
2132 YY_SYMBOL_PRINT ("Shifting", yytoken
, yylvalp
, yyllocp
);
2133 if (yytoken
!= YYEOF
)
2136 yyglrShift (&yystack
, 0, yyaction
, yyposn
, yylval
, yyllocp
);
2137 if (0 < yystack
.yyerrState
)
2138 yystack
.yyerrState
-= 1;
2140 else if (yyisErrorAction (yyaction
))
2142 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2143 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2147 YYCHK1 (yyglrReduce (&yystack
, 0, -yyaction
, yytrue
]b4_user_args
[));
2154 size_t yyn
= yystack
.yytops
.yysize
;
2155 for (yys
= 0; yys
< yyn
; yys
+= 1)
2156 YYCHK1 (yyprocessOneStack (&yystack
, yys
, yyposn
,
2157 yylvalp
, yyllocp
]b4_lpure_args
[));
2160 yyremoveDeletes (&yystack
);
2161 if (yystack
.yytops
.yysize
== 0)
2163 yyundeleteLastStack (&yystack
);
2164 if (yystack
.yytops
.yysize
== 0)
2165 yyFail (&yystack
][]b4_lpure_args
[, YY_("syntax error"));
2166 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2167 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2168 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2169 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2172 else if (yystack
.yytops
.yysize
== 1)
2174 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2175 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2176 yycompressStack (&yystack
);
2182 yyrecoverSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2183 yyposn
= yystack
.yytops
.yystates
[0]->yyposn
;
2195 yyerror (]b4_lyyerror_args
[YY_("memory exhausted"));
2200 if (yytoken
!= YYEOF
&& yytoken
!= YYEMPTY
)
2201 yydestruct ("Cleanup: discarding lookahead",
2202 yytoken
, yylvalp
]b4_location_if([, yyllocp
])[);
2204 /* If the stack is well-formed, pop the stack until it is empty,
2205 destroying its entries as we go. But free the stack regardless
2206 of whether it is well-formed. */
2207 if (yystack
.yyitems
)
2209 yyGLRState
** yystates
= yystack
.yytops
.yystates
;
2213 yyGLRState
*yys
= yystates
[0];
2214 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]]
2215 )[ yydestroyGLRState ("Cleanup: popping", yys
);
2216 yystates
[0] = yys
->yypred
;
2217 yystack
.yynextFree
-= 1;
2218 yystack
.yyspaceLeft
+= 1;
2220 yyfreeGLRStack (&yystack
);
2226 /* DEBUGGING ONLY */
2228 static void yypstack (yyGLRStack
* yystack
, size_t yyk
)
2229 __attribute__ ((__unused__
));
2230 static void yypdumpstack (yyGLRStack
* yystack
) __attribute__ ((__unused__
));
2233 yy_yypstack (yyGLRState
* yys
)
2237 yy_yypstack (yys
->yypred
);
2238 fprintf (stderr
, " -> ");
2240 fprintf (stderr
, "%d@@%lu", yys
->yylrState
, (unsigned long int) yys
->yyposn
);
2244 yypstates (yyGLRState
* yyst
)
2247 fprintf (stderr
, "<null>");
2250 fprintf (stderr
, "\n");
2254 yypstack (yyGLRStack
* yystack
, size_t yyk
)
2256 yypstates (yystack
->yytops
.yystates
[yyk
]);
2259 #define YYINDEX(YYX) \
2260 ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
2264 yypdumpstack (yyGLRStack
* yystack
)
2266 yyGLRStackItem
* yyp
;
2268 for (yyp
= yystack
->yyitems
; yyp
< yystack
->yynextFree
; yyp
+= 1)
2270 fprintf (stderr
, "%3lu. ", (unsigned long int) (yyp
- yystack
->yyitems
));
2271 if (*(yybool
*) yyp
)
2273 fprintf (stderr
, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
2274 yyp
->yystate
.yyresolved
, yyp
->yystate
.yylrState
,
2275 (unsigned long int) yyp
->yystate
.yyposn
,
2276 (long int) YYINDEX (yyp
->yystate
.yypred
));
2277 if (! yyp
->yystate
.yyresolved
)
2278 fprintf (stderr
, ", firstVal: %ld",
2279 (long int) YYINDEX (yyp
->yystate
.yysemantics
.yyfirstVal
));
2283 fprintf (stderr
, "Option. rule: %d, state: %ld, next: %ld",
2284 yyp
->yyoption
.yyrule
,
2285 (long int) YYINDEX (yyp
->yyoption
.yystate
),
2286 (long int) YYINDEX (yyp
->yyoption
.yynext
));
2288 fprintf (stderr
, "\n");
2290 fprintf (stderr
, "Tops:");
2291 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
2292 fprintf (stderr
, "%lu: %ld; ", (unsigned long int) yyi
,
2293 (long int) YYINDEX (yystack
->yytops
.yystates
[yyi
]));
2294 fprintf (stderr
, "\n");
2300 m4_if(b4_defines_flag
, 0, [],
2301 [@output @output_header_name@
2302 b4_copyright([Skeleton parser
for GLR parsing with Bison
],
2303 [2002, 2003, 2004, 2005])
2305 b4_token_defines(b4_tokens
)
2307 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
2308 m4_ifdef([b4_stype
],
2309 [b4_syncline([b4_stype_line
], [b4_filename
])
2310 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
2311 /* Line __line__ of glr.c. */
2312 b4_syncline([@oline@
], [@ofile@
])],
2313 [typedef int YYSTYPE
;])
2314 # define YYSTYPE_IS_DECLARED 1
2315 # define YYSTYPE_IS_TRIVIAL 1
2319 [extern YYSTYPE b4_prefix
[]lval
;])
2321 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
2322 typedef struct YYLTYPE
2333 # define YYLTYPE_IS_DECLARED 1
2334 # define YYLTYPE_IS_TRIVIAL 1
2337 b4_location_if([b4_pure_if([],
2338 [extern YYLTYPE b4_prefix
[]lloc
;])