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 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
176 ]m4_ifdef([b4_stype
],
177 [b4_syncline([b4_stype_line
], [b4_filename
])
178 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
179 /* Line __line__ of glr.c. */
180 b4_syncline([@oline@
], [@ofile@
])],
181 [typedef int YYSTYPE
;])[
182 # define YYSTYPE_IS_DECLARED 1
183 # define YYSTYPE_IS_TRIVIAL 1
186 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
187 typedef struct YYLTYPE
198 # define YYLTYPE_IS_DECLARED 1
199 # define YYLTYPE_IS_TRIVIAL 1
202 /* Default (constant) value used for initialization for null
203 right-hand sides. Unlike the standard yacc.c template,
204 here we set the default value of $$ to a zeroed-out value.
205 Since the default value is undefined, this behavior is
206 technically correct. */
207 static YYSTYPE yyval_default
;
209 /* Copy the second part of user declarations. */
212 ]/* Line __line__ of glr.c. */
213 b4_syncline([@oline@
], [@ofile@
])
225 # define YYMALLOC malloc
228 # define YYREALLOC realloc
231 #define YYSIZEMAX ((size_t) -1)
236 typedef unsigned char yybool
;
245 #ifndef __attribute__
246 /* This feature is available in gcc versions 2.5 and later. */
247 # if !defined (__GNUC__) || __GNUC__ < 2 || \
248 (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
249 # define __attribute__(Spec) /* empty */
251 ]b4_location_if([# define YYOPTIONAL_LOC(Name) Name],[
252 # if defined (__cplusplus)
253 # define YYOPTIONAL_LOC(Name) /* empty */
255 # define YYOPTIONAL_LOC(Name) Name ATTRIBUTE_UNUSED
261 # define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
264 #ifndef ATTRIBUTE_UNUSED
265 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
268 /* YYFINAL -- State number of the termination state. */
269 #define YYFINAL ]b4_final_state_number[
270 /* YYLAST -- Last index in YYTABLE. */
271 #define YYLAST ]b4_last[
273 /* YYNTOKENS -- Number of terminals. */
274 #define YYNTOKENS ]b4_tokens_number[
275 /* YYNNTS -- Number of nonterminals. */
276 #define YYNNTS ]b4_nterms_number[
277 /* YYNRULES -- Number of rules. */
278 #define YYNRULES ]b4_rules_number[
279 /* YYNRULES -- Number of states. */
280 #define YYNSTATES ]b4_states_number[
281 /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
282 #define YYMAXRHS ]b4_r2_max[
283 /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
284 accessed by $0, $-1, etc., in any rule. */
285 #define YYMAXLEFT ]b4_max_left_semantic_context[
287 /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
288 #define YYUNDEFTOK ]b4_undef_token_number[
289 #define YYMAXUTOK ]b4_user_token_number_max[
291 #define YYTRANSLATE(YYX) \
292 ((YYX <= 0) ? YYEOF : \
293 (unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
295 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
296 static const ]b4_int_type_for([b4_translate
])[ yytranslate
[] =
302 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
304 static const ]b4_int_type_for([b4_prhs
])[ yyprhs
[] =
309 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
310 static const ]b4_int_type_for([b4_rhs
])[ yyrhs
[] =
315 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
316 static const ]b4_int_type_for([b4_rline
])[ yyrline
[] =
322 #if (YYDEBUG) || YYERROR_VERBOSE
323 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
324 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
325 static const char *const yytname
[] =
331 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
332 static const ]b4_int_type_for([b4_r1
])[ yyr1
[] =
337 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
338 static const ]b4_int_type_for([b4_r2
])[ yyr2
[] =
343 /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
344 static const ]b4_int_type_for([b4_dprec
])[ yydprec
[] =
349 /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
350 static const ]b4_int_type_for([b4_merger
])[ yymerger
[] =
355 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
356 doesn't specify something else to do. Zero means the default is an
358 static const ]b4_int_type_for([b4_defact
])[ yydefact
[] =
363 /* YYPDEFGOTO[NTERM-NUM]. */
364 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto
[] =
369 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
371 #define YYPACT_NINF ]b4_pact_ninf[
372 static const ]b4_int_type_for([b4_pact
])[ yypact
[] =
377 /* YYPGOTO[NTERM-NUM]. */
378 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto
[] =
383 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
384 positive, shift that token. If negative, reduce the rule which
385 number is the opposite. If zero, do what YYDEFACT says.
386 If YYTABLE_NINF, syntax error. */
387 #define YYTABLE_NINF ]b4_table_ninf[
388 static const ]b4_int_type_for([b4_table
])[ yytable
[] =
393 /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
394 list of conflicting reductions corresponding to action entry for
395 state STATE-NUM in yytable. 0 means no conflicts. The list in
396 yyconfl is terminated by a rule number of 0. */
397 static const ]b4_int_type_for([b4_conflict_list_heads
])[ yyconflp
[] =
399 ]b4_conflict_list_heads
[
402 /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
403 0, pointed into by YYCONFLP. */
404 ]dnl Do
not use b4_int_type_for here
, since there are places where
405 dnl pointers onto yyconfl are taken
, which type is
"short int *".
406 dnl We probably ought to introduce a type
for confl
.
407 [static const short int yyconfl
[] =
409 ]b4_conflicting_rules
[
412 static const ]b4_int_type_for([b4_check
])[ yycheck
[] =
417 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
418 symbol of state STATE-NUM. */
419 static const ]b4_int_type_for([b4_stos
])[ yystos
[] =
425 /* Prevent warning if -Wmissing-prototypes. */
426 ]b4_c_ansi_function_decl([yyparse
], [int], b4_parse_param
)[
428 /* Error token number */
431 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
432 If N is 0, then set CURRENT to the empty location which ends
433 the previous symbol: RHS[0] (always defined). */
436 #define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
437 #ifndef YYLLOC_DEFAULT
438 # define YYLLOC_DEFAULT(Current, Rhs, N) \
442 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
443 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
444 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
445 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
449 (Current).first_line = (Current).last_line = \
450 YYRHSLOC (Rhs, 0).last_line; \
451 (Current).first_column = (Current).last_column = \
452 YYRHSLOC (Rhs, 0).last_column; \
456 /* YY_LOCATION_PRINT -- Print the location on the stream.
457 This macro was not mandated originally: define only if we know
458 we won't break user code: when these are the locations we know. */
460 # define YY_LOCATION_PRINT(File, Loc) \
461 fprintf (File, "%d.%d-%d.%d", \
462 (Loc).first_line, (Loc).first_column, \
463 (Loc).last_line, (Loc).last_column)
466 #ifndef YYLLOC_DEFAULT
467 # define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)
471 #ifndef YY_LOCATION_PRINT
472 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
476 /* YYLEX -- calling `yylex' with the right arguments. */
477 #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
482 #define yynerrs (yystack->yyerrcnt)
484 #define yychar (yystack->yyrawchar)],
492 static const int YYEOF
= 0;
493 static const int YYEMPTY
= -2;
495 typedef enum { yyok
, yyaccept
, yyabort
, yyerr
} YYRESULTTAG
;
498 do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
503 #if ! defined (YYFPRINTF)
504 # define YYFPRINTF fprintf
507 # define YYDPRINTF(Args) \
513 ]b4_yysymprint_generate([b4_c_ansi_function_def
])[
515 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
519 YYFPRINTF (stderr, "%s ", Title); \
520 yysymprint (stderr, \
521 Type, Value]b4_location_if([, Location])[); \
525 /* Nonzero means print parse trace. It is left uninitialized so that
526 multiple parsers can coexist. */
531 # define YYDPRINTF(Args)
532 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
534 #endif /* !YYDEBUG */
536 /* YYINITDEPTH -- initial size of the parser's stacks. */
538 # define YYINITDEPTH ]b4_stack_depth_init[
541 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
542 if the built-in stack extension method is used).
544 Do not make this value too large; the results are undefined if
545 SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
546 evaluated with infinite-precision integer arithmetic. */
549 # define YYMAXDEPTH ]b4_stack_depth_max[
552 /* Minimum number of free items on the stack allowed after an
553 allocation. This is to allow allocation and initialization
554 to be completed by functions that call yyexpandGLRStack before the
555 stack is expanded, thus insuring that all necessary pointers get
556 properly redirected to new data. */
559 #if (! defined (YYSTACKEXPANDABLE) \
560 && (! defined (__cplusplus) \
561 || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \
562 && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
563 #define YYSTACKEXPANDABLE 1
565 #define YYSTACKEXPANDABLE 0
571 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
572 # define yystpcpy stpcpy
574 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
577 yystpcpy (char *yydest
, const char *yysrc
)
580 const char *yys
= yysrc
;
582 while ((*yyd
++ = *yys
++) != '\0')
590 #endif /* !YYERROR_VERBOSE */
592 /** State numbers, as in LALR(1) machine */
593 typedef int yyStateNum
;
595 /** Rule numbers, as in LALR(1) machine */
596 typedef int yyRuleNum
;
598 /** Grammar symbol */
599 typedef short int yySymbol
;
601 /** Item references, as in LALR(1) machine */
602 typedef short int yyItemNum
;
604 typedef struct yyGLRState yyGLRState
;
605 typedef struct yySemanticOption yySemanticOption
;
606 typedef union yyGLRStackItem yyGLRStackItem
;
607 typedef struct yyGLRStack yyGLRStack
;
608 typedef struct yyGLRStateSet yyGLRStateSet
;
611 /** Type tag: always true. */
613 /** Type tag for yysemantics. If true, yysval applies, otherwise
614 * yyfirstVal applies. */
616 /** Number of corresponding LALR(1) machine state. */
617 yyStateNum yylrState
;
618 /** Preceding state in this stack */
620 /** Source position of the first token produced by my symbol */
623 /** First in a chain of alternative reductions producing the
624 * non-terminal corresponding to this state, threaded through
626 yySemanticOption
* yyfirstVal
;
627 /** Semantic value for this state. */
630 /** Source location for this state. */
634 struct yyGLRStateSet
{
635 yyGLRState
** yystates
;
636 size_t yysize
, yycapacity
;
639 struct yySemanticOption
{
640 /** Type tag: always false. */
642 /** Rule number for this reduction */
644 /** The last RHS state in the list of states to be reduced. */
646 /** Next sibling in chain of options. To facilitate merging,
647 * options are chained in decreasing order by address. */
648 yySemanticOption
* yynext
;
651 /** Type of the items in the GLR stack. The yyisState field
652 * indicates which item of the union is valid. */
653 union yyGLRStackItem
{
655 yySemanticOption yyoption
;
661 ]b4_location_if([[ /* To compute the location of the error token. */
662 yyGLRStackItem yyerror_range
[3];]])[
669 jmp_buf yyexception_buffer
;
670 yyGLRStackItem
* yyitems
;
671 yyGLRStackItem
* yynextFree
;
673 yyGLRState
* yysplitPoint
;
674 yyGLRState
* yylastDeleted
;
675 yyGLRStateSet yytops
;
678 static void yyexpandGLRStack (yyGLRStack
* yystack
]b4_pure_formals
[);
681 yyFail (yyGLRStack
* yystack
]b4_pure_formals
[, const char* yymsg
)
683 yystack
->yyerrflag
= 1;
685 yyerror (]b4_yyerror_args
[yymsg
);
686 longjmp (yystack
->yyexception_buffer
, 1);
690 yyStackOverflow (yyGLRStack
* yystack
]b4_pure_formals
[)
692 yyFail (yystack
]b4_pure_args
[, "parser stack overflow");
695 #if YYDEBUG || YYERROR_VERBOSE
696 /** A printable representation of TOKEN. */
697 static inline const char*
698 yytokenName (yySymbol yytoken
)
700 if (yytoken
== YYEMPTY
)
703 return yytname
[yytoken
];
707 /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
708 * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
709 * containing the pointer to the next state in the chain. Assumes
710 * YYLOW1 < YYLOW0. */
711 static void yyfillin (yyGLRStackItem
*, int, int) ATTRIBUTE_UNUSED
;
713 yyfillin (yyGLRStackItem
*yyvsp
, int yylow0
, int yylow1
)
717 s
= yyvsp
[yylow0
].yystate
.yypred
;
718 for (i
= yylow0
-1; i
>= yylow1
; i
-= 1)
720 YYASSERT (s
->yyresolved
);
721 yyvsp
[i
].yystate
.yyresolved
= yytrue
;
722 yyvsp
[i
].yystate
.yysemantics
.yysval
= s
->yysemantics
.yysval
;
723 yyvsp
[i
].yystate
.yyloc
= s
->yyloc
;
724 s
= yyvsp
[i
].yystate
.yypred
= s
->yypred
;
728 /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
729 YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
730 For convenience, always return YYLOW1. */
731 static inline int yyfill (yyGLRStackItem
*, int *, int, yybool
)
734 yyfill (yyGLRStackItem
*yyvsp
, int *yylow
, int yylow1
, yybool yynormal
)
736 if (!yynormal
&& yylow1
< *yylow
)
738 yyfillin (yyvsp
, *yylow
, yylow1
);
744 /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
745 * and top stack item YYVSP. YYLVALP points to place to put semantic
746 * value ($$), and yylocp points to place for location information
747 * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
748 * yyerr for YYERROR, yyabort for YYABORT. */
750 yyuserAction (yyRuleNum yyn
, int yyrhslen
, yyGLRStackItem
* yyvsp
,
752 YYLTYPE
* YYOPTIONAL_LOC (yylocp
),
756 yybool yynormal ATTRIBUTE_UNUSED
= (yystack
->yysplitPoint
== NULL
);
760 # define yyerrok (yystack->yyerrState = 0)
762 # define YYACCEPT return yyaccept
764 # define YYABORT return yyabort
766 # define YYERROR return yyerrok, yyerr
768 # define YYRECOVERING (yystack->yyerrState != 0)
770 # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)
772 # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
774 # define YYBACKUP(Token, Value) \
775 return yyerror (]b4_yyerror_args["syntax error: cannot back up"), \
780 *yyvalp
= yyval_default
;
782 *yyvalp
= yyvsp
[YYFILL (1-yyrhslen
)].yystate
.yysemantics
.yysval
;
783 YYLLOC_DEFAULT (*yylocp
, yyvsp
- yyrhslen
, yyrhslen
);
784 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= *yylocp
;
800 /* Line __line__ of glr.c. */
801 b4_syncline([@oline@
], [@ofile@
])
806 yyuserMerge (int yyn
, YYSTYPE
* yy0
, YYSTYPE
* yy1
)
808 /* `Use' the arguments. */
818 /* Bison grammar-table manipulation. */
820 ]b4_yydestruct_generate([b4_c_ansi_function_def
])[
822 /** Number of symbols composing the right hand side of rule #RULE. */
824 yyrhsLength (yyRuleNum yyrule
)
829 /** Left-hand-side symbol for rule #RULE. */
830 static inline yySymbol
831 yylhsNonterm (yyRuleNum yyrule
)
836 #define yyis_pact_ninf(yystate) \
837 ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), 1,
839 ((yystate
) == YYPACT_NINF
))[
841 /** True iff LR state STATE has only a default reduction (regardless
844 yyisDefaultedState (yyStateNum yystate
)
846 return yyis_pact_ninf (yypact
[yystate
]);
849 /** The default reduction for STATE, assuming it has one. */
850 static inline yyRuleNum
851 yydefaultAction (yyStateNum yystate
)
853 return yydefact
[yystate
];
856 #define yyis_table_ninf(yytable_value) \
857 ]m4_if(m4_eval(b4_table_ninf < b4_table_min), 1,
859 ((yytable_value
) == YYTABLE_NINF
))[
861 /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
863 * R < 0: Reduce on rule -R.
865 * R > 0: Shift to state R.
866 * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
867 * conflicting reductions.
870 yygetLRActions (yyStateNum yystate
, int yytoken
,
871 int* yyaction
, const short int** yyconflicts
)
873 int yyindex
= yypact
[yystate
] + yytoken
;
874 if (yyindex
< 0 || YYLAST
< yyindex
|| yycheck
[yyindex
] != yytoken
)
876 *yyaction
= -yydefact
[yystate
];
877 *yyconflicts
= yyconfl
;
879 else if (! yyis_table_ninf (yytable
[yyindex
]))
881 *yyaction
= yytable
[yyindex
];
882 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
887 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
891 static inline yyStateNum
892 yyLRgotoState (yyStateNum yystate
, yySymbol yylhs
)
895 yyr
= yypgoto
[yylhs
- YYNTOKENS
] + yystate
;
896 if (0 <= yyr
&& yyr
<= YYLAST
&& yycheck
[yyr
] == yystate
)
899 return yydefgoto
[yylhs
- YYNTOKENS
];
903 yyisShiftAction (int yyaction
)
909 yyisErrorAction (int yyaction
)
911 return yyaction
== 0;
917 yyaddDeferredAction (yyGLRStack
* yystack
, yyGLRState
* yystate
,
918 yyGLRState
* rhs
, yyRuleNum yyrule
]b4_pure_formals
[)
920 yySemanticOption
* yynewItem
;
921 yynewItem
= &yystack
->yynextFree
->yyoption
;
922 yystack
->yyspaceLeft
-= 1;
923 yystack
->yynextFree
+= 1;
924 yynewItem
->yyisState
= yyfalse
;
925 yynewItem
->yystate
= rhs
;
926 yynewItem
->yyrule
= yyrule
;
927 yynewItem
->yynext
= yystate
->yysemantics
.yyfirstVal
;
928 yystate
->yysemantics
.yyfirstVal
= yynewItem
;
929 if (yystack
->yyspaceLeft
< YYHEADROOM
)
930 yyexpandGLRStack (yystack
]b4_pure_args
[);
935 /** Initialize SET to a singleton set containing an empty stack. */
937 yyinitStateSet (yyGLRStateSet
* yyset
)
940 yyset
->yycapacity
= 16;
941 yyset
->yystates
= (yyGLRState
**) YYMALLOC (16 * sizeof yyset
->yystates
[0]);
942 if (! yyset
->yystates
)
944 yyset
->yystates
[0] = NULL
;
948 static void yyfreeStateSet (yyGLRStateSet
* yyset
)
950 YYFREE (yyset
->yystates
);
953 /** Initialize STACK to a single empty stack, with total maximum
954 * capacity for all stacks of SIZE. */
956 yyinitGLRStack (yyGLRStack
* yystack
, size_t yysize
)
958 yystack
->yyerrflag
= 0;
959 yystack
->yyerrState
= 0;
961 yystack
->yyspaceLeft
= yysize
;
962 yystack
->yynextFree
= yystack
->yyitems
=
963 (yyGLRStackItem
*) YYMALLOC (yysize
* sizeof yystack
->yynextFree
[0]);
964 yystack
->yysplitPoint
= NULL
;
965 yystack
->yylastDeleted
= NULL
;
966 return yyinitStateSet (&yystack
->yytops
) && yystack
->yyitems
;
969 #define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
970 &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
972 /** If STACK is expandable, extend it. WARNING: Pointers into the
973 stack from outside should be considered invalid after this call.
974 We always expand when there are 1 or fewer items left AFTER an
975 allocation, so that we can avoid having external pointers exist
976 across an allocation. */
978 yyexpandGLRStack (yyGLRStack
* yystack
]b4_pure_formals
[)
980 #if YYSTACKEXPANDABLE
981 yyGLRStackItem
* yynewItems
;
982 yyGLRStackItem
* yyp0
, *yyp1
;
983 size_t yysize
, yynewSize
;
985 yysize
= yystack
->yynextFree
- yystack
->yyitems
;
986 if (YYMAXDEPTH
<= yysize
)
987 yyStackOverflow (yystack
]b4_pure_args
[);
988 yynewSize
= 2*yysize
;
989 if (YYMAXDEPTH
< yynewSize
)
990 yynewSize
= YYMAXDEPTH
;
991 yynewItems
= (yyGLRStackItem
*) YYMALLOC (yynewSize
* sizeof yynewItems
[0]);
993 yyStackOverflow (yystack
]b4_pure_args
[);
994 for (yyp0
= yystack
->yyitems
, yyp1
= yynewItems
, yyn
= yysize
;
996 yyn
-= 1, yyp0
+= 1, yyp1
+= 1)
999 if (*(yybool
*) yyp0
)
1001 yyGLRState
* yys0
= &yyp0
->yystate
;
1002 yyGLRState
* yys1
= &yyp1
->yystate
;
1003 if (yys0
->yypred
!= NULL
)
1005 YYRELOC (yyp0
, yyp1
, yys0
->yypred
, yystate
);
1006 if (! yys0
->yyresolved
&& yys0
->yysemantics
.yyfirstVal
!= NULL
)
1007 yys1
->yysemantics
.yyfirstVal
=
1008 YYRELOC(yyp0
, yyp1
, yys0
->yysemantics
.yyfirstVal
, yyoption
);
1012 yySemanticOption
* yyv0
= &yyp0
->yyoption
;
1013 yySemanticOption
* yyv1
= &yyp1
->yyoption
;
1014 if (yyv0
->yystate
!= NULL
)
1015 yyv1
->yystate
= YYRELOC (yyp0
, yyp1
, yyv0
->yystate
, yystate
);
1016 if (yyv0
->yynext
!= NULL
)
1017 yyv1
->yynext
= YYRELOC (yyp0
, yyp1
, yyv0
->yynext
, yyoption
);
1020 if (yystack
->yysplitPoint
!= NULL
)
1021 yystack
->yysplitPoint
= YYRELOC (yystack
->yyitems
, yynewItems
,
1022 yystack
->yysplitPoint
, yystate
);
1024 for (yyn
= 0; yyn
< yystack
->yytops
.yysize
; yyn
+= 1)
1025 if (yystack
->yytops
.yystates
[yyn
] != NULL
)
1026 yystack
->yytops
.yystates
[yyn
] =
1027 YYRELOC (yystack
->yyitems
, yynewItems
,
1028 yystack
->yytops
.yystates
[yyn
], yystate
);
1029 YYFREE (yystack
->yyitems
);
1030 yystack
->yyitems
= yynewItems
;
1031 yystack
->yynextFree
= yynewItems
+ yysize
;
1032 yystack
->yyspaceLeft
= yynewSize
- yysize
;
1036 yyStackOverflow (yystack
]b4_pure_args
[);
1041 yyfreeGLRStack (yyGLRStack
* yystack
)
1043 YYFREE (yystack
->yyitems
);
1044 yyfreeStateSet (&yystack
->yytops
);
1047 /** Assuming that S is a GLRState somewhere on STACK, update the
1048 * splitpoint of STACK, if needed, so that it is at least as deep as
1051 yyupdateSplit (yyGLRStack
* yystack
, yyGLRState
* yys
)
1053 if (yystack
->yysplitPoint
!= NULL
&& yystack
->yysplitPoint
> yys
)
1054 yystack
->yysplitPoint
= yys
;
1057 /** Invalidate stack #K in STACK. */
1059 yymarkStackDeleted (yyGLRStack
* yystack
, size_t yyk
)
1061 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1062 yystack
->yylastDeleted
= yystack
->yytops
.yystates
[yyk
];
1063 yystack
->yytops
.yystates
[yyk
] = NULL
;
1066 /** Undelete the last stack that was marked as deleted. Can only be
1067 done once after a deletion, and only when all other stacks have
1070 yyundeleteLastStack (yyGLRStack
* yystack
)
1072 if (yystack
->yylastDeleted
== NULL
|| yystack
->yytops
.yysize
!= 0)
1074 yystack
->yytops
.yystates
[0] = yystack
->yylastDeleted
;
1075 yystack
->yytops
.yysize
= 1;
1076 YYDPRINTF ((stderr
, "Restoring last deleted stack as stack #0.\n"));
1077 yystack
->yylastDeleted
= NULL
;
1081 yyremoveDeletes (yyGLRStack
* yystack
)
1085 while (yyj
< yystack
->yytops
.yysize
)
1087 if (yystack
->yytops
.yystates
[yyi
] == NULL
)
1091 YYDPRINTF ((stderr
, "Removing dead stacks.\n"));
1093 yystack
->yytops
.yysize
-= 1;
1097 yystack
->yytops
.yystates
[yyj
] = yystack
->yytops
.yystates
[yyi
];
1100 YYDPRINTF ((stderr
, "Rename stack %lu -> %lu.\n",
1101 (unsigned long int) yyi
, (unsigned long int) yyj
));
1109 /** Shift to a new state on stack #K of STACK, corresponding to LR state
1110 * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
1112 yyglrShift (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1114 YYSTYPE yysval
, YYLTYPE
* yylocp
]b4_user_formals
[)
1116 yyGLRStackItem
* yynewItem
;
1118 yynewItem
= yystack
->yynextFree
;
1119 yystack
->yynextFree
+= 1;
1120 yystack
->yyspaceLeft
-= 1;
1121 yynewItem
->yystate
.yyisState
= yytrue
;
1122 yynewItem
->yystate
.yylrState
= yylrState
;
1123 yynewItem
->yystate
.yyposn
= yyposn
;
1124 yynewItem
->yystate
.yyresolved
= yytrue
;
1125 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1126 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1127 yynewItem
->yystate
.yysemantics
.yysval
= yysval
;
1128 yynewItem
->yystate
.yyloc
= *yylocp
;
1129 if (yystack
->yyspaceLeft
< YYHEADROOM
)
1130 yyexpandGLRStack (yystack
]b4_pure_args
[);
1133 /** Shift stack #K of YYSTACK, to a new state corresponding to LR
1134 * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
1135 * semantic value of YYRHS under the action for YYRULE. */
1137 yyglrShiftDefer (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1138 size_t yyposn
, yyGLRState
* rhs
, yyRuleNum yyrule
]b4_pure_formals
[)
1140 yyGLRStackItem
* yynewItem
;
1142 yynewItem
= yystack
->yynextFree
;
1143 yynewItem
->yystate
.yyisState
= yytrue
;
1144 yynewItem
->yystate
.yylrState
= yylrState
;
1145 yynewItem
->yystate
.yyposn
= yyposn
;
1146 yynewItem
->yystate
.yyresolved
= yyfalse
;
1147 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1148 yynewItem
->yystate
.yysemantics
.yyfirstVal
= NULL
;
1149 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1150 yystack
->yynextFree
+= 1;
1151 yystack
->yyspaceLeft
-= 1;
1152 yyaddDeferredAction (yystack
, &yynewItem
->yystate
, rhs
, yyrule
]b4_pure_args
[);
1155 /** Pop the symbols consumed by reduction #RULE from the top of stack
1156 * #K of STACK, and perform the appropriate semantic action on their
1157 * semantic values. Assumes that all ambiguities in semantic values
1158 * have been previously resolved. Set *VALP to the resulting value,
1159 * and *LOCP to the computed location (if any). Return value is as
1160 * for userAction. */
1161 static inline YYRESULTTAG
1162 yydoAction (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1163 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1165 int yynrhs
= yyrhsLength (yyrule
);
1167 if (yystack
->yysplitPoint
== NULL
)
1169 /* Standard special case: single stack. */
1170 yyGLRStackItem
* rhs
= (yyGLRStackItem
*) yystack
->yytops
.yystates
[yyk
];
1171 YYASSERT (yyk
== 0);
1172 yystack
->yynextFree
-= yynrhs
;
1173 yystack
->yyspaceLeft
+= yynrhs
;
1174 yystack
->yytops
.yystates
[0] = & yystack
->yynextFree
[-1].yystate
;
1175 return yyuserAction (yyrule
, yynrhs
, rhs
,
1176 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1182 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1183 yys
= yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
1184 = yystack
->yytops
.yystates
[yyk
];
1185 for (yyi
= 0; yyi
< yynrhs
; yyi
+= 1)
1190 yyupdateSplit (yystack
, yys
);
1191 yystack
->yytops
.yystates
[yyk
] = yys
;
1192 return yyuserAction (yyrule
, yynrhs
, yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1193 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1198 # define YY_REDUCE_PRINT(K, Rule)
1200 # define YY_REDUCE_PRINT(K, Rule) \
1203 yy_reduce_print (K, Rule); \
1206 /*----------------------------------------------------------.
1207 | Report that the RULE is going to be reduced on stack #K. |
1208 `----------------------------------------------------------*/
1211 yy_reduce_print (size_t yyk
, yyRuleNum yyrule
)
1214 YYFPRINTF (stderr
, "Reducing stack %lu by rule %d (line %lu), ",
1215 (unsigned long int) yyk
, yyrule
- 1,
1216 (unsigned long int) yyrline
[yyrule
]);
1217 /* Print the symbols being reduced, and their result. */
1218 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
1219 YYFPRINTF (stderr
, "%s ", yytokenName (yyrhs
[yyi
]));
1220 YYFPRINTF (stderr
, "-> %s\n", yytokenName (yyr1
[yyrule
]));
1224 /** Pop items off stack #K of STACK according to grammar rule RULE,
1225 * and push back on the resulting nonterminal symbol. Perform the
1226 * semantic action associated with RULE and store its value with the
1227 * newly pushed state, if FORCEEVAL or if STACK is currently
1228 * unambiguous. Otherwise, store the deferred semantic action with
1229 * the new state. If the new state would have an identical input
1230 * position, LR state, and predecessor to an existing state on the stack,
1231 * it is identified with that existing state, eliminating stack #K from
1232 * the STACK. In this case, the (necessarily deferred) semantic value is
1233 * added to the options for the existing state's semantic value.
1235 static inline YYRESULTTAG
1236 yyglrReduce (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1237 yybool yyforceEval
]b4_pure_formals
[)
1239 size_t yyposn
= yystack
->yytops
.yystates
[yyk
]->yyposn
;
1241 if (yyforceEval
|| yystack
->yysplitPoint
== NULL
)
1246 YY_REDUCE_PRINT (yyk
, yyrule
);
1247 YYCHK (yydoAction (yystack
, yyk
, yyrule
, &yysval
, &yyloc
]b4_user_args
[));
1248 yyglrShift (yystack
, yyk
,
1249 yyLRgotoState (yystack
->yytops
.yystates
[yyk
]->yylrState
,
1250 yylhsNonterm (yyrule
)),
1251 yyposn
, yysval
, &yyloc
]b4_user_args
[);
1257 yyGLRState
* yys
, *yys0
= yystack
->yytops
.yystates
[yyk
];
1258 yyStateNum yynewLRState
;
1260 for (yys
= yystack
->yytops
.yystates
[yyk
], yyn
= yyrhsLength (yyrule
);
1266 yyupdateSplit (yystack
, yys
);
1267 yynewLRState
= yyLRgotoState (yys
->yylrState
, yylhsNonterm (yyrule
));
1269 "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
1270 (unsigned long int) yyk
, yyrule
- 1, yynewLRState
));
1271 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
1272 if (yyi
!= yyk
&& yystack
->yytops
.yystates
[yyi
] != NULL
)
1274 yyGLRState
* yyp
, *yysplit
= yystack
->yysplitPoint
;
1275 yyp
= yystack
->yytops
.yystates
[yyi
];
1276 while (yyp
!= yys
&& yyp
!= yysplit
&& yyp
->yyposn
>= yyposn
)
1278 if (yyp
->yylrState
== yynewLRState
&& yyp
->yypred
== yys
)
1280 yyaddDeferredAction (yystack
, yyp
, yys0
, yyrule
]b4_pure_args
[);
1281 yymarkStackDeleted (yystack
, yyk
);
1282 YYDPRINTF ((stderr
, "Merging stack %lu into stack %lu.\n",
1283 (unsigned long int) yyk
,
1284 (unsigned long int) yyi
));
1290 yystack
->yytops
.yystates
[yyk
] = yys
;
1291 yyglrShiftDefer (yystack
, yyk
, yynewLRState
, yyposn
, yys0
, yyrule
]b4_pure_args
[);
1297 yysplitStack (yyGLRStack
* yystack
, size_t yyk
]b4_pure_formals
[)
1299 if (yystack
->yysplitPoint
== NULL
)
1301 YYASSERT (yyk
== 0);
1302 yystack
->yysplitPoint
= yystack
->yytops
.yystates
[yyk
];
1304 if (yystack
->yytops
.yysize
>= yystack
->yytops
.yycapacity
)
1306 yyGLRState
** yynewStates
;
1307 if (! ((yystack
->yytops
.yycapacity
1308 <= (YYSIZEMAX
/ (2 * sizeof yynewStates
[0])))
1310 (yyGLRState
**) YYREALLOC (yystack
->yytops
.yystates
,
1311 ((yystack
->yytops
.yycapacity
*= 2)
1312 * sizeof yynewStates
[0])))))
1313 yyStackOverflow (yystack
]b4_pure_args
[);
1314 yystack
->yytops
.yystates
= yynewStates
;
1316 yystack
->yytops
.yystates
[yystack
->yytops
.yysize
]
1317 = yystack
->yytops
.yystates
[yyk
];
1318 yystack
->yytops
.yysize
+= 1;
1319 return yystack
->yytops
.yysize
-1;
1322 /** True iff Y0 and Y1 represent identical options at the top level.
1323 * That is, they represent the same rule applied to RHS symbols
1324 * that produce the same terminal symbols. */
1326 yyidenticalOptions (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1328 if (yyy0
->yyrule
== yyy1
->yyrule
)
1330 yyGLRState
*yys0
, *yys1
;
1332 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1333 yyn
= yyrhsLength (yyy0
->yyrule
);
1335 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1336 if (yys0
->yyposn
!= yys1
->yyposn
)
1344 /** Assuming identicalOptions (Y0,Y1), destructively merge the
1345 * alternative semantic values for the RHS-symbols of Y1 and Y0. */
1347 yymergeOptionSets (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1349 yyGLRState
*yys0
, *yys1
;
1351 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1352 yyn
= yyrhsLength (yyy0
->yyrule
);
1354 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1358 else if (yys0
->yyresolved
)
1360 yys1
->yyresolved
= yytrue
;
1361 yys1
->yysemantics
.yysval
= yys0
->yysemantics
.yysval
;
1363 else if (yys1
->yyresolved
)
1365 yys0
->yyresolved
= yytrue
;
1366 yys0
->yysemantics
.yysval
= yys1
->yysemantics
.yysval
;
1370 yySemanticOption
** yyz0p
;
1371 yySemanticOption
* yyz1
;
1372 yyz0p
= &yys0
->yysemantics
.yyfirstVal
;
1373 yyz1
= yys1
->yysemantics
.yyfirstVal
;
1376 if (yyz1
== *yyz0p
|| yyz1
== NULL
)
1378 else if (*yyz0p
== NULL
)
1383 else if (*yyz0p
< yyz1
)
1385 yySemanticOption
* yyz
= *yyz0p
;
1387 yyz1
= yyz1
->yynext
;
1388 (*yyz0p
)->yynext
= yyz
;
1390 yyz0p
= &(*yyz0p
)->yynext
;
1392 yys1
->yysemantics
.yyfirstVal
= yys0
->yysemantics
.yyfirstVal
;
1397 /** Y0 and Y1 represent two possible actions to take in a given
1398 * parsing state; return 0 if no combination is possible,
1399 * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
1401 yypreference (yySemanticOption
* y0
, yySemanticOption
* y1
)
1403 yyRuleNum r0
= y0
->yyrule
, r1
= y1
->yyrule
;
1404 int p0
= yydprec
[r0
], p1
= yydprec
[r1
];
1408 if (yymerger
[r0
] == 0 || yymerger
[r0
] != yymerger
[r1
])
1413 if (p0
== 0 || p1
== 0)
1422 static YYRESULTTAG
yyresolveValue (yySemanticOption
* yyoptionList
,
1423 yyGLRStack
* yystack
, YYSTYPE
* yyvalp
,
1424 YYLTYPE
* yylocp
]b4_user_formals
[);
1427 yyresolveStates (yyGLRState
* yys
, int yyn
, yyGLRStack
* yystack
]b4_user_formals
[)
1432 YYASSERT (yys
->yypred
);
1433 yyflag
= yyresolveStates (yys
->yypred
, yyn
-1, yystack
]b4_user_args
[);
1436 if (! yys
->yyresolved
)
1438 yyflag
= yyresolveValue (yys
->yysemantics
.yyfirstVal
, yystack
,
1439 &yys
->yysemantics
.yysval
, &yys
->yyloc
1443 yys
->yyresolved
= yytrue
;
1450 yyresolveAction (yySemanticOption
* yyopt
, yyGLRStack
* yystack
,
1451 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1453 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1456 yynrhs
= yyrhsLength (yyopt
->yyrule
);
1457 YYCHK (yyresolveStates (yyopt
->yystate
, yynrhs
, yystack
]b4_user_args
[));
1458 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
= yyopt
->yystate
;
1459 return yyuserAction (yyopt
->yyrule
, yynrhs
,
1460 yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1461 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1466 yyreportTree (yySemanticOption
* yyx
, int yyindent
)
1468 int yynrhs
= yyrhsLength (yyx
->yyrule
);
1471 yyGLRState
* yystates
[YYMAXRHS
];
1472 yyGLRState yyleftmost_state
;
1474 for (yyi
= yynrhs
, yys
= yyx
->yystate
; 0 < yyi
; yyi
-= 1, yys
= yys
->yypred
)
1475 yystates
[yyi
] = yys
;
1478 yyleftmost_state
.yyposn
= 0;
1479 yystates
[0] = &yyleftmost_state
;
1484 if (yyx
->yystate
->yyposn
< yys
->yyposn
+ 1)
1485 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, empty>\n",
1486 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1489 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
1490 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1491 yyx
->yyrule
, (unsigned long int) (yys
->yyposn
+ 1),
1492 (unsigned long int) yyx
->yystate
->yyposn
);
1493 for (yyi
= 1; yyi
<= yynrhs
; yyi
+= 1)
1495 if (yystates
[yyi
]->yyresolved
)
1497 if (yystates
[yyi
-1]->yyposn
+1 > yystates
[yyi
]->yyposn
)
1498 YYFPRINTF (stderr
, "%*s%s <empty>\n", yyindent
+2, "",
1499 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]));
1501 YYFPRINTF (stderr
, "%*s%s <tokens %lu .. %lu>\n", yyindent
+2, "",
1502 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]),
1503 (unsigned long int) (yystates
[yyi
- 1]->yyposn
+ 1),
1504 (unsigned long int) yystates
[yyi
]->yyposn
);
1507 yyreportTree (yystates
[yyi
]->yysemantics
.yyfirstVal
, yyindent
+2);
1513 yyreportAmbiguity (yySemanticOption
* yyx0
, yySemanticOption
* yyx1
,
1514 yyGLRStack
* yystack
]b4_pure_formals
[)
1516 /* `Unused' warnings. */
1521 YYFPRINTF (stderr
, "Ambiguity detected.\n");
1522 YYFPRINTF (stderr
, "Option 1,\n");
1523 yyreportTree (yyx0
, 2);
1524 YYFPRINTF (stderr
, "\nOption 2,\n");
1525 yyreportTree (yyx1
, 2);
1526 YYFPRINTF (stderr
, "\n");
1528 yyFail (yystack
][]b4_pure_args
[, "ambiguity detected");
1532 /** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
1533 * actions, and return the result. */
1535 yyresolveValue (yySemanticOption
* yyoptionList
, yyGLRStack
* yystack
,
1536 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1538 yySemanticOption
* yybest
;
1539 yySemanticOption
* yyp
;
1542 yybest
= yyoptionList
;
1544 for (yyp
= yyoptionList
->yynext
; yyp
!= NULL
; yyp
= yyp
->yynext
)
1546 if (yyidenticalOptions (yybest
, yyp
))
1547 yymergeOptionSets (yybest
, yyp
);
1549 switch (yypreference (yybest
, yyp
))
1552 yyreportAmbiguity (yybest
, yyp
, yystack
]b4_pure_args
[);
1568 int yyprec
= yydprec
[yybest
->yyrule
];
1569 YYCHK (yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[));
1570 for (yyp
= yybest
->yynext
; yyp
!= NULL
; yyp
= yyp
->yynext
)
1572 if (yyprec
== yydprec
[yyp
->yyrule
])
1576 YYCHK (yyresolveAction (yyp
, yystack
, &yyval1
, &yydummy
]b4_user_args
[));
1577 yyuserMerge (yymerger
[yyp
->yyrule
], yyvalp
, &yyval1
);
1583 return yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[);
1587 yyresolveStack (yyGLRStack
* yystack
]b4_user_formals
[)
1589 if (yystack
->yysplitPoint
!= NULL
)
1594 for (yyn
= 0, yys
= yystack
->yytops
.yystates
[0];
1595 yys
!= yystack
->yysplitPoint
;
1596 yys
= yys
->yypred
, yyn
+= 1)
1598 YYCHK (yyresolveStates (yystack
->yytops
.yystates
[0], yyn
, yystack
1605 yycompressStack (yyGLRStack
* yystack
)
1607 yyGLRState
* yyp
, *yyq
, *yyr
;
1609 if (yystack
->yytops
.yysize
!= 1 || yystack
->yysplitPoint
== NULL
)
1612 for (yyp
= yystack
->yytops
.yystates
[0], yyq
= yyp
->yypred
, yyr
= NULL
;
1613 yyp
!= yystack
->yysplitPoint
;
1614 yyr
= yyp
, yyp
= yyq
, yyq
= yyp
->yypred
)
1617 yystack
->yyspaceLeft
+= yystack
->yynextFree
- yystack
->yyitems
;
1618 yystack
->yynextFree
= ((yyGLRStackItem
*) yystack
->yysplitPoint
) + 1;
1619 yystack
->yyspaceLeft
-= yystack
->yynextFree
- yystack
->yyitems
;
1620 yystack
->yysplitPoint
= NULL
;
1621 yystack
->yylastDeleted
= NULL
;
1625 yystack
->yynextFree
->yystate
= *yyr
;
1627 yystack
->yynextFree
->yystate
.yypred
= & yystack
->yynextFree
[-1].yystate
;
1628 yystack
->yytops
.yystates
[0] = &yystack
->yynextFree
->yystate
;
1629 yystack
->yynextFree
+= 1;
1630 yystack
->yyspaceLeft
-= 1;
1635 yyprocessOneStack (yyGLRStack
* yystack
, size_t yyk
,
1636 size_t yyposn
, YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
1640 const short int* yyconflicts
;
1642 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1644 while (yystack
->yytops
.yystates
[yyk
] != NULL
)
1646 yyStateNum yystate
= yystack
->yytops
.yystates
[yyk
]->yylrState
;
1647 YYDPRINTF ((stderr
, "Stack %lu Entering state %d\n",
1648 (unsigned long int) yyk
, yystate
));
1650 YYASSERT (yystate
!= YYFINAL
);
1652 if (yyisDefaultedState (yystate
))
1654 yyrule
= yydefaultAction (yystate
);
1657 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1658 (unsigned long int) yyk
));
1659 yymarkStackDeleted (yystack
, yyk
);
1662 YYCHK (yyglrReduce (yystack
, yyk
, yyrule
, yyfalse
]b4_lpure_args
[));
1666 if (*yytokenp
== YYEMPTY
)
1668 YYDPRINTF ((stderr
, "Reading a token: "));
1670 *yytokenp
= YYTRANSLATE (yychar
);
1671 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1672 YYDPRINTF ((stderr
, "\n"));
1674 yygetLRActions (yystate
, *yytokenp
, &yyaction
, &yyconflicts
);
1676 while (*yyconflicts
!= 0)
1678 size_t yynewStack
= yysplitStack (yystack
, yyk
]b4_pure_args
[);
1679 YYDPRINTF ((stderr
, "Splitting off stack %lu from %lu.\n",
1680 (unsigned long int) yynewStack
,
1681 (unsigned long int) yyk
));
1682 YYCHK (yyglrReduce (yystack
, yynewStack
,
1683 *yyconflicts
, yyfalse
]b4_lpure_args
[));
1684 YYCHK (yyprocessOneStack (yystack
, yynewStack
, yyposn
,
1685 yylvalp
, yyllocp
]b4_pure_args
[));
1689 if (yyisShiftAction (yyaction
))
1691 YYDPRINTF ((stderr
, "On stack %lu, ", (unsigned long int) yyk
));
1692 YY_SYMBOL_PRINT ("shifting", *yytokenp
, yylvalp
, yyllocp
);
1693 yyglrShift (yystack
, yyk
, yyaction
, yyposn
+1,
1694 *yylvalp
, yyllocp
]b4_user_args
[);
1695 YYDPRINTF ((stderr
, ", now in state #%d\n",
1696 yystack
->yytops
.yystates
[yyk
]->yylrState
));
1699 else if (yyisErrorAction (yyaction
))
1701 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1702 (unsigned long int) yyk
));
1703 yymarkStackDeleted (yystack
, yyk
);
1707 YYCHK (yyglrReduce (yystack
, yyk
, -yyaction
, yyfalse
]b4_lpure_args
[));
1714 yyreportSyntaxError (yyGLRStack
* yystack
,
1715 YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
]b4_user_formals
[)
1717 /* `Unused' warnings. */
1721 if (yystack
->yyerrState
== 0)
1724 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1726 yyn
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1727 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1729 size_t yysize0
= strlen (yytokenName (*yytokenp
));
1730 size_t yysize
= yysize0
;
1732 yybool yysize_overflow
= yyfalse
;
1734 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1735 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1739 static char const yyunexpected
[] = "syntax error, unexpected %s";
1740 static char const yyexpecting
[] = ", expecting %s";
1741 static char const yyor
[] = " or %s";
1742 char yyformat
[sizeof yyunexpected
1743 + sizeof yyexpecting
- 1
1744 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1745 * (sizeof yyor
- 1))];
1746 char const *yyprefix
= yyexpecting
;
1748 /* Start YYX at -YYN if negative to avoid negative indexes in
1750 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1752 /* Stay within bounds of both yycheck and yytname. */
1753 int yychecklim
= YYLAST
- yyn
;
1754 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1757 yyarg
[0] = yytokenName (*yytokenp
);
1758 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1760 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1761 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1763 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1767 yyformat
[sizeof yyunexpected
- 1] = '\0';
1770 yyarg
[yycount
++] = yytokenName (yyx
);
1771 yysize1
= yysize
+ strlen (yytokenName (yyx
));
1772 yysize_overflow
|= yysize1
< yysize
;
1774 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1779 yysize1
= yysize
+ (yyfmt
- yyformat
);
1780 yysize_overflow
|= yysize1
< yysize
;
1783 if (!yysize_overflow
)
1784 yymsg
= (char *) YYMALLOC (yysize
);
1790 while ((*yyp
= *yyf
))
1792 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1794 yyp
= yystpcpy (yyp
, yyarg
[yyi
++]);
1803 yyerror (]b4_lyyerror_args
[yymsg
);
1807 yyerror (]b4_lyyerror_args
["syntax error; also virtual memory exhausted");
1810 #endif /* YYERROR_VERBOSE */
1811 yyerror (]b4_lyyerror_args
["syntax error");
1816 /* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
1817 YYLVALP, and YYLLOCP point to the syntactic category, semantic
1818 value, and location of the look-ahead. */
1820 yyrecoverSyntaxError (yyGLRStack
* yystack
,
1822 YYLTYPE
* YYOPTIONAL_LOC (yyllocp
)
1825 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1829 if (yystack
->yyerrState
== 3)
1830 /* We just shifted the error token and (perhaps) took some
1831 reductions. Skip tokens until we can proceed. */
1834 if (*yytokenp
== YYEOF
)
1836 /* Now pop stack until empty and fail. */
1837 while (yystack
->yytops
.yystates
[0] != NULL
)
1839 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
1840 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]])[
1841 yydestruct ("Error: popping",
1842 yystos
[yys
->yylrState
],
1843 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[);
1844 yystack
->yytops
.yystates
[0] = yys
->yypred
;
1845 yystack
->yynextFree
-= 1;
1846 yystack
->yyspaceLeft
+= 1;
1848 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1850 if (*yytokenp
!= YYEMPTY
)
1852 /* We throw away the lookahead, but the error range
1853 of the shifted error token must take it into account. */
1854 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
1855 yyGLRStackItem yyerror_range
[3];
1856 yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;
1857 yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
1858 YYLLOC_DEFAULT (yys
->yyloc
, yyerror_range
, 2);]])[
1859 yydestruct ("Error: discarding",
1860 *yytokenp
, yylvalp
]b4_location_if([, yyllocp
])[);
1862 YYDPRINTF ((stderr
, "Reading a token: "));
1864 *yytokenp
= YYTRANSLATE (yychar
);
1865 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1866 YYDPRINTF ((stderr
, "\n"));
1867 yyj
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1868 if (yyis_pact_ninf (yyj
))
1871 if (yyj
< 0 || YYLAST
< yyj
|| yycheck
[yyj
] != *yytokenp
)
1873 if (yydefact
[yystack
->yytops
.yystates
[0]->yylrState
] != 0)
1876 else if (yytable
[yyj
] != 0 && ! yyis_table_ninf (yytable
[yyj
]))
1880 /* Reduce to one stack. */
1881 for (yyk
= 0; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
1882 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1884 if (yyk
>= yystack
->yytops
.yysize
)
1885 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1886 for (yyk
+= 1; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
1887 yymarkStackDeleted (yystack
, yyk
);
1888 yyremoveDeletes (yystack
);
1889 yycompressStack (yystack
);
1891 /* Now pop stack until we find a state that shifts the error token. */
1892 yystack
->yyerrState
= 3;
1893 while (yystack
->yytops
.yystates
[0] != NULL
)
1895 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
1896 yyj
= yypact
[yys
->yylrState
];
1897 if (! yyis_pact_ninf (yyj
))
1900 if (0 <= yyj
&& yyj
<= YYLAST
&& yycheck
[yyj
] == YYTERROR
1901 && yyisShiftAction (yytable
[yyj
]))
1903 /* Shift the error token having adjusted its location. */
1904 YYLTYPE yyerrloc
;]b4_location_if([[
1905 yystack
->yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
1906 YYLLOC_DEFAULT (yyerrloc
, yystack
->yyerror_range
, 2);]])[
1907 YY_SYMBOL_PRINT ("Shifting", yystos
[yytable
[yyj
]],
1908 yylvalp
, &yyerrloc
);
1909 YYDPRINTF ((stderr
, "\n"));
1910 yyglrShift (yystack
, 0, yytable
[yyj
],
1911 yys
->yyposn
, *yylvalp
, &yyerrloc
]b4_user_args
[);
1912 yys
= yystack
->yytops
.yystates
[0];
1916 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]])[
1917 yydestruct ("Error: popping",
1918 yystos
[yys
->yylrState
],
1919 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[);
1920 yystack
->yytops
.yystates
[0] = yys
->yypred
;
1921 yystack
->yynextFree
-= 1;
1922 yystack
->yyspaceLeft
+= 1;
1924 if (yystack
->yytops
.yystates
[0] == NULL
)
1925 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1928 #define YYCHK1(YYE) \
1934 yystack.yyerrflag = 1; \
1937 yystack.yyerrflag = 0; \
1940 goto yyuser_error; \
1949 ]b4_c_ansi_function_def([yyparse
], [int], b4_parse_param
)[
1959 #define yychar (yystack.yyrawchar)
1962 YYSTYPE
* const yylvalp
= &yylval
;
1963 YYLTYPE
* const yyllocp
= &yylloc
;
1965 YYDPRINTF ((stderr
, "Starting parse\n"));
1969 if (setjmp (yystack
.yyexception_buffer
) != 0)
1972 if (! yyinitGLRStack (&yystack
, YYINITDEPTH
))
1974 yystack
.yytokenp
= &yytoken
;
1976 yylval
= yyval_default
;
1978 #if YYLTYPE_IS_TRIVIAL
1979 yylloc
.first_line
= yylloc
.last_line
= 1;
1980 yylloc
.first_column
= yylloc
.last_column
= 0;
1983 m4_ifdef([b4_initial_action
], [
1984 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
1985 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
1986 /* User initialization code. */
1988 m4_popdef([b4_dollar_dollar
])dnl
1989 m4_popdef([b4_at_dollar
])dnl
1990 /* Line __line__ of glr.c. */
1991 b4_syncline([@oline@
], [@ofile@
])])dnl
1993 yyglrShift (&yystack
, 0, 0, 0, yylval
, &yylloc
]b4_user_args
[);
1998 /* For efficiency, we have two loops, the first of which is
1999 specialized to deterministic operation (single stack, no
2000 potential ambiguity). */
2006 const short int* yyconflicts
;
2008 yyStateNum yystate
= yystack
.yytops
.yystates
[0]->yylrState
;
2009 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
2010 if (yystate
== YYFINAL
)
2012 if (yyisDefaultedState (yystate
))
2014 yyrule
= yydefaultAction (yystate
);
2017 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2018 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2021 YYCHK1 (yyglrReduce (&yystack
, 0, yyrule
, yytrue
]b4_lpure_args
[));
2025 if (yytoken
== YYEMPTY
)
2027 YYDPRINTF ((stderr
, "Reading a token: "));
2029 yytoken
= YYTRANSLATE (yychar
);
2030 YY_SYMBOL_PRINT ("Next token is", yytoken
, yylvalp
, yyllocp
);
2031 YYDPRINTF ((stderr
, "\n"));
2033 yygetLRActions (yystate
, yytoken
, &yyaction
, &yyconflicts
);
2034 if (*yyconflicts
!= 0)
2036 if (yyisShiftAction (yyaction
))
2038 YY_SYMBOL_PRINT ("Shifting", yytoken
, yylvalp
, yyllocp
);
2039 YYDPRINTF ((stderr
, "\n"));
2040 if (yytoken
!= YYEOF
)
2043 yyglrShift (&yystack
, 0, yyaction
, yyposn
,
2044 yylval
, yyllocp
]b4_user_args
[);
2045 if (0 < yystack
.yyerrState
)
2046 yystack
.yyerrState
-= 1;
2048 else if (yyisErrorAction (yyaction
))
2050 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2051 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2055 YYCHK1 (yyglrReduce (&yystack
, 0, -yyaction
, yytrue
]b4_lpure_args
[));
2062 size_t yyn
= yystack
.yytops
.yysize
;
2063 for (yys
= 0; yys
< yyn
; yys
+= 1)
2064 YYCHK1 (yyprocessOneStack (&yystack
, yys
, yyposn
,
2065 yylvalp
, yyllocp
]b4_lpure_args
[));
2068 yyremoveDeletes (&yystack
);
2069 if (yystack
.yytops
.yysize
== 0)
2071 yyundeleteLastStack (&yystack
);
2072 if (yystack
.yytops
.yysize
== 0)
2073 yyFail (&yystack
][]b4_lpure_args
[, "syntax error");
2074 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2075 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2076 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2077 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2080 else if (yystack
.yytops
.yysize
== 1)
2082 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2083 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2084 yycompressStack (&yystack
);
2090 yyrecoverSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2091 yyposn
= yystack
.yytops
.yystates
[0]->yyposn
;
2094 /* On YYABORT, free the lookahead. */
2095 if (yystack
.yyerrflag
== 1 && yytoken
!= YYEMPTY
)
2096 yydestruct ("Error: discarding lookahead",
2097 yytoken
, yylvalp
]b4_location_if([, yyllocp
])[);
2099 yyfreeGLRStack (&yystack
);
2100 return yystack
.yyerrflag
;
2103 /* DEBUGGING ONLY */
2105 static void yypstack (yyGLRStack
* yystack
, size_t yyk
) ATTRIBUTE_UNUSED
;
2106 static void yypdumpstack (yyGLRStack
* yystack
) ATTRIBUTE_UNUSED
;
2109 yy_yypstack (yyGLRState
* yys
)
2113 yy_yypstack (yys
->yypred
);
2114 fprintf (stderr
, " -> ");
2116 fprintf (stderr
, "%d@@%lu", yys
->yylrState
, (unsigned long int) yys
->yyposn
);
2120 yypstates (yyGLRState
* yyst
)
2123 fprintf (stderr
, "<null>");
2126 fprintf (stderr
, "\n");
2130 yypstack (yyGLRStack
* yystack
, size_t yyk
)
2132 yypstates (yystack
->yytops
.yystates
[yyk
]);
2135 #define YYINDEX(YYX) \
2136 ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
2140 yypdumpstack (yyGLRStack
* yystack
)
2142 yyGLRStackItem
* yyp
;
2144 for (yyp
= yystack
->yyitems
; yyp
< yystack
->yynextFree
; yyp
+= 1)
2146 fprintf (stderr
, "%3lu. ", (unsigned long int) (yyp
- yystack
->yyitems
));
2147 if (*(yybool
*) yyp
)
2149 fprintf (stderr
, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
2150 yyp
->yystate
.yyresolved
, yyp
->yystate
.yylrState
,
2151 (unsigned long int) yyp
->yystate
.yyposn
,
2152 (long int) YYINDEX (yyp
->yystate
.yypred
));
2153 if (! yyp
->yystate
.yyresolved
)
2154 fprintf (stderr
, ", firstVal: %ld",
2155 (long int) YYINDEX (yyp
->yystate
.yysemantics
.yyfirstVal
));
2159 fprintf (stderr
, "Option. rule: %d, state: %ld, next: %ld",
2160 yyp
->yyoption
.yyrule
,
2161 (long int) YYINDEX (yyp
->yyoption
.yystate
),
2162 (long int) YYINDEX (yyp
->yyoption
.yynext
));
2164 fprintf (stderr
, "\n");
2166 fprintf (stderr
, "Tops:");
2167 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
2168 fprintf (stderr
, "%lu: %ld; ", (unsigned long int) yyi
,
2169 (long int) YYINDEX (yystack
->yytops
.yystates
[yyi
]));
2170 fprintf (stderr
, "\n");
2176 m4_if(b4_defines_flag
, 0, [],
2177 [@output @output_header_name@
2178 b4_copyright([Skeleton parser
for GLR parsing with Bison
],
2179 [2002, 2003, 2004, 2005])
2181 b4_token_defines(b4_tokens
)
2183 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
2184 m4_ifdef([b4_stype
],
2185 [b4_syncline([b4_stype_line
], [b4_filename
])
2186 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
2187 /* Line __line__ of glr.c. */
2188 b4_syncline([@oline@
], [@ofile@
])],
2189 [typedef int YYSTYPE
;])
2190 # define YYSTYPE_IS_DECLARED 1
2191 # define YYSTYPE_IS_TRIVIAL 1
2195 [extern YYSTYPE b4_prefix
[]lval
;])
2197 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
2198 typedef struct YYLTYPE
2209 # define YYLTYPE_IS_DECLARED 1
2210 # define YYLTYPE_IS_TRIVIAL 1
2213 b4_location_if([b4_pure_if([],
2214 [extern YYLTYPE b4_prefix
[]lloc
;])