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_enums(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_file_name
])
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@
])
228 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
229 # define YY_(msgid) dgettext ("bison-runtime", msgid)
233 # define YY_(msgid) msgid
237 /* Suppress unused-variable warnings by "using" E. */
238 #define YYUSE(e) do {;} while (/*CONSTCOND*/ yyfalse && (e))
244 # define YYMALLOC malloc
247 # define YYREALLOC realloc
250 #define YYSIZEMAX ((size_t) -1)
255 typedef unsigned char yybool
;
262 # define YYJMP_BUF jmp_buf
263 # define YYSETJMP(env) setjmp (env)
264 # define YYLONGJMP(env, val) longjmp (env, val)
271 #ifndef __attribute__
272 /* This feature is available in gcc versions 2.5 and later. */
273 # if (!defined (__GNUC__) || __GNUC__ < 2 \
274 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
275 # define __attribute__(Spec) /* empty */
279 ]b4_location_if([#define YYOPTIONAL_LOC(Name) Name],[
281 # define YYOPTIONAL_LOC(Name) /* empty */
283 # define YYOPTIONAL_LOC(Name) Name __attribute__ ((__unused__))
287 # define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
290 /* YYFINAL -- State number of the termination state. */
291 #define YYFINAL ]b4_final_state_number[
292 /* YYLAST -- Last index in YYTABLE. */
293 #define YYLAST ]b4_last[
295 /* YYNTOKENS -- Number of terminals. */
296 #define YYNTOKENS ]b4_tokens_number[
297 /* YYNNTS -- Number of nonterminals. */
298 #define YYNNTS ]b4_nterms_number[
299 /* YYNRULES -- Number of rules. */
300 #define YYNRULES ]b4_rules_number[
301 /* YYNRULES -- Number of states. */
302 #define YYNSTATES ]b4_states_number[
303 /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
304 #define YYMAXRHS ]b4_r2_max[
305 /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
306 accessed by $0, $-1, etc., in any rule. */
307 #define YYMAXLEFT ]b4_max_left_semantic_context[
309 /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
310 #define YYUNDEFTOK ]b4_undef_token_number[
311 #define YYMAXUTOK ]b4_user_token_number_max[
313 #define YYTRANSLATE(YYX) \
314 ((YYX <= 0) ? YYEOF : \
315 (unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
317 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
318 static const ]b4_int_type_for([b4_translate
])[ yytranslate
[] =
324 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
326 static const ]b4_int_type_for([b4_prhs
])[ yyprhs
[] =
331 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
332 static const ]b4_int_type_for([b4_rhs
])[ yyrhs
[] =
337 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
338 static const ]b4_int_type_for([b4_rline
])[ yyrline
[] =
344 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
345 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
346 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
347 static const char *const yytname
[] =
353 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
354 static const ]b4_int_type_for([b4_r1
])[ yyr1
[] =
359 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
360 static const ]b4_int_type_for([b4_r2
])[ yyr2
[] =
365 /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
366 static const ]b4_int_type_for([b4_dprec
])[ yydprec
[] =
371 /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
372 static const ]b4_int_type_for([b4_merger
])[ yymerger
[] =
377 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
378 doesn't specify something else to do. Zero means the default is an
380 static const ]b4_int_type_for([b4_defact
])[ yydefact
[] =
385 /* YYPDEFGOTO[NTERM-NUM]. */
386 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto
[] =
391 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
393 #define YYPACT_NINF ]b4_pact_ninf[
394 static const ]b4_int_type_for([b4_pact
])[ yypact
[] =
399 /* YYPGOTO[NTERM-NUM]. */
400 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto
[] =
405 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
406 positive, shift that token. If negative, reduce the rule which
407 number is the opposite. If zero, do what YYDEFACT says.
408 If YYTABLE_NINF, syntax error. */
409 #define YYTABLE_NINF ]b4_table_ninf[
410 static const ]b4_int_type_for([b4_table
])[ yytable
[] =
415 /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
416 list of conflicting reductions corresponding to action entry for
417 state STATE-NUM in yytable. 0 means no conflicts. The list in
418 yyconfl is terminated by a rule number of 0. */
419 static const ]b4_int_type_for([b4_conflict_list_heads
])[ yyconflp
[] =
421 ]b4_conflict_list_heads
[
424 /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
425 0, pointed into by YYCONFLP. */
426 ]dnl Do
not use b4_int_type_for here
, since there are places where
427 dnl pointers onto yyconfl are taken
, which type is
"short int *".
428 dnl We probably ought to introduce a type
for confl
.
429 [static const short int yyconfl
[] =
431 ]b4_conflicting_rules
[
434 static const ]b4_int_type_for([b4_check
])[ yycheck
[] =
439 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
440 symbol of state STATE-NUM. */
441 static const ]b4_int_type_for([b4_stos
])[ yystos
[] =
447 /* Prevent warning if -Wmissing-prototypes. */
448 ]b4_c_ansi_function_decl([yyparse
], [int], b4_parse_param
)[
450 /* Error token number */
453 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
454 If N is 0, then set CURRENT to the empty location which ends
455 the previous symbol: RHS[0] (always defined). */
458 #define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
459 #ifndef YYLLOC_DEFAULT
460 # define YYLLOC_DEFAULT(Current, Rhs, N) \
464 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
465 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
466 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
467 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
471 (Current).first_line = (Current).last_line = \
472 YYRHSLOC (Rhs, 0).last_line; \
473 (Current).first_column = (Current).last_column = \
474 YYRHSLOC (Rhs, 0).last_column; \
476 while (/*CONSTCOND*/ 0)
478 /* YY_LOCATION_PRINT -- Print the location on the stream.
479 This macro was not mandated originally: define only if we know
480 we won't break user code: when these are the locations we know. */
482 # define YY_LOCATION_PRINT(File, Loc) \
483 fprintf (File, "%d.%d-%d.%d", \
484 (Loc).first_line, (Loc).first_column, \
485 (Loc).last_line, (Loc).last_column)
488 #ifndef YYLLOC_DEFAULT
489 # define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)
493 #ifndef YY_LOCATION_PRINT
494 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
498 /* YYLEX -- calling `yylex' with the right arguments. */
499 #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
504 #define yynerrs (yystack->yyerrcnt)
506 #define yychar (yystack->yyrawchar)],
514 static const int YYEOF
= 0;
515 static const int YYEMPTY
= -2;
517 typedef enum { yyok
, yyaccept
, yyabort
, yyerr
} YYRESULTTAG
;
520 do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
521 while (/*CONSTCOND*/ 0)
525 #if ! defined (YYFPRINTF)
526 # define YYFPRINTF fprintf
529 # define YYDPRINTF(Args) \
533 } while (/*CONSTCOND*/ 0)
535 ]b4_yysymprint_generate([b4_c_ansi_function_def
])[
537 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
541 YYFPRINTF (stderr, "%s ", Title); \
542 yysymprint (stderr, \
543 Type, Value]b4_location_if([, Location])[); \
544 YYFPRINTF (stderr, "\n"); \
546 } while (/*CONSTCOND*/ 0)
548 /* Nonzero means print parse trace. It is left uninitialized so that
549 multiple parsers can coexist. */
554 # define YYDPRINTF(Args)
555 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
557 #endif /* !YYDEBUG */
559 /* YYINITDEPTH -- initial size of the parser's stacks. */
561 # define YYINITDEPTH ]b4_stack_depth_init[
564 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
565 if the built-in stack extension method is used).
567 Do not make this value too large; the results are undefined if
568 SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
569 evaluated with infinite-precision integer arithmetic. */
572 # define YYMAXDEPTH ]b4_stack_depth_max[
575 /* Minimum number of free items on the stack allowed after an
576 allocation. This is to allow allocation and initialization
577 to be completed by functions that call yyexpandGLRStack before the
578 stack is expanded, thus insuring that all necessary pointers get
579 properly redirected to new data. */
582 #ifndef YYSTACKEXPANDABLE
583 # if (! defined (__cplusplus) \
584 || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \
585 && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))
586 # define YYSTACKEXPANDABLE 1
588 # define YYSTACKEXPANDABLE 0
595 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
596 # define yystpcpy stpcpy
598 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
601 yystpcpy (char *yydest
, const char *yysrc
)
604 const char *yys
= yysrc
;
606 while ((*yyd
++ = *yys
++) != '\0')
615 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
616 quotes and backslashes, so that it's suitable for yyerror. The
617 heuristic is that double-quoting is unnecessary unless the string
618 contains an apostrophe, a comma, or backslash (other than
619 backslash-backslash). YYSTR is taken from yytname. If YYRES is
620 null, do not copy; instead, return the length of what the result
623 yytnamerr (char *yyres
, const char *yystr
)
628 char const *yyp
= yystr
;
635 goto do_not_strip_quotes
;
639 goto do_not_strip_quotes
;
652 do_not_strip_quotes
: ;
656 return strlen (yystr
);
658 return yystpcpy (yyres
, yystr
) - yyres
;
662 #endif /* !YYERROR_VERBOSE */
664 /** State numbers, as in LALR(1) machine */
665 typedef int yyStateNum
;
667 /** Rule numbers, as in LALR(1) machine */
668 typedef int yyRuleNum
;
670 /** Grammar symbol */
671 typedef short int yySymbol
;
673 /** Item references, as in LALR(1) machine */
674 typedef short int yyItemNum
;
676 typedef struct yyGLRState yyGLRState
;
677 typedef struct yySemanticOption yySemanticOption
;
678 typedef union yyGLRStackItem yyGLRStackItem
;
679 typedef struct yyGLRStack yyGLRStack
;
680 typedef struct yyGLRStateSet yyGLRStateSet
;
683 /** Type tag: always true. */
685 /** Type tag for yysemantics. If true, yysval applies, otherwise
686 * yyfirstVal applies. */
688 /** Number of corresponding LALR(1) machine state. */
689 yyStateNum yylrState
;
690 /** Preceding state in this stack */
692 /** Source position of the first token produced by my symbol */
695 /** First in a chain of alternative reductions producing the
696 * non-terminal corresponding to this state, threaded through
698 yySemanticOption
* yyfirstVal
;
699 /** Semantic value for this state. */
702 /** Source location for this state. */
706 struct yyGLRStateSet
{
707 yyGLRState
** yystates
;
708 size_t yysize
, yycapacity
;
711 struct yySemanticOption
{
712 /** Type tag: always false. */
714 /** Rule number for this reduction */
716 /** The last RHS state in the list of states to be reduced. */
718 /** Next sibling in chain of options. To facilitate merging,
719 * options are chained in decreasing order by address. */
720 yySemanticOption
* yynext
;
723 /** Type of the items in the GLR stack. The yyisState field
724 * indicates which item of the union is valid. */
725 union yyGLRStackItem
{
727 yySemanticOption yyoption
;
732 ]b4_location_if([[ /* To compute the location of the error token. */
733 yyGLRStackItem yyerror_range
[3];]])[
740 YYJMP_BUF yyexception_buffer
;
741 yyGLRStackItem
* yyitems
;
742 yyGLRStackItem
* yynextFree
;
744 yyGLRState
* yysplitPoint
;
745 yyGLRState
* yylastDeleted
;
746 yyGLRStateSet yytops
;
749 static void yyexpandGLRStack (yyGLRStack
* yystack
);
751 static void yyFail (yyGLRStack
* yystack
]b4_pure_formals
[, const char* yymsg
)
752 __attribute__ ((__noreturn__
));
754 yyFail (yyGLRStack
* yystack
]b4_pure_formals
[, const char* yymsg
)
757 yyerror (]b4_yyerror_args
[yymsg
);
758 YYLONGJMP (yystack
->yyexception_buffer
, 1);
761 static void yyMemoryExhausted (yyGLRStack
* yystack
)
762 __attribute__ ((__noreturn__
));
764 yyMemoryExhausted (yyGLRStack
* yystack
)
766 YYLONGJMP (yystack
->yyexception_buffer
, 2);
769 #if YYDEBUG || YYERROR_VERBOSE
770 /** A printable representation of TOKEN. */
771 static inline const char*
772 yytokenName (yySymbol yytoken
)
774 if (yytoken
== YYEMPTY
)
777 return yytname
[yytoken
];
781 /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
782 * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
783 * containing the pointer to the next state in the chain. Assumes
784 * YYLOW1 < YYLOW0. */
785 static void yyfillin (yyGLRStackItem
*, int, int) __attribute__ ((__unused__
));
787 yyfillin (yyGLRStackItem
*yyvsp
, int yylow0
, int yylow1
)
791 s
= yyvsp
[yylow0
].yystate
.yypred
;
792 for (i
= yylow0
-1; i
>= yylow1
; i
-= 1)
794 YYASSERT (s
->yyresolved
);
795 yyvsp
[i
].yystate
.yyresolved
= yytrue
;
796 yyvsp
[i
].yystate
.yysemantics
.yysval
= s
->yysemantics
.yysval
;
797 yyvsp
[i
].yystate
.yyloc
= s
->yyloc
;
798 s
= yyvsp
[i
].yystate
.yypred
= s
->yypred
;
802 /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
803 YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
804 For convenience, always return YYLOW1. */
805 static inline int yyfill (yyGLRStackItem
*, int *, int, yybool
)
806 __attribute__ ((__unused__
));
808 yyfill (yyGLRStackItem
*yyvsp
, int *yylow
, int yylow1
, yybool yynormal
)
810 if (!yynormal
&& yylow1
< *yylow
)
812 yyfillin (yyvsp
, *yylow
, yylow1
);
818 /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
819 * and top stack item YYVSP. YYLVALP points to place to put semantic
820 * value ($$), and yylocp points to place for location information
821 * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
822 * yyerr for YYERROR, yyabort for YYABORT. */
824 yyuserAction (yyRuleNum yyn
, int yyrhslen
, yyGLRStackItem
* yyvsp
,
826 YYLTYPE
* YYOPTIONAL_LOC (yylocp
),
830 yybool yynormal
__attribute__ ((__unused__
)) =
831 (yystack
->yysplitPoint
== NULL
);
835 # define yyerrok (yystack->yyerrState = 0)
837 # define YYACCEPT return yyaccept
839 # define YYABORT return yyabort
841 # define YYERROR return yyerrok, yyerr
843 # define YYRECOVERING (yystack->yyerrState != 0)
845 # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)
847 # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
849 # define YYBACKUP(Token, Value) \
850 return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
855 *yyvalp
= yyval_default
;
857 *yyvalp
= yyvsp
[YYFILL (1-yyrhslen
)].yystate
.yysemantics
.yysval
;
858 YYLLOC_DEFAULT (*yylocp
, yyvsp
- yyrhslen
, yyrhslen
);
859 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= *yylocp
;
875 /* Line __line__ of glr.c. */
876 b4_syncline([@oline@
], [@ofile@
])
881 yyuserMerge (int yyn
, YYSTYPE
* yy0
, YYSTYPE
* yy1
)
893 /* Bison grammar-table manipulation. */
895 ]b4_yydestruct_generate([b4_c_ansi_function_def
])[
897 /** Number of symbols composing the right hand side of rule #RULE. */
899 yyrhsLength (yyRuleNum yyrule
)
905 yydestroyGLRState (char const *yymsg
, yyGLRState
*yys
)
908 yydestruct (yymsg
, yystos
[yys
->yylrState
],
909 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[);
915 YYFPRINTF (stderr
, "%s unresolved ", yymsg
);
916 yysymprint (stderr
, yystos
[yys
->yylrState
],
917 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[);
918 YYFPRINTF (stderr
, "\n");
922 if (yys
->yysemantics
.yyfirstVal
)
924 yySemanticOption
*yyoption
= yys
->yysemantics
.yyfirstVal
;
927 for (yyrh
= yyoption
->yystate
, yyn
= yyrhsLength (yyoption
->yyrule
);
929 yyrh
= yyrh
->yypred
, yyn
-= 1)
930 yydestroyGLRState (yymsg
, yyrh
);
935 /** Left-hand-side symbol for rule #RULE. */
936 static inline yySymbol
937 yylhsNonterm (yyRuleNum yyrule
)
942 #define yyis_pact_ninf(yystate) \
943 ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), 1,
945 ((yystate
) == YYPACT_NINF
))[
947 /** True iff LR state STATE has only a default reduction (regardless
950 yyisDefaultedState (yyStateNum yystate
)
952 return yyis_pact_ninf (yypact
[yystate
]);
955 /** The default reduction for STATE, assuming it has one. */
956 static inline yyRuleNum
957 yydefaultAction (yyStateNum yystate
)
959 return yydefact
[yystate
];
962 #define yyis_table_ninf(yytable_value) \
963 ]m4_if(m4_eval(b4_table_ninf < b4_table_min), 1,
965 ((yytable_value
) == YYTABLE_NINF
))[
967 /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
969 * R < 0: Reduce on rule -R.
971 * R > 0: Shift to state R.
972 * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
973 * conflicting reductions.
976 yygetLRActions (yyStateNum yystate
, int yytoken
,
977 int* yyaction
, const short int** yyconflicts
)
979 int yyindex
= yypact
[yystate
] + yytoken
;
980 if (yyindex
< 0 || YYLAST
< yyindex
|| yycheck
[yyindex
] != yytoken
)
982 *yyaction
= -yydefact
[yystate
];
983 *yyconflicts
= yyconfl
;
985 else if (! yyis_table_ninf (yytable
[yyindex
]))
987 *yyaction
= yytable
[yyindex
];
988 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
993 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
997 static inline yyStateNum
998 yyLRgotoState (yyStateNum yystate
, yySymbol yylhs
)
1001 yyr
= yypgoto
[yylhs
- YYNTOKENS
] + yystate
;
1002 if (0 <= yyr
&& yyr
<= YYLAST
&& yycheck
[yyr
] == yystate
)
1003 return yytable
[yyr
];
1005 return yydefgoto
[yylhs
- YYNTOKENS
];
1008 static inline yybool
1009 yyisShiftAction (int yyaction
)
1011 return 0 < yyaction
;
1014 static inline yybool
1015 yyisErrorAction (int yyaction
)
1017 return yyaction
== 0;
1023 yyaddDeferredAction (yyGLRStack
* yystack
, yyGLRState
* yystate
,
1024 yyGLRState
* rhs
, yyRuleNum yyrule
)
1026 yySemanticOption
* yynewItem
;
1027 yynewItem
= &yystack
->yynextFree
->yyoption
;
1028 yystack
->yyspaceLeft
-= 1;
1029 yystack
->yynextFree
+= 1;
1030 yynewItem
->yyisState
= yyfalse
;
1031 yynewItem
->yystate
= rhs
;
1032 yynewItem
->yyrule
= yyrule
;
1033 yynewItem
->yynext
= yystate
->yysemantics
.yyfirstVal
;
1034 yystate
->yysemantics
.yyfirstVal
= yynewItem
;
1035 if (yystack
->yyspaceLeft
< YYHEADROOM
)
1036 yyexpandGLRStack (yystack
);
1041 /** Initialize SET to a singleton set containing an empty stack. */
1043 yyinitStateSet (yyGLRStateSet
* yyset
)
1046 yyset
->yycapacity
= 16;
1047 yyset
->yystates
= (yyGLRState
**) YYMALLOC (16 * sizeof yyset
->yystates
[0]);
1048 if (! yyset
->yystates
)
1050 yyset
->yystates
[0] = NULL
;
1054 static void yyfreeStateSet (yyGLRStateSet
* yyset
)
1056 YYFREE (yyset
->yystates
);
1059 /** Initialize STACK to a single empty stack, with total maximum
1060 * capacity for all stacks of SIZE. */
1062 yyinitGLRStack (yyGLRStack
* yystack
, size_t yysize
)
1064 yystack
->yyerrState
= 0;
1066 yystack
->yyspaceLeft
= yysize
;
1068 (yyGLRStackItem
*) YYMALLOC (yysize
* sizeof yystack
->yynextFree
[0]);
1069 if (!yystack
->yyitems
)
1071 yystack
->yynextFree
= yystack
->yyitems
;
1072 yystack
->yysplitPoint
= NULL
;
1073 yystack
->yylastDeleted
= NULL
;
1074 return yyinitStateSet (&yystack
->yytops
);
1077 #define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
1078 &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
1080 /** If STACK is expandable, extend it. WARNING: Pointers into the
1081 stack from outside should be considered invalid after this call.
1082 We always expand when there are 1 or fewer items left AFTER an
1083 allocation, so that we can avoid having external pointers exist
1084 across an allocation. */
1086 yyexpandGLRStack (yyGLRStack
* yystack
)
1088 #if YYSTACKEXPANDABLE
1089 yyGLRStackItem
* yynewItems
;
1090 yyGLRStackItem
* yyp0
, *yyp1
;
1091 size_t yysize
, yynewSize
;
1093 yysize
= yystack
->yynextFree
- yystack
->yyitems
;
1094 if (YYMAXDEPTH
<= yysize
)
1095 yyMemoryExhausted (yystack
);
1096 yynewSize
= 2*yysize
;
1097 if (YYMAXDEPTH
< yynewSize
)
1098 yynewSize
= YYMAXDEPTH
;
1099 yynewItems
= (yyGLRStackItem
*) YYMALLOC (yynewSize
* sizeof yynewItems
[0]);
1101 yyMemoryExhausted (yystack
);
1102 for (yyp0
= yystack
->yyitems
, yyp1
= yynewItems
, yyn
= yysize
;
1104 yyn
-= 1, yyp0
+= 1, yyp1
+= 1)
1107 if (*(yybool
*) yyp0
)
1109 yyGLRState
* yys0
= &yyp0
->yystate
;
1110 yyGLRState
* yys1
= &yyp1
->yystate
;
1111 if (yys0
->yypred
!= NULL
)
1113 YYRELOC (yyp0
, yyp1
, yys0
->yypred
, yystate
);
1114 if (! yys0
->yyresolved
&& yys0
->yysemantics
.yyfirstVal
!= NULL
)
1115 yys1
->yysemantics
.yyfirstVal
=
1116 YYRELOC(yyp0
, yyp1
, yys0
->yysemantics
.yyfirstVal
, yyoption
);
1120 yySemanticOption
* yyv0
= &yyp0
->yyoption
;
1121 yySemanticOption
* yyv1
= &yyp1
->yyoption
;
1122 if (yyv0
->yystate
!= NULL
)
1123 yyv1
->yystate
= YYRELOC (yyp0
, yyp1
, yyv0
->yystate
, yystate
);
1124 if (yyv0
->yynext
!= NULL
)
1125 yyv1
->yynext
= YYRELOC (yyp0
, yyp1
, yyv0
->yynext
, yyoption
);
1128 if (yystack
->yysplitPoint
!= NULL
)
1129 yystack
->yysplitPoint
= YYRELOC (yystack
->yyitems
, yynewItems
,
1130 yystack
->yysplitPoint
, yystate
);
1132 for (yyn
= 0; yyn
< yystack
->yytops
.yysize
; yyn
+= 1)
1133 if (yystack
->yytops
.yystates
[yyn
] != NULL
)
1134 yystack
->yytops
.yystates
[yyn
] =
1135 YYRELOC (yystack
->yyitems
, yynewItems
,
1136 yystack
->yytops
.yystates
[yyn
], yystate
);
1137 YYFREE (yystack
->yyitems
);
1138 yystack
->yyitems
= yynewItems
;
1139 yystack
->yynextFree
= yynewItems
+ yysize
;
1140 yystack
->yyspaceLeft
= yynewSize
- yysize
;
1143 yyMemoryExhausted (yystack
);
1148 yyfreeGLRStack (yyGLRStack
* yystack
)
1150 YYFREE (yystack
->yyitems
);
1151 yyfreeStateSet (&yystack
->yytops
);
1154 /** Assuming that S is a GLRState somewhere on STACK, update the
1155 * splitpoint of STACK, if needed, so that it is at least as deep as
1158 yyupdateSplit (yyGLRStack
* yystack
, yyGLRState
* yys
)
1160 if (yystack
->yysplitPoint
!= NULL
&& yystack
->yysplitPoint
> yys
)
1161 yystack
->yysplitPoint
= yys
;
1164 /** Invalidate stack #K in STACK. */
1166 yymarkStackDeleted (yyGLRStack
* yystack
, size_t yyk
)
1168 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1169 yystack
->yylastDeleted
= yystack
->yytops
.yystates
[yyk
];
1170 yystack
->yytops
.yystates
[yyk
] = NULL
;
1173 /** Undelete the last stack that was marked as deleted. Can only be
1174 done once after a deletion, and only when all other stacks have
1177 yyundeleteLastStack (yyGLRStack
* yystack
)
1179 if (yystack
->yylastDeleted
== NULL
|| yystack
->yytops
.yysize
!= 0)
1181 yystack
->yytops
.yystates
[0] = yystack
->yylastDeleted
;
1182 yystack
->yytops
.yysize
= 1;
1183 YYDPRINTF ((stderr
, "Restoring last deleted stack as stack #0.\n"));
1184 yystack
->yylastDeleted
= NULL
;
1188 yyremoveDeletes (yyGLRStack
* yystack
)
1192 while (yyj
< yystack
->yytops
.yysize
)
1194 if (yystack
->yytops
.yystates
[yyi
] == NULL
)
1198 YYDPRINTF ((stderr
, "Removing dead stacks.\n"));
1200 yystack
->yytops
.yysize
-= 1;
1204 yystack
->yytops
.yystates
[yyj
] = yystack
->yytops
.yystates
[yyi
];
1207 YYDPRINTF ((stderr
, "Rename stack %lu -> %lu.\n",
1208 (unsigned long int) yyi
, (unsigned long int) yyj
));
1216 /** Shift to a new state on stack #K of STACK, corresponding to LR state
1217 * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
1219 yyglrShift (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1221 YYSTYPE yysval
, YYLTYPE
* yylocp
)
1223 yyGLRStackItem
* yynewItem
;
1225 yynewItem
= yystack
->yynextFree
;
1226 yystack
->yynextFree
+= 1;
1227 yystack
->yyspaceLeft
-= 1;
1228 yynewItem
->yystate
.yyisState
= yytrue
;
1229 yynewItem
->yystate
.yylrState
= yylrState
;
1230 yynewItem
->yystate
.yyposn
= yyposn
;
1231 yynewItem
->yystate
.yyresolved
= yytrue
;
1232 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1233 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1234 yynewItem
->yystate
.yysemantics
.yysval
= yysval
;
1235 yynewItem
->yystate
.yyloc
= *yylocp
;
1236 if (yystack
->yyspaceLeft
< YYHEADROOM
)
1237 yyexpandGLRStack (yystack
);
1240 /** Shift stack #K of YYSTACK, to a new state corresponding to LR
1241 * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
1242 * semantic value of YYRHS under the action for YYRULE. */
1244 yyglrShiftDefer (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1245 size_t yyposn
, yyGLRState
* rhs
, yyRuleNum yyrule
)
1247 yyGLRStackItem
* yynewItem
;
1249 yynewItem
= yystack
->yynextFree
;
1250 yynewItem
->yystate
.yyisState
= yytrue
;
1251 yynewItem
->yystate
.yylrState
= yylrState
;
1252 yynewItem
->yystate
.yyposn
= yyposn
;
1253 yynewItem
->yystate
.yyresolved
= yyfalse
;
1254 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1255 yynewItem
->yystate
.yysemantics
.yyfirstVal
= NULL
;
1256 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1257 yystack
->yynextFree
+= 1;
1258 yystack
->yyspaceLeft
-= 1;
1259 yyaddDeferredAction (yystack
, &yynewItem
->yystate
, rhs
, yyrule
);
1262 /** Pop the symbols consumed by reduction #RULE from the top of stack
1263 * #K of STACK, and perform the appropriate semantic action on their
1264 * semantic values. Assumes that all ambiguities in semantic values
1265 * have been previously resolved. Set *VALP to the resulting value,
1266 * and *LOCP to the computed location (if any). Return value is as
1267 * for userAction. */
1268 static inline YYRESULTTAG
1269 yydoAction (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1270 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1272 int yynrhs
= yyrhsLength (yyrule
);
1274 if (yystack
->yysplitPoint
== NULL
)
1276 /* Standard special case: single stack. */
1277 yyGLRStackItem
* rhs
= (yyGLRStackItem
*) yystack
->yytops
.yystates
[yyk
];
1278 YYASSERT (yyk
== 0);
1279 yystack
->yynextFree
-= yynrhs
;
1280 yystack
->yyspaceLeft
+= yynrhs
;
1281 yystack
->yytops
.yystates
[0] = & yystack
->yynextFree
[-1].yystate
;
1282 return yyuserAction (yyrule
, yynrhs
, rhs
,
1283 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1289 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1290 yys
= yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
1291 = yystack
->yytops
.yystates
[yyk
];
1292 for (yyi
= 0; yyi
< yynrhs
; yyi
+= 1)
1297 yyupdateSplit (yystack
, yys
);
1298 yystack
->yytops
.yystates
[yyk
] = yys
;
1299 return yyuserAction (yyrule
, yynrhs
, yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1300 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1305 # define YY_REDUCE_PRINT(K, Rule)
1307 # define YY_REDUCE_PRINT(K, Rule) \
1310 yy_reduce_print (K, Rule); \
1311 } while (/*CONSTCOND*/ 0)
1313 /*----------------------------------------------------------.
1314 | Report that the RULE is going to be reduced on stack #K. |
1315 `----------------------------------------------------------*/
1318 yy_reduce_print (size_t yyk
, yyRuleNum yyrule
)
1321 YYFPRINTF (stderr
, "Reducing stack %lu by rule %d (line %lu), ",
1322 (unsigned long int) yyk
, yyrule
- 1,
1323 (unsigned long int) yyrline
[yyrule
]);
1324 /* Print the symbols being reduced, and their result. */
1325 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
1326 YYFPRINTF (stderr
, "%s ", yytokenName (yyrhs
[yyi
]));
1327 YYFPRINTF (stderr
, "-> %s\n", yytokenName (yyr1
[yyrule
]));
1331 /** Pop items off stack #K of STACK according to grammar rule RULE,
1332 * and push back on the resulting nonterminal symbol. Perform the
1333 * semantic action associated with RULE and store its value with the
1334 * newly pushed state, if FORCEEVAL or if STACK is currently
1335 * unambiguous. Otherwise, store the deferred semantic action with
1336 * the new state. If the new state would have an identical input
1337 * position, LR state, and predecessor to an existing state on the stack,
1338 * it is identified with that existing state, eliminating stack #K from
1339 * the STACK. In this case, the (necessarily deferred) semantic value is
1340 * added to the options for the existing state's semantic value.
1342 static inline YYRESULTTAG
1343 yyglrReduce (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1344 yybool yyforceEval
]b4_user_formals
[)
1346 size_t yyposn
= yystack
->yytops
.yystates
[yyk
]->yyposn
;
1348 if (yyforceEval
|| yystack
->yysplitPoint
== NULL
)
1353 YY_REDUCE_PRINT (yyk
, yyrule
);
1354 YYCHK (yydoAction (yystack
, yyk
, yyrule
, &yysval
, &yyloc
]b4_user_args
[));
1355 yyglrShift (yystack
, yyk
,
1356 yyLRgotoState (yystack
->yytops
.yystates
[yyk
]->yylrState
,
1357 yylhsNonterm (yyrule
)),
1358 yyposn
, yysval
, &yyloc
);
1364 yyGLRState
* yys
, *yys0
= yystack
->yytops
.yystates
[yyk
];
1365 yyStateNum yynewLRState
;
1367 for (yys
= yystack
->yytops
.yystates
[yyk
], yyn
= yyrhsLength (yyrule
);
1373 yyupdateSplit (yystack
, yys
);
1374 yynewLRState
= yyLRgotoState (yys
->yylrState
, yylhsNonterm (yyrule
));
1376 "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
1377 (unsigned long int) yyk
, yyrule
- 1, yynewLRState
));
1378 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
1379 if (yyi
!= yyk
&& yystack
->yytops
.yystates
[yyi
] != NULL
)
1381 yyGLRState
* yyp
, *yysplit
= yystack
->yysplitPoint
;
1382 yyp
= yystack
->yytops
.yystates
[yyi
];
1383 while (yyp
!= yys
&& yyp
!= yysplit
&& yyp
->yyposn
>= yyposn
)
1385 if (yyp
->yylrState
== yynewLRState
&& yyp
->yypred
== yys
)
1387 yyaddDeferredAction (yystack
, yyp
, yys0
, yyrule
);
1388 yymarkStackDeleted (yystack
, yyk
);
1389 YYDPRINTF ((stderr
, "Merging stack %lu into stack %lu.\n",
1390 (unsigned long int) yyk
,
1391 (unsigned long int) yyi
));
1397 yystack
->yytops
.yystates
[yyk
] = yys
;
1398 yyglrShiftDefer (yystack
, yyk
, yynewLRState
, yyposn
, yys0
, yyrule
);
1404 yysplitStack (yyGLRStack
* yystack
, size_t yyk
)
1406 if (yystack
->yysplitPoint
== NULL
)
1408 YYASSERT (yyk
== 0);
1409 yystack
->yysplitPoint
= yystack
->yytops
.yystates
[yyk
];
1411 if (yystack
->yytops
.yysize
>= yystack
->yytops
.yycapacity
)
1413 yyGLRState
** yynewStates
;
1414 if (! ((yystack
->yytops
.yycapacity
1415 <= (YYSIZEMAX
/ (2 * sizeof yynewStates
[0])))
1417 (yyGLRState
**) YYREALLOC (yystack
->yytops
.yystates
,
1418 ((yystack
->yytops
.yycapacity
*= 2)
1419 * sizeof yynewStates
[0])))))
1420 yyMemoryExhausted (yystack
);
1421 yystack
->yytops
.yystates
= yynewStates
;
1423 yystack
->yytops
.yystates
[yystack
->yytops
.yysize
]
1424 = yystack
->yytops
.yystates
[yyk
];
1425 yystack
->yytops
.yysize
+= 1;
1426 return yystack
->yytops
.yysize
-1;
1429 /** True iff Y0 and Y1 represent identical options at the top level.
1430 * That is, they represent the same rule applied to RHS symbols
1431 * that produce the same terminal symbols. */
1433 yyidenticalOptions (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1435 if (yyy0
->yyrule
== yyy1
->yyrule
)
1437 yyGLRState
*yys0
, *yys1
;
1439 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1440 yyn
= yyrhsLength (yyy0
->yyrule
);
1442 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1443 if (yys0
->yyposn
!= yys1
->yyposn
)
1451 /** Assuming identicalOptions (Y0,Y1), destructively merge the
1452 * alternative semantic values for the RHS-symbols of Y1 and Y0. */
1454 yymergeOptionSets (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1456 yyGLRState
*yys0
, *yys1
;
1458 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1459 yyn
= yyrhsLength (yyy0
->yyrule
);
1461 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1465 else if (yys0
->yyresolved
)
1467 yys1
->yyresolved
= yytrue
;
1468 yys1
->yysemantics
.yysval
= yys0
->yysemantics
.yysval
;
1470 else if (yys1
->yyresolved
)
1472 yys0
->yyresolved
= yytrue
;
1473 yys0
->yysemantics
.yysval
= yys1
->yysemantics
.yysval
;
1477 yySemanticOption
** yyz0p
;
1478 yySemanticOption
* yyz1
;
1479 yyz0p
= &yys0
->yysemantics
.yyfirstVal
;
1480 yyz1
= yys1
->yysemantics
.yyfirstVal
;
1483 if (yyz1
== *yyz0p
|| yyz1
== NULL
)
1485 else if (*yyz0p
== NULL
)
1490 else if (*yyz0p
< yyz1
)
1492 yySemanticOption
* yyz
= *yyz0p
;
1494 yyz1
= yyz1
->yynext
;
1495 (*yyz0p
)->yynext
= yyz
;
1497 yyz0p
= &(*yyz0p
)->yynext
;
1499 yys1
->yysemantics
.yyfirstVal
= yys0
->yysemantics
.yyfirstVal
;
1504 /** Y0 and Y1 represent two possible actions to take in a given
1505 * parsing state; return 0 if no combination is possible,
1506 * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
1508 yypreference (yySemanticOption
* y0
, yySemanticOption
* y1
)
1510 yyRuleNum r0
= y0
->yyrule
, r1
= y1
->yyrule
;
1511 int p0
= yydprec
[r0
], p1
= yydprec
[r1
];
1515 if (yymerger
[r0
] == 0 || yymerger
[r0
] != yymerger
[r1
])
1520 if (p0
== 0 || p1
== 0)
1529 static YYRESULTTAG
yyresolveValue (yySemanticOption
* yyoptionList
,
1530 yyGLRStack
* yystack
, YYSTYPE
* yyvalp
,
1531 YYLTYPE
* yylocp
]b4_user_formals
[);
1534 yyresolveStates (yyGLRState
* yys
, int yyn
, yyGLRStack
* yystack
]b4_user_formals
[)
1539 YYASSERT (yys
->yypred
);
1540 yyflag
= yyresolveStates (yys
->yypred
, yyn
-1, yystack
]b4_user_args
[);
1543 if (! yys
->yyresolved
)
1545 yyflag
= yyresolveValue (yys
->yysemantics
.yyfirstVal
, yystack
,
1546 &yys
->yysemantics
.yysval
, &yys
->yyloc
1550 yys
->yyresolved
= yytrue
;
1557 yyresolveAction (yySemanticOption
* yyopt
, yyGLRStack
* yystack
,
1558 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1560 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1563 yynrhs
= yyrhsLength (yyopt
->yyrule
);
1564 YYCHK (yyresolveStates (yyopt
->yystate
, yynrhs
, yystack
]b4_user_args
[));
1565 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
= yyopt
->yystate
;
1566 return yyuserAction (yyopt
->yyrule
, yynrhs
,
1567 yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1568 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1573 yyreportTree (yySemanticOption
* yyx
, int yyindent
)
1575 int yynrhs
= yyrhsLength (yyx
->yyrule
);
1578 yyGLRState
* yystates
[YYMAXRHS
];
1579 yyGLRState yyleftmost_state
;
1581 for (yyi
= yynrhs
, yys
= yyx
->yystate
; 0 < yyi
; yyi
-= 1, yys
= yys
->yypred
)
1582 yystates
[yyi
] = yys
;
1585 yyleftmost_state
.yyposn
= 0;
1586 yystates
[0] = &yyleftmost_state
;
1591 if (yyx
->yystate
->yyposn
< yys
->yyposn
+ 1)
1592 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, empty>\n",
1593 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1596 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
1597 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1598 yyx
->yyrule
, (unsigned long int) (yys
->yyposn
+ 1),
1599 (unsigned long int) yyx
->yystate
->yyposn
);
1600 for (yyi
= 1; yyi
<= yynrhs
; yyi
+= 1)
1602 if (yystates
[yyi
]->yyresolved
)
1604 if (yystates
[yyi
-1]->yyposn
+1 > yystates
[yyi
]->yyposn
)
1605 YYFPRINTF (stderr
, "%*s%s <empty>\n", yyindent
+2, "",
1606 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]));
1608 YYFPRINTF (stderr
, "%*s%s <tokens %lu .. %lu>\n", yyindent
+2, "",
1609 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]),
1610 (unsigned long int) (yystates
[yyi
- 1]->yyposn
+ 1),
1611 (unsigned long int) yystates
[yyi
]->yyposn
);
1614 yyreportTree (yystates
[yyi
]->yysemantics
.yyfirstVal
, yyindent
+2);
1619 static void yyreportAmbiguity (yySemanticOption
* yyx0
, yySemanticOption
* yyx1
,
1620 yyGLRStack
* yystack
]b4_pure_formals
[)
1621 __attribute__ ((__noreturn__
));
1623 yyreportAmbiguity (yySemanticOption
* yyx0
, yySemanticOption
* yyx1
,
1624 yyGLRStack
* yystack
]b4_pure_formals
[)
1630 YYFPRINTF (stderr
, "Ambiguity detected.\n");
1631 YYFPRINTF (stderr
, "Option 1,\n");
1632 yyreportTree (yyx0
, 2);
1633 YYFPRINTF (stderr
, "\nOption 2,\n");
1634 yyreportTree (yyx1
, 2);
1635 YYFPRINTF (stderr
, "\n");
1637 yyFail (yystack
][]b4_pure_args
[, YY_("syntax is ambiguous"));
1641 /** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
1642 * actions, and return the result. */
1644 yyresolveValue (yySemanticOption
* yyoptionList
, yyGLRStack
* yystack
,
1645 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1647 yySemanticOption
* yybest
;
1648 yySemanticOption
** yypp
;
1651 yybest
= yyoptionList
;
1653 for (yypp
= &yyoptionList
->yynext
; *yypp
!= NULL
; )
1655 yySemanticOption
* yyp
= *yypp
;
1657 if (yyidenticalOptions (yybest
, yyp
))
1659 yymergeOptionSets (yybest
, yyp
);
1660 *yypp
= yyp
->yynext
;
1664 switch (yypreference (yybest
, yyp
))
1667 yyreportAmbiguity (yybest
, yyp
, yystack
]b4_pure_args
[);
1679 /* This cannot happen so it is not worth a YYASSERT (yyfalse),
1680 but some compilers complain if the default case is
1684 yypp
= &yyp
->yynext
;
1690 yySemanticOption
* yyp
;
1691 int yyprec
= yydprec
[yybest
->yyrule
];
1692 YYCHK (yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[));
1693 for (yyp
= yybest
->yynext
; yyp
!= NULL
; yyp
= yyp
->yynext
)
1695 if (yyprec
== yydprec
[yyp
->yyrule
])
1699 YYCHK (yyresolveAction (yyp
, yystack
, &yyval1
, &yydummy
]b4_user_args
[));
1700 yyuserMerge (yymerger
[yyp
->yyrule
], yyvalp
, &yyval1
);
1706 return yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[);
1710 yyresolveStack (yyGLRStack
* yystack
]b4_user_formals
[)
1712 if (yystack
->yysplitPoint
!= NULL
)
1717 for (yyn
= 0, yys
= yystack
->yytops
.yystates
[0];
1718 yys
!= yystack
->yysplitPoint
;
1719 yys
= yys
->yypred
, yyn
+= 1)
1721 YYCHK (yyresolveStates (yystack
->yytops
.yystates
[0], yyn
, yystack
1728 yycompressStack (yyGLRStack
* yystack
)
1730 yyGLRState
* yyp
, *yyq
, *yyr
;
1732 if (yystack
->yytops
.yysize
!= 1 || yystack
->yysplitPoint
== NULL
)
1735 for (yyp
= yystack
->yytops
.yystates
[0], yyq
= yyp
->yypred
, yyr
= NULL
;
1736 yyp
!= yystack
->yysplitPoint
;
1737 yyr
= yyp
, yyp
= yyq
, yyq
= yyp
->yypred
)
1740 yystack
->yyspaceLeft
+= yystack
->yynextFree
- yystack
->yyitems
;
1741 yystack
->yynextFree
= ((yyGLRStackItem
*) yystack
->yysplitPoint
) + 1;
1742 yystack
->yyspaceLeft
-= yystack
->yynextFree
- yystack
->yyitems
;
1743 yystack
->yysplitPoint
= NULL
;
1744 yystack
->yylastDeleted
= NULL
;
1748 yystack
->yynextFree
->yystate
= *yyr
;
1750 yystack
->yynextFree
->yystate
.yypred
= & yystack
->yynextFree
[-1].yystate
;
1751 yystack
->yytops
.yystates
[0] = &yystack
->yynextFree
->yystate
;
1752 yystack
->yynextFree
+= 1;
1753 yystack
->yyspaceLeft
-= 1;
1758 yyprocessOneStack (yyGLRStack
* yystack
, size_t yyk
,
1759 size_t yyposn
, YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
1763 const short int* yyconflicts
;
1765 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1767 while (yystack
->yytops
.yystates
[yyk
] != NULL
)
1769 yyStateNum yystate
= yystack
->yytops
.yystates
[yyk
]->yylrState
;
1770 YYDPRINTF ((stderr
, "Stack %lu Entering state %d\n",
1771 (unsigned long int) yyk
, yystate
));
1773 YYASSERT (yystate
!= YYFINAL
);
1775 if (yyisDefaultedState (yystate
))
1777 yyrule
= yydefaultAction (yystate
);
1780 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1781 (unsigned long int) yyk
));
1782 yymarkStackDeleted (yystack
, yyk
);
1785 YYCHK (yyglrReduce (yystack
, yyk
, yyrule
, yyfalse
]b4_user_args
[));
1789 if (*yytokenp
== YYEMPTY
)
1791 YYDPRINTF ((stderr
, "Reading a token: "));
1793 *yytokenp
= YYTRANSLATE (yychar
);
1794 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1796 yygetLRActions (yystate
, *yytokenp
, &yyaction
, &yyconflicts
);
1798 while (*yyconflicts
!= 0)
1800 size_t yynewStack
= yysplitStack (yystack
, yyk
);
1801 YYDPRINTF ((stderr
, "Splitting off stack %lu from %lu.\n",
1802 (unsigned long int) yynewStack
,
1803 (unsigned long int) yyk
));
1804 YYCHK (yyglrReduce (yystack
, yynewStack
,
1805 *yyconflicts
, yyfalse
]b4_user_args
[));
1806 YYCHK (yyprocessOneStack (yystack
, yynewStack
, yyposn
,
1807 yylvalp
, yyllocp
]b4_pure_args
[));
1811 if (yyisShiftAction (yyaction
))
1813 YYDPRINTF ((stderr
, "On stack %lu, ", (unsigned long int) yyk
));
1814 YY_SYMBOL_PRINT ("shifting", *yytokenp
, yylvalp
, yyllocp
);
1815 yyglrShift (yystack
, yyk
, yyaction
, yyposn
+1,
1817 YYDPRINTF ((stderr
, "Stack %lu now in state #%d\n",
1818 (unsigned long int) yyk
,
1819 yystack
->yytops
.yystates
[yyk
]->yylrState
));
1822 else if (yyisErrorAction (yyaction
))
1824 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1825 (unsigned long int) yyk
));
1826 yymarkStackDeleted (yystack
, yyk
);
1830 YYCHK (yyglrReduce (yystack
, yyk
, -yyaction
, yyfalse
]b4_user_args
[));
1837 yyreportSyntaxError (yyGLRStack
* yystack
,
1838 YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
]b4_user_formals
[)
1843 if (yystack
->yyerrState
== 0)
1846 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1848 yyn
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1849 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1851 size_t yysize0
= yytnamerr (NULL
, yytokenName (*yytokenp
));
1852 size_t yysize
= yysize0
;
1854 yybool yysize_overflow
= yyfalse
;
1856 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1857 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1861 static char const yyunexpected
[] = "syntax error, unexpected %s";
1862 static char const yyexpecting
[] = ", expecting %s";
1863 static char const yyor
[] = " or %s";
1864 char yyformat
[sizeof yyunexpected
1865 + sizeof yyexpecting
- 1
1866 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1867 * (sizeof yyor
- 1))];
1868 char const *yyprefix
= yyexpecting
;
1870 /* Start YYX at -YYN if negative to avoid negative indexes in
1872 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1874 /* Stay within bounds of both yycheck and yytname. */
1875 int yychecklim
= YYLAST
- yyn
;
1876 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1879 yyarg
[0] = yytokenName (*yytokenp
);
1880 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1882 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1883 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1885 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1889 yyformat
[sizeof yyunexpected
- 1] = '\0';
1892 yyarg
[yycount
++] = yytokenName (yyx
);
1893 yysize1
= yysize
+ yytnamerr (NULL
, yytokenName (yyx
));
1894 yysize_overflow
|= yysize1
< yysize
;
1896 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1900 yyf
= YY_(yyformat
);
1901 yysize1
= yysize
+ strlen (yyf
);
1902 yysize_overflow
|= yysize1
< yysize
;
1905 if (!yysize_overflow
)
1906 yymsg
= (char *) YYMALLOC (yysize
);
1912 while ((*yyp
= *yyf
))
1914 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1916 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1925 yyerror (]b4_lyyerror_args
[yymsg
);
1930 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1931 yyMemoryExhausted (yystack
);
1935 #endif /* YYERROR_VERBOSE */
1936 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1941 /* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
1942 YYLVALP, and YYLLOCP point to the syntactic category, semantic
1943 value, and location of the look-ahead. */
1945 yyrecoverSyntaxError (yyGLRStack
* yystack
,
1947 YYLTYPE
* YYOPTIONAL_LOC (yyllocp
)
1950 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1954 if (yystack
->yyerrState
== 3)
1955 /* We just shifted the error token and (perhaps) took some
1956 reductions. Skip tokens until we can proceed. */
1959 if (*yytokenp
== YYEOF
)
1960 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1961 if (*yytokenp
!= YYEMPTY
)
1963 /* We throw away the lookahead, but the error range
1964 of the shifted error token must take it into account. */
1965 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
1966 yyGLRStackItem yyerror_range
[3];
1967 yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;
1968 yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
1969 YYLLOC_DEFAULT (yys
->yyloc
, yyerror_range
, 2);]])[
1970 yydestruct ("Error: discarding",
1971 *yytokenp
, yylvalp
]b4_location_if([, yyllocp
])[);
1973 YYDPRINTF ((stderr
, "Reading a token: "));
1975 *yytokenp
= YYTRANSLATE (yychar
);
1976 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1977 yyj
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1978 if (yyis_pact_ninf (yyj
))
1981 if (yyj
< 0 || YYLAST
< yyj
|| yycheck
[yyj
] != *yytokenp
)
1983 if (yydefact
[yystack
->yytops
.yystates
[0]->yylrState
] != 0)
1986 else if (yytable
[yyj
] != 0 && ! yyis_table_ninf (yytable
[yyj
]))
1990 /* Reduce to one stack. */
1991 for (yyk
= 0; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
1992 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1994 if (yyk
>= yystack
->yytops
.yysize
)
1995 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1996 for (yyk
+= 1; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
1997 yymarkStackDeleted (yystack
, yyk
);
1998 yyremoveDeletes (yystack
);
1999 yycompressStack (yystack
);
2001 /* Now pop stack until we find a state that shifts the error token. */
2002 yystack
->yyerrState
= 3;
2003 while (yystack
->yytops
.yystates
[0] != NULL
)
2005 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
2006 yyj
= yypact
[yys
->yylrState
];
2007 if (! yyis_pact_ninf (yyj
))
2010 if (0 <= yyj
&& yyj
<= YYLAST
&& yycheck
[yyj
] == YYTERROR
2011 && yyisShiftAction (yytable
[yyj
]))
2013 /* Shift the error token having adjusted its location. */
2014 YYLTYPE yyerrloc
;]b4_location_if([[
2015 yystack
->yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
2016 YYLLOC_DEFAULT (yyerrloc
, yystack
->yyerror_range
, 2);]])[
2017 YY_SYMBOL_PRINT ("Shifting", yystos
[yytable
[yyj
]],
2018 yylvalp
, &yyerrloc
);
2019 yyglrShift (yystack
, 0, yytable
[yyj
],
2020 yys
->yyposn
, *yylvalp
, &yyerrloc
);
2021 yys
= yystack
->yytops
.yystates
[0];
2025 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]])[
2026 yydestroyGLRState ("Error: popping", yys
);
2027 yystack
->yytops
.yystates
[0] = yys
->yypred
;
2028 yystack
->yynextFree
-= 1;
2029 yystack
->yyspaceLeft
+= 1;
2031 if (yystack
->yytops
.yystates
[0] == NULL
)
2032 yyFail (yystack
][]b4_lpure_args
[, NULL
);
2035 #define YYCHK1(YYE) \
2045 goto yyuser_error; \
2049 } while (/*CONSTCOND*/ 0)
2056 ]b4_c_ansi_function_def([yyparse
], [int], b4_parse_param
)[
2067 #define yychar (yystack.yyrawchar)
2070 YYSTYPE
* const yylvalp
= &yylval
;
2071 YYLTYPE
* const yyllocp
= &yylloc
;
2073 YYDPRINTF ((stderr
, "Starting parse\n"));
2076 yylval
= yyval_default
;
2078 #if YYLTYPE_IS_TRIVIAL
2079 yylloc
.first_line
= yylloc
.last_line
= 1;
2080 yylloc
.first_column
= yylloc
.last_column
= 0;
2083 m4_ifdef([b4_initial_action
], [
2084 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
2085 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
2086 /* User initialization code. */
2088 m4_popdef([b4_dollar_dollar
])dnl
2089 m4_popdef([b4_at_dollar
])dnl
2090 /* Line __line__ of glr.c. */
2091 b4_syncline([@oline@
], [@ofile@
])])dnl
2093 if (! yyinitGLRStack (&yystack
, YYINITDEPTH
))
2094 goto yyexhaustedlab
;
2095 switch (YYSETJMP (yystack
.yyexception_buffer
))
2098 case 1: goto yyabortlab
;
2099 case 2: goto yyexhaustedlab
;
2100 default: goto yybuglab
;
2102 yystack
.yytokenp
= &yytoken
;
2103 yyglrShift (&yystack
, 0, 0, 0, yylval
, &yylloc
);
2108 /* For efficiency, we have two loops, the first of which is
2109 specialized to deterministic operation (single stack, no
2110 potential ambiguity). */
2116 const short int* yyconflicts
;
2118 yyStateNum yystate
= yystack
.yytops
.yystates
[0]->yylrState
;
2119 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
2120 if (yystate
== YYFINAL
)
2122 if (yyisDefaultedState (yystate
))
2124 yyrule
= yydefaultAction (yystate
);
2127 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2128 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2131 YYCHK1 (yyglrReduce (&yystack
, 0, yyrule
, yytrue
]b4_user_args
[));
2135 if (yytoken
== YYEMPTY
)
2137 YYDPRINTF ((stderr
, "Reading a token: "));
2139 yytoken
= YYTRANSLATE (yychar
);
2140 YY_SYMBOL_PRINT ("Next token is", yytoken
, yylvalp
, yyllocp
);
2142 yygetLRActions (yystate
, yytoken
, &yyaction
, &yyconflicts
);
2143 if (*yyconflicts
!= 0)
2145 if (yyisShiftAction (yyaction
))
2147 YY_SYMBOL_PRINT ("Shifting", yytoken
, yylvalp
, yyllocp
);
2148 if (yytoken
!= YYEOF
)
2151 yyglrShift (&yystack
, 0, yyaction
, yyposn
, yylval
, yyllocp
);
2152 if (0 < yystack
.yyerrState
)
2153 yystack
.yyerrState
-= 1;
2155 else if (yyisErrorAction (yyaction
))
2157 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2158 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2162 YYCHK1 (yyglrReduce (&yystack
, 0, -yyaction
, yytrue
]b4_user_args
[));
2169 size_t yyn
= yystack
.yytops
.yysize
;
2170 for (yys
= 0; yys
< yyn
; yys
+= 1)
2171 YYCHK1 (yyprocessOneStack (&yystack
, yys
, yyposn
,
2172 yylvalp
, yyllocp
]b4_lpure_args
[));
2175 yyremoveDeletes (&yystack
);
2176 if (yystack
.yytops
.yysize
== 0)
2178 yyundeleteLastStack (&yystack
);
2179 if (yystack
.yytops
.yysize
== 0)
2180 yyFail (&yystack
][]b4_lpure_args
[, YY_("syntax error"));
2181 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2182 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2183 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2184 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2187 else if (yystack
.yytops
.yysize
== 1)
2189 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2190 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2191 yycompressStack (&yystack
);
2197 yyrecoverSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2198 yyposn
= yystack
.yytops
.yystates
[0]->yyposn
;
2214 yyerror (]b4_lyyerror_args
[YY_("memory exhausted"));
2219 if (yytoken
!= YYEOF
&& yytoken
!= YYEMPTY
)
2220 yydestruct ("Cleanup: discarding lookahead",
2221 yytoken
, yylvalp
]b4_location_if([, yyllocp
])[);
2223 /* If the stack is well-formed, pop the stack until it is empty,
2224 destroying its entries as we go. But free the stack regardless
2225 of whether it is well-formed. */
2226 if (yystack
.yyitems
)
2228 yyGLRState
** yystates
= yystack
.yytops
.yystates
;
2232 yyGLRState
*yys
= yystates
[0];
2233 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]]
2234 )[ yydestroyGLRState ("Cleanup: popping", yys
);
2235 yystates
[0] = yys
->yypred
;
2236 yystack
.yynextFree
-= 1;
2237 yystack
.yyspaceLeft
+= 1;
2239 yyfreeGLRStack (&yystack
);
2245 /* DEBUGGING ONLY */
2247 static void yypstack (yyGLRStack
* yystack
, size_t yyk
)
2248 __attribute__ ((__unused__
));
2249 static void yypdumpstack (yyGLRStack
* yystack
) __attribute__ ((__unused__
));
2252 yy_yypstack (yyGLRState
* yys
)
2256 yy_yypstack (yys
->yypred
);
2257 fprintf (stderr
, " -> ");
2259 fprintf (stderr
, "%d@@%lu", yys
->yylrState
, (unsigned long int) yys
->yyposn
);
2263 yypstates (yyGLRState
* yyst
)
2266 fprintf (stderr
, "<null>");
2269 fprintf (stderr
, "\n");
2273 yypstack (yyGLRStack
* yystack
, size_t yyk
)
2275 yypstates (yystack
->yytops
.yystates
[yyk
]);
2278 #define YYINDEX(YYX) \
2279 ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
2283 yypdumpstack (yyGLRStack
* yystack
)
2285 yyGLRStackItem
* yyp
;
2287 for (yyp
= yystack
->yyitems
; yyp
< yystack
->yynextFree
; yyp
+= 1)
2289 fprintf (stderr
, "%3lu. ", (unsigned long int) (yyp
- yystack
->yyitems
));
2290 if (*(yybool
*) yyp
)
2292 fprintf (stderr
, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
2293 yyp
->yystate
.yyresolved
, yyp
->yystate
.yylrState
,
2294 (unsigned long int) yyp
->yystate
.yyposn
,
2295 (long int) YYINDEX (yyp
->yystate
.yypred
));
2296 if (! yyp
->yystate
.yyresolved
)
2297 fprintf (stderr
, ", firstVal: %ld",
2298 (long int) YYINDEX (yyp
->yystate
.yysemantics
.yyfirstVal
));
2302 fprintf (stderr
, "Option. rule: %d, state: %ld, next: %ld",
2303 yyp
->yyoption
.yyrule
,
2304 (long int) YYINDEX (yyp
->yyoption
.yystate
),
2305 (long int) YYINDEX (yyp
->yyoption
.yynext
));
2307 fprintf (stderr
, "\n");
2309 fprintf (stderr
, "Tops:");
2310 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
2311 fprintf (stderr
, "%lu: %ld; ", (unsigned long int) yyi
,
2312 (long int) YYINDEX (yystack
->yytops
.yystates
[yyi
]));
2313 fprintf (stderr
, "\n");
2319 m4_if(b4_defines_flag
, 0, [],
2320 [@output @output_header_name@
2321 b4_copyright([Skeleton parser
for GLR parsing with Bison
],
2322 [2002, 2003, 2004, 2005])
2324 b4_token_enums(b4_tokens
)
2326 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
2327 m4_ifdef([b4_stype
],
2328 [b4_syncline([b4_stype_line
], [b4_file_name
])
2329 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
2330 /* Line __line__ of glr.c. */
2331 b4_syncline([@oline@
], [@ofile@
])],
2332 [typedef int YYSTYPE
;])
2333 # define YYSTYPE_IS_DECLARED 1
2334 # define YYSTYPE_IS_TRIVIAL 1
2338 [extern YYSTYPE b4_prefix
[]lval
;])
2340 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
2341 typedef struct YYLTYPE
2352 # define YYLTYPE_IS_DECLARED 1
2353 # define YYLTYPE_IS_TRIVIAL 1
2356 b4_location_if([b4_pure_if([],
2357 [extern YYLTYPE b4_prefix
[]lloc
;])