1 m4_divert(-1) -*- C
-*-
3 # GLR skeleton for Bison
4 # Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 ## ---------------- ##
24 ## ---------------- ##
27 m4_define_default([b4_stack_depth_max
], [10000])
28 m4_define_default([b4_stack_depth_init
], [200])
32 ## ------------------------ ##
33 ## Pure/impure interfaces. ##
34 ## ------------------------ ##
39 # Accumule in b4_lex_param all the yylex arguments.
40 # Yes, this is quite ugly...
41 m4_define([b4_lex_param
],
42 m4_dquote(b4_pure_if([[[[YYSTYPE
*]], [[yylvalp]]][]dnl
43 b4_location_if([, [[YYLTYPE
*], [yyllocp
]]])])dnl
44 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
)))
49 m4_define([b4_user_formals
],
50 [m4_ifset([b4_parse_param
], [, b4_c_ansi_formals(b4_parse_param
)])])
55 # Arguments passed to yyerror: user args plus yylloc.
56 m4_define([b4_yyerror_args
],
57 [b4_pure_if([b4_location_if([yylocp
, ])])dnl
58 m4_ifset([b4_parse_param
], [b4_c_args(b4_parse_param
), ])])
63 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
64 m4_define([b4_lyyerror_args
],
65 [b4_pure_if([b4_location_if([yyllocp
, ])])dnl
66 m4_ifset([b4_parse_param
], [b4_c_args(b4_parse_param
), ])])
71 # Arguments needed by yyerror: user args plus yylloc.
72 m4_define([b4_pure_args
],
73 [b4_pure_if([b4_location_if([, yylocp
])])[]b4_user_args
])
78 # Arguments passed to yyerror: user formals plus yyllocp.
79 m4_define([b4_pure_formals
],
80 [b4_pure_if([b4_location_if([, YYLTYPE
*yylocp
])])[]b4_user_formals
])
85 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
86 m4_define([b4_lpure_args
],
87 [b4_pure_if([b4_location_if([, yyllocp
])])[]b4_user_args
])
92 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
93 m4_define([b4_lpure_formals
],
94 [b4_pure_if([b4_location_if([YYLTYPE
*yyllocp
])])[]b4_user_formals
])
97 ## ----------------- ##
98 ## Semantic Values. ##
99 ## ----------------- ##
102 # b4_lhs_value([TYPE])
103 # --------------------
104 # Expansion of $<TYPE>$.
105 m4_define([b4_lhs_value
],
106 [((*yyvalp
)[]m4_ifval([$
1], [.$
1]))])
109 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
110 # --------------------------------------
111 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
113 m4_define([b4_rhs_value
],
114 [(((yyGLRStackItem
const *)yyvsp
)@
{YYFILL (m4_eval([$
2 - $
1]))@
}.yystate
.yysemantics
.yysval
[]m4_ifval([$
3], [.$
3]))])
125 m4_define([b4_lhs_location
],
129 # b4_rhs_location(RULE-LENGTH, NUM)
130 # ---------------------------------
131 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
133 m4_define([b4_rhs_location
],
134 [(((yyGLRStackItem
const *)yyvsp
)@
{YYFILL (m4_eval([$
2 - $
1]))@
}.yystate
.yyloc
)])
136 # We do want M4 expansion after # for CPP macros.
139 @output @output_parser_name@
140 b4_copyright([Skeleton parser
for GLR parsing with Bison
],
141 [2002, 2003, 2004, 2005])
143 /* This is the parser code for GLR (Generalized LR) parser. */
146 m4_if(b4_prefix
[], [yy
], [],
147 [/* Substitute the variable and function names. */
148 #define yyparse b4_prefix[]parse
149 #define yylex b4_prefix[]lex
150 #define yyerror b4_prefix[]error
151 #define yylval b4_prefix[]lval
152 #define yychar b4_prefix[]char
153 #define yydebug b4_prefix[]debug
154 #define yynerrs b4_prefix[]nerrs
155 #define yylloc b4_prefix[]lloc])
157 b4_token_defines(b4_tokens
)
159 /* Copy the first part of user declarations. */
162 /* Enabling traces. */
164 # define YYDEBUG ]b4_debug[
167 /* Enabling verbose error messages. */
168 #ifdef YYERROR_VERBOSE
169 # undef YYERROR_VERBOSE
170 # define YYERROR_VERBOSE 1
172 # define YYERROR_VERBOSE ]b4_error_verbose[
175 /* Enabling the token table. */
176 #ifndef YYTOKEN_TABLE
177 # define YYTOKEN_TABLE ]b4_token_table[
180 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
181 ]m4_ifdef([b4_stype
],
182 [b4_syncline([b4_stype_line
], [b4_filename
])
183 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
184 /* Line __line__ of glr.c. */
185 b4_syncline([@oline@
], [@ofile@
])],
186 [typedef int YYSTYPE
;])[
187 # define YYSTYPE_IS_DECLARED 1
188 # define YYSTYPE_IS_TRIVIAL 1
191 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
192 typedef struct YYLTYPE
203 # define YYLTYPE_IS_DECLARED 1
204 # define YYLTYPE_IS_TRIVIAL 1
207 /* Default (constant) value used for initialization for null
208 right-hand sides. Unlike the standard yacc.c template,
209 here we set the default value of $$ to a zeroed-out value.
210 Since the default value is undefined, this behavior is
211 technically correct. */
212 static YYSTYPE yyval_default
;
214 /* Copy the second part of user declarations. */
217 ]/* Line __line__ of glr.c. */
218 b4_syncline([@oline@
], [@ofile@
])
229 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
230 # define YY_(msgid) dgettext ("bison-runtime", msgid)
234 # define YY_(msgid) msgid
242 # define YYMALLOC malloc
245 # define YYREALLOC realloc
248 #define YYSIZEMAX ((size_t) -1)
253 typedef unsigned char yybool
;
262 #ifndef __attribute__
263 /* This feature is available in gcc versions 2.5 and later. */
264 # if !defined (__GNUC__) || __GNUC__ < 2 || \
265 (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
266 # define __attribute__(Spec) /* empty */
268 ]b4_location_if([# define YYOPTIONAL_LOC(Name) Name],[
269 # if defined (__cplusplus)
270 # define YYOPTIONAL_LOC(Name) /* empty */
272 # define YYOPTIONAL_LOC(Name) Name ATTRIBUTE_UNUSED
278 # define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
281 #ifndef ATTRIBUTE_UNUSED
282 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
285 /* YYFINAL -- State number of the termination state. */
286 #define YYFINAL ]b4_final_state_number[
287 /* YYLAST -- Last index in YYTABLE. */
288 #define YYLAST ]b4_last[
290 /* YYNTOKENS -- Number of terminals. */
291 #define YYNTOKENS ]b4_tokens_number[
292 /* YYNNTS -- Number of nonterminals. */
293 #define YYNNTS ]b4_nterms_number[
294 /* YYNRULES -- Number of rules. */
295 #define YYNRULES ]b4_rules_number[
296 /* YYNRULES -- Number of states. */
297 #define YYNSTATES ]b4_states_number[
298 /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
299 #define YYMAXRHS ]b4_r2_max[
300 /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
301 accessed by $0, $-1, etc., in any rule. */
302 #define YYMAXLEFT ]b4_max_left_semantic_context[
304 /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
305 #define YYUNDEFTOK ]b4_undef_token_number[
306 #define YYMAXUTOK ]b4_user_token_number_max[
308 #define YYTRANSLATE(YYX) \
309 ((YYX <= 0) ? YYEOF : \
310 (unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
312 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
313 static const ]b4_int_type_for([b4_translate
])[ yytranslate
[] =
319 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
321 static const ]b4_int_type_for([b4_prhs
])[ yyprhs
[] =
326 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
327 static const ]b4_int_type_for([b4_rhs
])[ yyrhs
[] =
332 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
333 static const ]b4_int_type_for([b4_rline
])[ yyrline
[] =
339 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
340 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
341 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
342 static const char *const yytname
[] =
348 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
349 static const ]b4_int_type_for([b4_r1
])[ yyr1
[] =
354 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
355 static const ]b4_int_type_for([b4_r2
])[ yyr2
[] =
360 /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
361 static const ]b4_int_type_for([b4_dprec
])[ yydprec
[] =
366 /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
367 static const ]b4_int_type_for([b4_merger
])[ yymerger
[] =
372 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
373 doesn't specify something else to do. Zero means the default is an
375 static const ]b4_int_type_for([b4_defact
])[ yydefact
[] =
380 /* YYPDEFGOTO[NTERM-NUM]. */
381 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto
[] =
386 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
388 #define YYPACT_NINF ]b4_pact_ninf[
389 static const ]b4_int_type_for([b4_pact
])[ yypact
[] =
394 /* YYPGOTO[NTERM-NUM]. */
395 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto
[] =
400 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
401 positive, shift that token. If negative, reduce the rule which
402 number is the opposite. If zero, do what YYDEFACT says.
403 If YYTABLE_NINF, syntax error. */
404 #define YYTABLE_NINF ]b4_table_ninf[
405 static const ]b4_int_type_for([b4_table
])[ yytable
[] =
410 /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
411 list of conflicting reductions corresponding to action entry for
412 state STATE-NUM in yytable. 0 means no conflicts. The list in
413 yyconfl is terminated by a rule number of 0. */
414 static const ]b4_int_type_for([b4_conflict_list_heads
])[ yyconflp
[] =
416 ]b4_conflict_list_heads
[
419 /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
420 0, pointed into by YYCONFLP. */
421 ]dnl Do
not use b4_int_type_for here
, since there are places where
422 dnl pointers onto yyconfl are taken
, which type is
"short int *".
423 dnl We probably ought to introduce a type
for confl
.
424 [static const short int yyconfl
[] =
426 ]b4_conflicting_rules
[
429 static const ]b4_int_type_for([b4_check
])[ yycheck
[] =
434 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
435 symbol of state STATE-NUM. */
436 static const ]b4_int_type_for([b4_stos
])[ yystos
[] =
442 /* Prevent warning if -Wmissing-prototypes. */
443 ]b4_c_ansi_function_decl([yyparse
], [int], b4_parse_param
)[
445 /* Error token number */
448 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
449 If N is 0, then set CURRENT to the empty location which ends
450 the previous symbol: RHS[0] (always defined). */
453 #define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
454 #ifndef YYLLOC_DEFAULT
455 # define YYLLOC_DEFAULT(Current, Rhs, N) \
459 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
460 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
461 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
462 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
466 (Current).first_line = (Current).last_line = \
467 YYRHSLOC (Rhs, 0).last_line; \
468 (Current).first_column = (Current).last_column = \
469 YYRHSLOC (Rhs, 0).last_column; \
473 /* YY_LOCATION_PRINT -- Print the location on the stream.
474 This macro was not mandated originally: define only if we know
475 we won't break user code: when these are the locations we know. */
477 # define YY_LOCATION_PRINT(File, Loc) \
478 fprintf (File, "%d.%d-%d.%d", \
479 (Loc).first_line, (Loc).first_column, \
480 (Loc).last_line, (Loc).last_column)
483 #ifndef YYLLOC_DEFAULT
484 # define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)
488 #ifndef YY_LOCATION_PRINT
489 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
493 /* YYLEX -- calling `yylex' with the right arguments. */
494 #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
499 #define yynerrs (yystack->yyerrcnt)
501 #define yychar (yystack->yyrawchar)],
509 static const int YYEOF
= 0;
510 static const int YYEMPTY
= -2;
512 typedef enum { yyok
, yyaccept
, yyabort
, yyerr
} YYRESULTTAG
;
515 do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
520 #if ! defined (YYFPRINTF)
521 # define YYFPRINTF fprintf
524 # define YYDPRINTF(Args) \
530 ]b4_yysymprint_generate([b4_c_ansi_function_def
])[
532 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
536 YYFPRINTF (stderr, "%s ", Title); \
537 yysymprint (stderr, \
538 Type, Value]b4_location_if([, Location])[); \
542 /* Nonzero means print parse trace. It is left uninitialized so that
543 multiple parsers can coexist. */
548 # define YYDPRINTF(Args)
549 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
551 #endif /* !YYDEBUG */
553 /* YYINITDEPTH -- initial size of the parser's stacks. */
555 # define YYINITDEPTH ]b4_stack_depth_init[
558 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
559 if the built-in stack extension method is used).
561 Do not make this value too large; the results are undefined if
562 SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
563 evaluated with infinite-precision integer arithmetic. */
566 # define YYMAXDEPTH ]b4_stack_depth_max[
569 /* Minimum number of free items on the stack allowed after an
570 allocation. This is to allow allocation and initialization
571 to be completed by functions that call yyexpandGLRStack before the
572 stack is expanded, thus insuring that all necessary pointers get
573 properly redirected to new data. */
576 #ifndef YYSTACKEXPANDABLE
577 # if (! defined (__cplusplus) \
578 || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \
579 && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))
580 # define YYSTACKEXPANDABLE 1
582 # define YYSTACKEXPANDABLE 0
589 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
590 # define yystpcpy stpcpy
592 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
595 yystpcpy (char *yydest
, const char *yysrc
)
598 const char *yys
= yysrc
;
600 while ((*yyd
++ = *yys
++) != '\0')
609 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
610 quotes and backslashes, so that it's suitable for yyerror. The
611 heuristic is that double-quoting is unnecessary unless the string
612 contains an apostrophe, a comma, or backslash (other than
613 backslash-backslash). YYSTR is taken from yytname. If YYRES is
614 null, do not copy; instead, return the length of what the result
617 yytnamerr (char *yyres
, const char *yystr
)
622 char const *yyp
= yystr
;
629 goto do_not_strip_quotes
;
633 goto do_not_strip_quotes
;
646 do_not_strip_quotes
: ;
650 return strlen (yystr
);
652 return yystpcpy (yyres
, yystr
) - yyres
;
656 #endif /* !YYERROR_VERBOSE */
658 /** State numbers, as in LALR(1) machine */
659 typedef int yyStateNum
;
661 /** Rule numbers, as in LALR(1) machine */
662 typedef int yyRuleNum
;
664 /** Grammar symbol */
665 typedef short int yySymbol
;
667 /** Item references, as in LALR(1) machine */
668 typedef short int yyItemNum
;
670 typedef struct yyGLRState yyGLRState
;
671 typedef struct yySemanticOption yySemanticOption
;
672 typedef union yyGLRStackItem yyGLRStackItem
;
673 typedef struct yyGLRStack yyGLRStack
;
674 typedef struct yyGLRStateSet yyGLRStateSet
;
677 /** Type tag: always true. */
679 /** Type tag for yysemantics. If true, yysval applies, otherwise
680 * yyfirstVal applies. */
682 /** Number of corresponding LALR(1) machine state. */
683 yyStateNum yylrState
;
684 /** Preceding state in this stack */
686 /** Source position of the first token produced by my symbol */
689 /** First in a chain of alternative reductions producing the
690 * non-terminal corresponding to this state, threaded through
692 yySemanticOption
* yyfirstVal
;
693 /** Semantic value for this state. */
696 /** Source location for this state. */
700 struct yyGLRStateSet
{
701 yyGLRState
** yystates
;
702 size_t yysize
, yycapacity
;
705 struct yySemanticOption
{
706 /** Type tag: always false. */
708 /** Rule number for this reduction */
710 /** The last RHS state in the list of states to be reduced. */
712 /** Next sibling in chain of options. To facilitate merging,
713 * options are chained in decreasing order by address. */
714 yySemanticOption
* yynext
;
717 /** Type of the items in the GLR stack. The yyisState field
718 * indicates which item of the union is valid. */
719 union yyGLRStackItem
{
721 yySemanticOption yyoption
;
726 ]b4_location_if([[ /* To compute the location of the error token. */
727 yyGLRStackItem yyerror_range
[3];]])[
734 jmp_buf yyexception_buffer
;
735 yyGLRStackItem
* yyitems
;
736 yyGLRStackItem
* yynextFree
;
738 yyGLRState
* yysplitPoint
;
739 yyGLRState
* yylastDeleted
;
740 yyGLRStateSet yytops
;
743 static void yyexpandGLRStack (yyGLRStack
* yystack
);
746 yyFail (yyGLRStack
* yystack
]b4_pure_formals
[, const char* yymsg
)
749 yyerror (]b4_yyerror_args
[yymsg
);
750 longjmp (yystack
->yyexception_buffer
, 1);
754 yyMemoryExhausted (yyGLRStack
* yystack
)
756 longjmp (yystack
->yyexception_buffer
, 2);
759 #if YYDEBUG || YYERROR_VERBOSE
760 /** A printable representation of TOKEN. */
761 static inline const char*
762 yytokenName (yySymbol yytoken
)
764 if (yytoken
== YYEMPTY
)
767 return yytname
[yytoken
];
771 /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
772 * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
773 * containing the pointer to the next state in the chain. Assumes
774 * YYLOW1 < YYLOW0. */
775 static void yyfillin (yyGLRStackItem
*, int, int) ATTRIBUTE_UNUSED
;
777 yyfillin (yyGLRStackItem
*yyvsp
, int yylow0
, int yylow1
)
781 s
= yyvsp
[yylow0
].yystate
.yypred
;
782 for (i
= yylow0
-1; i
>= yylow1
; i
-= 1)
784 YYASSERT (s
->yyresolved
);
785 yyvsp
[i
].yystate
.yyresolved
= yytrue
;
786 yyvsp
[i
].yystate
.yysemantics
.yysval
= s
->yysemantics
.yysval
;
787 yyvsp
[i
].yystate
.yyloc
= s
->yyloc
;
788 s
= yyvsp
[i
].yystate
.yypred
= s
->yypred
;
792 /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
793 YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
794 For convenience, always return YYLOW1. */
795 static inline int yyfill (yyGLRStackItem
*, int *, int, yybool
)
798 yyfill (yyGLRStackItem
*yyvsp
, int *yylow
, int yylow1
, yybool yynormal
)
800 if (!yynormal
&& yylow1
< *yylow
)
802 yyfillin (yyvsp
, *yylow
, yylow1
);
808 /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
809 * and top stack item YYVSP. YYLVALP points to place to put semantic
810 * value ($$), and yylocp points to place for location information
811 * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
812 * yyerr for YYERROR, yyabort for YYABORT. */
814 yyuserAction (yyRuleNum yyn
, int yyrhslen
, yyGLRStackItem
* yyvsp
,
816 YYLTYPE
* YYOPTIONAL_LOC (yylocp
),
820 yybool yynormal ATTRIBUTE_UNUSED
= (yystack
->yysplitPoint
== NULL
);
824 # define yyerrok (yystack->yyerrState = 0)
826 # define YYACCEPT return yyaccept
828 # define YYABORT return yyabort
830 # define YYERROR return yyerrok, yyerr
832 # define YYRECOVERING (yystack->yyerrState != 0)
834 # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)
836 # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
838 # define YYBACKUP(Token, Value) \
839 return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
844 *yyvalp
= yyval_default
;
846 *yyvalp
= yyvsp
[YYFILL (1-yyrhslen
)].yystate
.yysemantics
.yysval
;
847 YYLLOC_DEFAULT (*yylocp
, yyvsp
- yyrhslen
, yyrhslen
);
848 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= *yylocp
;
864 /* Line __line__ of glr.c. */
865 b4_syncline([@oline@
], [@ofile@
])
870 yyuserMerge (int yyn
, YYSTYPE
* yy0
, YYSTYPE
* yy1
)
872 /* `Use' the arguments. */
883 /* Bison grammar-table manipulation. */
885 ]b4_yydestruct_generate([b4_c_ansi_function_def
])[
887 /** Number of symbols composing the right hand side of rule #RULE. */
889 yyrhsLength (yyRuleNum yyrule
)
894 /** Left-hand-side symbol for rule #RULE. */
895 static inline yySymbol
896 yylhsNonterm (yyRuleNum yyrule
)
901 #define yyis_pact_ninf(yystate) \
902 ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), 1,
904 ((yystate
) == YYPACT_NINF
))[
906 /** True iff LR state STATE has only a default reduction (regardless
909 yyisDefaultedState (yyStateNum yystate
)
911 return yyis_pact_ninf (yypact
[yystate
]);
914 /** The default reduction for STATE, assuming it has one. */
915 static inline yyRuleNum
916 yydefaultAction (yyStateNum yystate
)
918 return yydefact
[yystate
];
921 #define yyis_table_ninf(yytable_value) \
922 ]m4_if(m4_eval(b4_table_ninf < b4_table_min), 1,
924 ((yytable_value
) == YYTABLE_NINF
))[
926 /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
928 * R < 0: Reduce on rule -R.
930 * R > 0: Shift to state R.
931 * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
932 * conflicting reductions.
935 yygetLRActions (yyStateNum yystate
, int yytoken
,
936 int* yyaction
, const short int** yyconflicts
)
938 int yyindex
= yypact
[yystate
] + yytoken
;
939 if (yyindex
< 0 || YYLAST
< yyindex
|| yycheck
[yyindex
] != yytoken
)
941 *yyaction
= -yydefact
[yystate
];
942 *yyconflicts
= yyconfl
;
944 else if (! yyis_table_ninf (yytable
[yyindex
]))
946 *yyaction
= yytable
[yyindex
];
947 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
952 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
956 static inline yyStateNum
957 yyLRgotoState (yyStateNum yystate
, yySymbol yylhs
)
960 yyr
= yypgoto
[yylhs
- YYNTOKENS
] + yystate
;
961 if (0 <= yyr
&& yyr
<= YYLAST
&& yycheck
[yyr
] == yystate
)
964 return yydefgoto
[yylhs
- YYNTOKENS
];
968 yyisShiftAction (int yyaction
)
974 yyisErrorAction (int yyaction
)
976 return yyaction
== 0;
982 yyaddDeferredAction (yyGLRStack
* yystack
, yyGLRState
* yystate
,
983 yyGLRState
* rhs
, yyRuleNum yyrule
)
985 yySemanticOption
* yynewItem
;
986 yynewItem
= &yystack
->yynextFree
->yyoption
;
987 yystack
->yyspaceLeft
-= 1;
988 yystack
->yynextFree
+= 1;
989 yynewItem
->yyisState
= yyfalse
;
990 yynewItem
->yystate
= rhs
;
991 yynewItem
->yyrule
= yyrule
;
992 yynewItem
->yynext
= yystate
->yysemantics
.yyfirstVal
;
993 yystate
->yysemantics
.yyfirstVal
= yynewItem
;
994 if (yystack
->yyspaceLeft
< YYHEADROOM
)
995 yyexpandGLRStack (yystack
);
1000 /** Initialize SET to a singleton set containing an empty stack. */
1002 yyinitStateSet (yyGLRStateSet
* yyset
)
1005 yyset
->yycapacity
= 16;
1006 yyset
->yystates
= (yyGLRState
**) YYMALLOC (16 * sizeof yyset
->yystates
[0]);
1007 if (! yyset
->yystates
)
1009 yyset
->yystates
[0] = NULL
;
1013 static void yyfreeStateSet (yyGLRStateSet
* yyset
)
1015 YYFREE (yyset
->yystates
);
1018 /** Initialize STACK to a single empty stack, with total maximum
1019 * capacity for all stacks of SIZE. */
1021 yyinitGLRStack (yyGLRStack
* yystack
, size_t yysize
)
1023 yystack
->yyerrState
= 0;
1025 yystack
->yyspaceLeft
= yysize
;
1027 (yyGLRStackItem
*) YYMALLOC (yysize
* sizeof yystack
->yynextFree
[0]);
1028 if (!yystack
->yyitems
)
1030 yystack
->yynextFree
= yystack
->yyitems
;
1031 yystack
->yysplitPoint
= NULL
;
1032 yystack
->yylastDeleted
= NULL
;
1033 return yyinitStateSet (&yystack
->yytops
);
1036 #define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
1037 &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
1039 /** If STACK is expandable, extend it. WARNING: Pointers into the
1040 stack from outside should be considered invalid after this call.
1041 We always expand when there are 1 or fewer items left AFTER an
1042 allocation, so that we can avoid having external pointers exist
1043 across an allocation. */
1045 yyexpandGLRStack (yyGLRStack
* yystack
)
1047 #if YYSTACKEXPANDABLE
1048 yyGLRStackItem
* yynewItems
;
1049 yyGLRStackItem
* yyp0
, *yyp1
;
1050 size_t yysize
, yynewSize
;
1052 yysize
= yystack
->yynextFree
- yystack
->yyitems
;
1053 if (YYMAXDEPTH
<= yysize
)
1054 yyMemoryExhausted (yystack
);
1055 yynewSize
= 2*yysize
;
1056 if (YYMAXDEPTH
< yynewSize
)
1057 yynewSize
= YYMAXDEPTH
;
1058 yynewItems
= (yyGLRStackItem
*) YYMALLOC (yynewSize
* sizeof yynewItems
[0]);
1060 yyMemoryExhausted (yystack
);
1061 for (yyp0
= yystack
->yyitems
, yyp1
= yynewItems
, yyn
= yysize
;
1063 yyn
-= 1, yyp0
+= 1, yyp1
+= 1)
1066 if (*(yybool
*) yyp0
)
1068 yyGLRState
* yys0
= &yyp0
->yystate
;
1069 yyGLRState
* yys1
= &yyp1
->yystate
;
1070 if (yys0
->yypred
!= NULL
)
1072 YYRELOC (yyp0
, yyp1
, yys0
->yypred
, yystate
);
1073 if (! yys0
->yyresolved
&& yys0
->yysemantics
.yyfirstVal
!= NULL
)
1074 yys1
->yysemantics
.yyfirstVal
=
1075 YYRELOC(yyp0
, yyp1
, yys0
->yysemantics
.yyfirstVal
, yyoption
);
1079 yySemanticOption
* yyv0
= &yyp0
->yyoption
;
1080 yySemanticOption
* yyv1
= &yyp1
->yyoption
;
1081 if (yyv0
->yystate
!= NULL
)
1082 yyv1
->yystate
= YYRELOC (yyp0
, yyp1
, yyv0
->yystate
, yystate
);
1083 if (yyv0
->yynext
!= NULL
)
1084 yyv1
->yynext
= YYRELOC (yyp0
, yyp1
, yyv0
->yynext
, yyoption
);
1087 if (yystack
->yysplitPoint
!= NULL
)
1088 yystack
->yysplitPoint
= YYRELOC (yystack
->yyitems
, yynewItems
,
1089 yystack
->yysplitPoint
, yystate
);
1091 for (yyn
= 0; yyn
< yystack
->yytops
.yysize
; yyn
+= 1)
1092 if (yystack
->yytops
.yystates
[yyn
] != NULL
)
1093 yystack
->yytops
.yystates
[yyn
] =
1094 YYRELOC (yystack
->yyitems
, yynewItems
,
1095 yystack
->yytops
.yystates
[yyn
], yystate
);
1096 YYFREE (yystack
->yyitems
);
1097 yystack
->yyitems
= yynewItems
;
1098 yystack
->yynextFree
= yynewItems
+ yysize
;
1099 yystack
->yyspaceLeft
= yynewSize
- yysize
;
1102 yyMemoryExhausted (yystack
);
1107 yyfreeGLRStack (yyGLRStack
* yystack
)
1109 YYFREE (yystack
->yyitems
);
1110 yyfreeStateSet (&yystack
->yytops
);
1113 /** Assuming that S is a GLRState somewhere on STACK, update the
1114 * splitpoint of STACK, if needed, so that it is at least as deep as
1117 yyupdateSplit (yyGLRStack
* yystack
, yyGLRState
* yys
)
1119 if (yystack
->yysplitPoint
!= NULL
&& yystack
->yysplitPoint
> yys
)
1120 yystack
->yysplitPoint
= yys
;
1123 /** Invalidate stack #K in STACK. */
1125 yymarkStackDeleted (yyGLRStack
* yystack
, size_t yyk
)
1127 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1128 yystack
->yylastDeleted
= yystack
->yytops
.yystates
[yyk
];
1129 yystack
->yytops
.yystates
[yyk
] = NULL
;
1132 /** Undelete the last stack that was marked as deleted. Can only be
1133 done once after a deletion, and only when all other stacks have
1136 yyundeleteLastStack (yyGLRStack
* yystack
)
1138 if (yystack
->yylastDeleted
== NULL
|| yystack
->yytops
.yysize
!= 0)
1140 yystack
->yytops
.yystates
[0] = yystack
->yylastDeleted
;
1141 yystack
->yytops
.yysize
= 1;
1142 YYDPRINTF ((stderr
, "Restoring last deleted stack as stack #0.\n"));
1143 yystack
->yylastDeleted
= NULL
;
1147 yyremoveDeletes (yyGLRStack
* yystack
)
1151 while (yyj
< yystack
->yytops
.yysize
)
1153 if (yystack
->yytops
.yystates
[yyi
] == NULL
)
1157 YYDPRINTF ((stderr
, "Removing dead stacks.\n"));
1159 yystack
->yytops
.yysize
-= 1;
1163 yystack
->yytops
.yystates
[yyj
] = yystack
->yytops
.yystates
[yyi
];
1166 YYDPRINTF ((stderr
, "Rename stack %lu -> %lu.\n",
1167 (unsigned long int) yyi
, (unsigned long int) yyj
));
1175 /** Shift to a new state on stack #K of STACK, corresponding to LR state
1176 * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
1178 yyglrShift (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1180 YYSTYPE yysval
, YYLTYPE
* yylocp
)
1182 yyGLRStackItem
* yynewItem
;
1184 yynewItem
= yystack
->yynextFree
;
1185 yystack
->yynextFree
+= 1;
1186 yystack
->yyspaceLeft
-= 1;
1187 yynewItem
->yystate
.yyisState
= yytrue
;
1188 yynewItem
->yystate
.yylrState
= yylrState
;
1189 yynewItem
->yystate
.yyposn
= yyposn
;
1190 yynewItem
->yystate
.yyresolved
= yytrue
;
1191 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1192 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1193 yynewItem
->yystate
.yysemantics
.yysval
= yysval
;
1194 yynewItem
->yystate
.yyloc
= *yylocp
;
1195 if (yystack
->yyspaceLeft
< YYHEADROOM
)
1196 yyexpandGLRStack (yystack
);
1199 /** Shift stack #K of YYSTACK, to a new state corresponding to LR
1200 * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
1201 * semantic value of YYRHS under the action for YYRULE. */
1203 yyglrShiftDefer (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1204 size_t yyposn
, yyGLRState
* rhs
, yyRuleNum yyrule
)
1206 yyGLRStackItem
* yynewItem
;
1208 yynewItem
= yystack
->yynextFree
;
1209 yynewItem
->yystate
.yyisState
= yytrue
;
1210 yynewItem
->yystate
.yylrState
= yylrState
;
1211 yynewItem
->yystate
.yyposn
= yyposn
;
1212 yynewItem
->yystate
.yyresolved
= yyfalse
;
1213 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1214 yynewItem
->yystate
.yysemantics
.yyfirstVal
= NULL
;
1215 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1216 yystack
->yynextFree
+= 1;
1217 yystack
->yyspaceLeft
-= 1;
1218 yyaddDeferredAction (yystack
, &yynewItem
->yystate
, rhs
, yyrule
);
1221 /** Pop the symbols consumed by reduction #RULE from the top of stack
1222 * #K of STACK, and perform the appropriate semantic action on their
1223 * semantic values. Assumes that all ambiguities in semantic values
1224 * have been previously resolved. Set *VALP to the resulting value,
1225 * and *LOCP to the computed location (if any). Return value is as
1226 * for userAction. */
1227 static inline YYRESULTTAG
1228 yydoAction (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1229 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1231 int yynrhs
= yyrhsLength (yyrule
);
1233 if (yystack
->yysplitPoint
== NULL
)
1235 /* Standard special case: single stack. */
1236 yyGLRStackItem
* rhs
= (yyGLRStackItem
*) yystack
->yytops
.yystates
[yyk
];
1237 YYASSERT (yyk
== 0);
1238 yystack
->yynextFree
-= yynrhs
;
1239 yystack
->yyspaceLeft
+= yynrhs
;
1240 yystack
->yytops
.yystates
[0] = & yystack
->yynextFree
[-1].yystate
;
1241 return yyuserAction (yyrule
, yynrhs
, rhs
,
1242 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1248 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1249 yys
= yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
1250 = yystack
->yytops
.yystates
[yyk
];
1251 for (yyi
= 0; yyi
< yynrhs
; yyi
+= 1)
1256 yyupdateSplit (yystack
, yys
);
1257 yystack
->yytops
.yystates
[yyk
] = yys
;
1258 return yyuserAction (yyrule
, yynrhs
, yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1259 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1264 # define YY_REDUCE_PRINT(K, Rule)
1266 # define YY_REDUCE_PRINT(K, Rule) \
1269 yy_reduce_print (K, Rule); \
1272 /*----------------------------------------------------------.
1273 | Report that the RULE is going to be reduced on stack #K. |
1274 `----------------------------------------------------------*/
1277 yy_reduce_print (size_t yyk
, yyRuleNum yyrule
)
1280 YYFPRINTF (stderr
, "Reducing stack %lu by rule %d (line %lu), ",
1281 (unsigned long int) yyk
, yyrule
- 1,
1282 (unsigned long int) yyrline
[yyrule
]);
1283 /* Print the symbols being reduced, and their result. */
1284 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
1285 YYFPRINTF (stderr
, "%s ", yytokenName (yyrhs
[yyi
]));
1286 YYFPRINTF (stderr
, "-> %s\n", yytokenName (yyr1
[yyrule
]));
1290 /** Pop items off stack #K of STACK according to grammar rule RULE,
1291 * and push back on the resulting nonterminal symbol. Perform the
1292 * semantic action associated with RULE and store its value with the
1293 * newly pushed state, if FORCEEVAL or if STACK is currently
1294 * unambiguous. Otherwise, store the deferred semantic action with
1295 * the new state. If the new state would have an identical input
1296 * position, LR state, and predecessor to an existing state on the stack,
1297 * it is identified with that existing state, eliminating stack #K from
1298 * the STACK. In this case, the (necessarily deferred) semantic value is
1299 * added to the options for the existing state's semantic value.
1301 static inline YYRESULTTAG
1302 yyglrReduce (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1303 yybool yyforceEval
]b4_user_formals
[)
1305 size_t yyposn
= yystack
->yytops
.yystates
[yyk
]->yyposn
;
1307 if (yyforceEval
|| yystack
->yysplitPoint
== NULL
)
1312 YY_REDUCE_PRINT (yyk
, yyrule
);
1313 YYCHK (yydoAction (yystack
, yyk
, yyrule
, &yysval
, &yyloc
]b4_user_args
[));
1314 yyglrShift (yystack
, yyk
,
1315 yyLRgotoState (yystack
->yytops
.yystates
[yyk
]->yylrState
,
1316 yylhsNonterm (yyrule
)),
1317 yyposn
, yysval
, &yyloc
);
1323 yyGLRState
* yys
, *yys0
= yystack
->yytops
.yystates
[yyk
];
1324 yyStateNum yynewLRState
;
1326 for (yys
= yystack
->yytops
.yystates
[yyk
], yyn
= yyrhsLength (yyrule
);
1332 yyupdateSplit (yystack
, yys
);
1333 yynewLRState
= yyLRgotoState (yys
->yylrState
, yylhsNonterm (yyrule
));
1335 "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
1336 (unsigned long int) yyk
, yyrule
- 1, yynewLRState
));
1337 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
1338 if (yyi
!= yyk
&& yystack
->yytops
.yystates
[yyi
] != NULL
)
1340 yyGLRState
* yyp
, *yysplit
= yystack
->yysplitPoint
;
1341 yyp
= yystack
->yytops
.yystates
[yyi
];
1342 while (yyp
!= yys
&& yyp
!= yysplit
&& yyp
->yyposn
>= yyposn
)
1344 if (yyp
->yylrState
== yynewLRState
&& yyp
->yypred
== yys
)
1346 yyaddDeferredAction (yystack
, yyp
, yys0
, yyrule
);
1347 yymarkStackDeleted (yystack
, yyk
);
1348 YYDPRINTF ((stderr
, "Merging stack %lu into stack %lu.\n",
1349 (unsigned long int) yyk
,
1350 (unsigned long int) yyi
));
1356 yystack
->yytops
.yystates
[yyk
] = yys
;
1357 yyglrShiftDefer (yystack
, yyk
, yynewLRState
, yyposn
, yys0
, yyrule
);
1363 yysplitStack (yyGLRStack
* yystack
, size_t yyk
)
1365 if (yystack
->yysplitPoint
== NULL
)
1367 YYASSERT (yyk
== 0);
1368 yystack
->yysplitPoint
= yystack
->yytops
.yystates
[yyk
];
1370 if (yystack
->yytops
.yysize
>= yystack
->yytops
.yycapacity
)
1372 yyGLRState
** yynewStates
;
1373 if (! ((yystack
->yytops
.yycapacity
1374 <= (YYSIZEMAX
/ (2 * sizeof yynewStates
[0])))
1376 (yyGLRState
**) YYREALLOC (yystack
->yytops
.yystates
,
1377 ((yystack
->yytops
.yycapacity
*= 2)
1378 * sizeof yynewStates
[0])))))
1379 yyMemoryExhausted (yystack
);
1380 yystack
->yytops
.yystates
= yynewStates
;
1382 yystack
->yytops
.yystates
[yystack
->yytops
.yysize
]
1383 = yystack
->yytops
.yystates
[yyk
];
1384 yystack
->yytops
.yysize
+= 1;
1385 return yystack
->yytops
.yysize
-1;
1388 /** True iff Y0 and Y1 represent identical options at the top level.
1389 * That is, they represent the same rule applied to RHS symbols
1390 * that produce the same terminal symbols. */
1392 yyidenticalOptions (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1394 if (yyy0
->yyrule
== yyy1
->yyrule
)
1396 yyGLRState
*yys0
, *yys1
;
1398 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1399 yyn
= yyrhsLength (yyy0
->yyrule
);
1401 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1402 if (yys0
->yyposn
!= yys1
->yyposn
)
1410 /** Assuming identicalOptions (Y0,Y1), destructively merge the
1411 * alternative semantic values for the RHS-symbols of Y1 and Y0. */
1413 yymergeOptionSets (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1415 yyGLRState
*yys0
, *yys1
;
1417 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1418 yyn
= yyrhsLength (yyy0
->yyrule
);
1420 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1424 else if (yys0
->yyresolved
)
1426 yys1
->yyresolved
= yytrue
;
1427 yys1
->yysemantics
.yysval
= yys0
->yysemantics
.yysval
;
1429 else if (yys1
->yyresolved
)
1431 yys0
->yyresolved
= yytrue
;
1432 yys0
->yysemantics
.yysval
= yys1
->yysemantics
.yysval
;
1436 yySemanticOption
** yyz0p
;
1437 yySemanticOption
* yyz1
;
1438 yyz0p
= &yys0
->yysemantics
.yyfirstVal
;
1439 yyz1
= yys1
->yysemantics
.yyfirstVal
;
1442 if (yyz1
== *yyz0p
|| yyz1
== NULL
)
1444 else if (*yyz0p
== NULL
)
1449 else if (*yyz0p
< yyz1
)
1451 yySemanticOption
* yyz
= *yyz0p
;
1453 yyz1
= yyz1
->yynext
;
1454 (*yyz0p
)->yynext
= yyz
;
1456 yyz0p
= &(*yyz0p
)->yynext
;
1458 yys1
->yysemantics
.yyfirstVal
= yys0
->yysemantics
.yyfirstVal
;
1463 /** Y0 and Y1 represent two possible actions to take in a given
1464 * parsing state; return 0 if no combination is possible,
1465 * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
1467 yypreference (yySemanticOption
* y0
, yySemanticOption
* y1
)
1469 yyRuleNum r0
= y0
->yyrule
, r1
= y1
->yyrule
;
1470 int p0
= yydprec
[r0
], p1
= yydprec
[r1
];
1474 if (yymerger
[r0
] == 0 || yymerger
[r0
] != yymerger
[r1
])
1479 if (p0
== 0 || p1
== 0)
1488 static YYRESULTTAG
yyresolveValue (yySemanticOption
* yyoptionList
,
1489 yyGLRStack
* yystack
, YYSTYPE
* yyvalp
,
1490 YYLTYPE
* yylocp
]b4_user_formals
[);
1493 yyresolveStates (yyGLRState
* yys
, int yyn
, yyGLRStack
* yystack
]b4_user_formals
[)
1498 YYASSERT (yys
->yypred
);
1499 yyflag
= yyresolveStates (yys
->yypred
, yyn
-1, yystack
]b4_user_args
[);
1502 if (! yys
->yyresolved
)
1504 yyflag
= yyresolveValue (yys
->yysemantics
.yyfirstVal
, yystack
,
1505 &yys
->yysemantics
.yysval
, &yys
->yyloc
1509 yys
->yyresolved
= yytrue
;
1516 yyresolveAction (yySemanticOption
* yyopt
, yyGLRStack
* yystack
,
1517 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1519 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1522 yynrhs
= yyrhsLength (yyopt
->yyrule
);
1523 YYCHK (yyresolveStates (yyopt
->yystate
, yynrhs
, yystack
]b4_user_args
[));
1524 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
= yyopt
->yystate
;
1525 return yyuserAction (yyopt
->yyrule
, yynrhs
,
1526 yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1527 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1532 yyreportTree (yySemanticOption
* yyx
, int yyindent
)
1534 int yynrhs
= yyrhsLength (yyx
->yyrule
);
1537 yyGLRState
* yystates
[YYMAXRHS
];
1538 yyGLRState yyleftmost_state
;
1540 for (yyi
= yynrhs
, yys
= yyx
->yystate
; 0 < yyi
; yyi
-= 1, yys
= yys
->yypred
)
1541 yystates
[yyi
] = yys
;
1544 yyleftmost_state
.yyposn
= 0;
1545 yystates
[0] = &yyleftmost_state
;
1550 if (yyx
->yystate
->yyposn
< yys
->yyposn
+ 1)
1551 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, empty>\n",
1552 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1555 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
1556 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1557 yyx
->yyrule
, (unsigned long int) (yys
->yyposn
+ 1),
1558 (unsigned long int) yyx
->yystate
->yyposn
);
1559 for (yyi
= 1; yyi
<= yynrhs
; yyi
+= 1)
1561 if (yystates
[yyi
]->yyresolved
)
1563 if (yystates
[yyi
-1]->yyposn
+1 > yystates
[yyi
]->yyposn
)
1564 YYFPRINTF (stderr
, "%*s%s <empty>\n", yyindent
+2, "",
1565 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]));
1567 YYFPRINTF (stderr
, "%*s%s <tokens %lu .. %lu>\n", yyindent
+2, "",
1568 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]),
1569 (unsigned long int) (yystates
[yyi
- 1]->yyposn
+ 1),
1570 (unsigned long int) yystates
[yyi
]->yyposn
);
1573 yyreportTree (yystates
[yyi
]->yysemantics
.yyfirstVal
, yyindent
+2);
1579 yyreportAmbiguity (yySemanticOption
* yyx0
, yySemanticOption
* yyx1
,
1580 yyGLRStack
* yystack
]b4_pure_formals
[)
1582 /* `Unused' warnings. */
1587 YYFPRINTF (stderr
, "Ambiguity detected.\n");
1588 YYFPRINTF (stderr
, "Option 1,\n");
1589 yyreportTree (yyx0
, 2);
1590 YYFPRINTF (stderr
, "\nOption 2,\n");
1591 yyreportTree (yyx1
, 2);
1592 YYFPRINTF (stderr
, "\n");
1594 yyFail (yystack
][]b4_pure_args
[, YY_("syntax is ambiguous"));
1598 /** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
1599 * actions, and return the result. */
1601 yyresolveValue (yySemanticOption
* yyoptionList
, yyGLRStack
* yystack
,
1602 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1604 yySemanticOption
* yybest
;
1605 yySemanticOption
* yyp
;
1608 yybest
= yyoptionList
;
1610 for (yyp
= yyoptionList
->yynext
; yyp
!= NULL
; yyp
= yyp
->yynext
)
1612 if (yyidenticalOptions (yybest
, yyp
))
1613 yymergeOptionSets (yybest
, yyp
);
1615 switch (yypreference (yybest
, yyp
))
1618 yyreportAmbiguity (yybest
, yyp
, yystack
]b4_pure_args
[);
1634 int yyprec
= yydprec
[yybest
->yyrule
];
1635 YYCHK (yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[));
1636 for (yyp
= yybest
->yynext
; yyp
!= NULL
; yyp
= yyp
->yynext
)
1638 if (yyprec
== yydprec
[yyp
->yyrule
])
1642 YYCHK (yyresolveAction (yyp
, yystack
, &yyval1
, &yydummy
]b4_user_args
[));
1643 yyuserMerge (yymerger
[yyp
->yyrule
], yyvalp
, &yyval1
);
1649 return yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[);
1653 yyresolveStack (yyGLRStack
* yystack
]b4_user_formals
[)
1655 if (yystack
->yysplitPoint
!= NULL
)
1660 for (yyn
= 0, yys
= yystack
->yytops
.yystates
[0];
1661 yys
!= yystack
->yysplitPoint
;
1662 yys
= yys
->yypred
, yyn
+= 1)
1664 YYCHK (yyresolveStates (yystack
->yytops
.yystates
[0], yyn
, yystack
1671 yycompressStack (yyGLRStack
* yystack
)
1673 yyGLRState
* yyp
, *yyq
, *yyr
;
1675 if (yystack
->yytops
.yysize
!= 1 || yystack
->yysplitPoint
== NULL
)
1678 for (yyp
= yystack
->yytops
.yystates
[0], yyq
= yyp
->yypred
, yyr
= NULL
;
1679 yyp
!= yystack
->yysplitPoint
;
1680 yyr
= yyp
, yyp
= yyq
, yyq
= yyp
->yypred
)
1683 yystack
->yyspaceLeft
+= yystack
->yynextFree
- yystack
->yyitems
;
1684 yystack
->yynextFree
= ((yyGLRStackItem
*) yystack
->yysplitPoint
) + 1;
1685 yystack
->yyspaceLeft
-= yystack
->yynextFree
- yystack
->yyitems
;
1686 yystack
->yysplitPoint
= NULL
;
1687 yystack
->yylastDeleted
= NULL
;
1691 yystack
->yynextFree
->yystate
= *yyr
;
1693 yystack
->yynextFree
->yystate
.yypred
= & yystack
->yynextFree
[-1].yystate
;
1694 yystack
->yytops
.yystates
[0] = &yystack
->yynextFree
->yystate
;
1695 yystack
->yynextFree
+= 1;
1696 yystack
->yyspaceLeft
-= 1;
1701 yyprocessOneStack (yyGLRStack
* yystack
, size_t yyk
,
1702 size_t yyposn
, YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
1706 const short int* yyconflicts
;
1708 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1710 while (yystack
->yytops
.yystates
[yyk
] != NULL
)
1712 yyStateNum yystate
= yystack
->yytops
.yystates
[yyk
]->yylrState
;
1713 YYDPRINTF ((stderr
, "Stack %lu Entering state %d\n",
1714 (unsigned long int) yyk
, yystate
));
1716 YYASSERT (yystate
!= YYFINAL
);
1718 if (yyisDefaultedState (yystate
))
1720 yyrule
= yydefaultAction (yystate
);
1723 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1724 (unsigned long int) yyk
));
1725 yymarkStackDeleted (yystack
, yyk
);
1728 YYCHK (yyglrReduce (yystack
, yyk
, yyrule
, yyfalse
]b4_user_args
[));
1732 if (*yytokenp
== YYEMPTY
)
1734 YYDPRINTF ((stderr
, "Reading a token: "));
1736 *yytokenp
= YYTRANSLATE (yychar
);
1737 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1738 YYDPRINTF ((stderr
, "\n"));
1740 yygetLRActions (yystate
, *yytokenp
, &yyaction
, &yyconflicts
);
1742 while (*yyconflicts
!= 0)
1744 size_t yynewStack
= yysplitStack (yystack
, yyk
);
1745 YYDPRINTF ((stderr
, "Splitting off stack %lu from %lu.\n",
1746 (unsigned long int) yynewStack
,
1747 (unsigned long int) yyk
));
1748 YYCHK (yyglrReduce (yystack
, yynewStack
,
1749 *yyconflicts
, yyfalse
]b4_user_args
[));
1750 YYCHK (yyprocessOneStack (yystack
, yynewStack
, yyposn
,
1751 yylvalp
, yyllocp
]b4_pure_args
[));
1755 if (yyisShiftAction (yyaction
))
1757 YYDPRINTF ((stderr
, "On stack %lu, ", (unsigned long int) yyk
));
1758 YY_SYMBOL_PRINT ("shifting", *yytokenp
, yylvalp
, yyllocp
);
1759 yyglrShift (yystack
, yyk
, yyaction
, yyposn
+1,
1761 YYDPRINTF ((stderr
, ", now in state #%d\n",
1762 yystack
->yytops
.yystates
[yyk
]->yylrState
));
1765 else if (yyisErrorAction (yyaction
))
1767 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1768 (unsigned long int) yyk
));
1769 yymarkStackDeleted (yystack
, yyk
);
1773 YYCHK (yyglrReduce (yystack
, yyk
, -yyaction
, yyfalse
]b4_user_args
[));
1780 yyreportSyntaxError (yyGLRStack
* yystack
,
1781 YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
]b4_user_formals
[)
1783 /* `Unused' warnings. */
1787 if (yystack
->yyerrState
== 0)
1790 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1792 yyn
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1793 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1795 size_t yysize0
= yytnamerr (NULL
, yytokenName (*yytokenp
));
1796 size_t yysize
= yysize0
;
1798 yybool yysize_overflow
= yyfalse
;
1800 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1801 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1805 static char const yyunexpected
[] = "syntax error, unexpected %s";
1806 static char const yyexpecting
[] = ", expecting %s";
1807 static char const yyor
[] = " or %s";
1808 char yyformat
[sizeof yyunexpected
1809 + sizeof yyexpecting
- 1
1810 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1811 * (sizeof yyor
- 1))];
1812 char const *yyprefix
= yyexpecting
;
1814 /* Start YYX at -YYN if negative to avoid negative indexes in
1816 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1818 /* Stay within bounds of both yycheck and yytname. */
1819 int yychecklim
= YYLAST
- yyn
;
1820 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1823 yyarg
[0] = yytokenName (*yytokenp
);
1824 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1826 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1827 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1829 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1833 yyformat
[sizeof yyunexpected
- 1] = '\0';
1836 yyarg
[yycount
++] = yytokenName (yyx
);
1837 yysize1
= yysize
+ yytnamerr (NULL
, yytokenName (yyx
));
1838 yysize_overflow
|= yysize1
< yysize
;
1840 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1844 yyf
= YY_(yyformat
);
1845 yysize1
= yysize
+ strlen (yyf
);
1846 yysize_overflow
|= yysize1
< yysize
;
1849 if (!yysize_overflow
)
1850 yymsg
= (char *) YYMALLOC (yysize
);
1856 while ((*yyp
= *yyf
))
1858 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1860 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1869 yyerror (]b4_lyyerror_args
[yymsg
);
1874 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1875 yyMemoryExhausted (yystack
);
1879 #endif /* YYERROR_VERBOSE */
1880 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1885 /* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
1886 YYLVALP, and YYLLOCP point to the syntactic category, semantic
1887 value, and location of the look-ahead. */
1889 yyrecoverSyntaxError (yyGLRStack
* yystack
,
1891 YYLTYPE
* YYOPTIONAL_LOC (yyllocp
)
1894 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1898 if (yystack
->yyerrState
== 3)
1899 /* We just shifted the error token and (perhaps) took some
1900 reductions. Skip tokens until we can proceed. */
1903 if (*yytokenp
== YYEOF
)
1904 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1905 if (*yytokenp
!= YYEMPTY
)
1907 /* We throw away the lookahead, but the error range
1908 of the shifted error token must take it into account. */
1909 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
1910 yyGLRStackItem yyerror_range
[3];
1911 yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;
1912 yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
1913 YYLLOC_DEFAULT (yys
->yyloc
, yyerror_range
, 2);]])[
1914 yydestruct ("Error: discarding",
1915 *yytokenp
, yylvalp
]b4_location_if([, yyllocp
])[);
1917 YYDPRINTF ((stderr
, "Reading a token: "));
1919 *yytokenp
= YYTRANSLATE (yychar
);
1920 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1921 YYDPRINTF ((stderr
, "\n"));
1922 yyj
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1923 if (yyis_pact_ninf (yyj
))
1926 if (yyj
< 0 || YYLAST
< yyj
|| yycheck
[yyj
] != *yytokenp
)
1928 if (yydefact
[yystack
->yytops
.yystates
[0]->yylrState
] != 0)
1931 else if (yytable
[yyj
] != 0 && ! yyis_table_ninf (yytable
[yyj
]))
1935 /* Reduce to one stack. */
1936 for (yyk
= 0; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
1937 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1939 if (yyk
>= yystack
->yytops
.yysize
)
1940 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1941 for (yyk
+= 1; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
1942 yymarkStackDeleted (yystack
, yyk
);
1943 yyremoveDeletes (yystack
);
1944 yycompressStack (yystack
);
1946 /* Now pop stack until we find a state that shifts the error token. */
1947 yystack
->yyerrState
= 3;
1948 while (yystack
->yytops
.yystates
[0] != NULL
)
1950 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
1951 yyj
= yypact
[yys
->yylrState
];
1952 if (! yyis_pact_ninf (yyj
))
1955 if (0 <= yyj
&& yyj
<= YYLAST
&& yycheck
[yyj
] == YYTERROR
1956 && yyisShiftAction (yytable
[yyj
]))
1958 /* Shift the error token having adjusted its location. */
1959 YYLTYPE yyerrloc
;]b4_location_if([[
1960 yystack
->yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
1961 YYLLOC_DEFAULT (yyerrloc
, yystack
->yyerror_range
, 2);]])[
1962 YY_SYMBOL_PRINT ("Shifting", yystos
[yytable
[yyj
]],
1963 yylvalp
, &yyerrloc
);
1964 YYDPRINTF ((stderr
, "\n"));
1965 yyglrShift (yystack
, 0, yytable
[yyj
],
1966 yys
->yyposn
, *yylvalp
, &yyerrloc
);
1967 yys
= yystack
->yytops
.yystates
[0];
1971 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]])[
1972 yydestruct ("Error: popping",
1973 yystos
[yys
->yylrState
],
1974 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[);
1975 yystack
->yytops
.yystates
[0] = yys
->yypred
;
1976 yystack
->yynextFree
-= 1;
1977 yystack
->yyspaceLeft
+= 1;
1979 if (yystack
->yytops
.yystates
[0] == NULL
)
1980 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1983 #define YYCHK1(YYE) \
1993 goto yyuser_error; \
2002 ]b4_c_ansi_function_def([yyparse
], [int], b4_parse_param
)[
2013 #define yychar (yystack.yyrawchar)
2016 YYSTYPE
* const yylvalp
= &yylval
;
2017 YYLTYPE
* const yyllocp
= &yylloc
;
2019 YYDPRINTF ((stderr
, "Starting parse\n"));
2022 yylval
= yyval_default
;
2024 #if YYLTYPE_IS_TRIVIAL
2025 yylloc
.first_line
= yylloc
.last_line
= 1;
2026 yylloc
.first_column
= yylloc
.last_column
= 0;
2029 m4_ifdef([b4_initial_action
], [
2030 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
2031 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
2032 /* User initialization code. */
2034 m4_popdef([b4_dollar_dollar
])dnl
2035 m4_popdef([b4_at_dollar
])dnl
2036 /* Line __line__ of glr.c. */
2037 b4_syncline([@oline@
], [@ofile@
])])dnl
2039 if (! yyinitGLRStack (&yystack
, YYINITDEPTH
))
2040 goto yyexhaustedlab
;
2041 switch (setjmp (yystack
.yyexception_buffer
))
2043 case 1: goto yyabortlab
;
2044 case 2: goto yyexhaustedlab
;
2046 yystack
.yytokenp
= &yytoken
;
2047 yyglrShift (&yystack
, 0, 0, 0, yylval
, &yylloc
);
2052 /* For efficiency, we have two loops, the first of which is
2053 specialized to deterministic operation (single stack, no
2054 potential ambiguity). */
2060 const short int* yyconflicts
;
2062 yyStateNum yystate
= yystack
.yytops
.yystates
[0]->yylrState
;
2063 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
2064 if (yystate
== YYFINAL
)
2066 if (yyisDefaultedState (yystate
))
2068 yyrule
= yydefaultAction (yystate
);
2071 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2072 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2075 YYCHK1 (yyglrReduce (&yystack
, 0, yyrule
, yytrue
]b4_user_args
[));
2079 if (yytoken
== YYEMPTY
)
2081 YYDPRINTF ((stderr
, "Reading a token: "));
2083 yytoken
= YYTRANSLATE (yychar
);
2084 YY_SYMBOL_PRINT ("Next token is", yytoken
, yylvalp
, yyllocp
);
2085 YYDPRINTF ((stderr
, "\n"));
2087 yygetLRActions (yystate
, yytoken
, &yyaction
, &yyconflicts
);
2088 if (*yyconflicts
!= 0)
2090 if (yyisShiftAction (yyaction
))
2092 YY_SYMBOL_PRINT ("Shifting", yytoken
, yylvalp
, yyllocp
);
2093 YYDPRINTF ((stderr
, "\n"));
2094 if (yytoken
!= YYEOF
)
2097 yyglrShift (&yystack
, 0, yyaction
, yyposn
, yylval
, yyllocp
);
2098 if (0 < yystack
.yyerrState
)
2099 yystack
.yyerrState
-= 1;
2101 else if (yyisErrorAction (yyaction
))
2103 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2104 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2108 YYCHK1 (yyglrReduce (&yystack
, 0, -yyaction
, yytrue
]b4_user_args
[));
2115 size_t yyn
= yystack
.yytops
.yysize
;
2116 for (yys
= 0; yys
< yyn
; yys
+= 1)
2117 YYCHK1 (yyprocessOneStack (&yystack
, yys
, yyposn
,
2118 yylvalp
, yyllocp
]b4_lpure_args
[));
2121 yyremoveDeletes (&yystack
);
2122 if (yystack
.yytops
.yysize
== 0)
2124 yyundeleteLastStack (&yystack
);
2125 if (yystack
.yytops
.yysize
== 0)
2126 yyFail (&yystack
][]b4_lpure_args
[, YY_("syntax error"));
2127 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2128 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2129 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2130 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2133 else if (yystack
.yytops
.yysize
== 1)
2135 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2136 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2137 yycompressStack (&yystack
);
2143 yyrecoverSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2144 yyposn
= yystack
.yytops
.yystates
[0]->yyposn
;
2156 yyerror (]b4_lyyerror_args
[YY_("memory exhausted"));
2161 if (yytoken
!= YYEOF
&& yytoken
!= YYEMPTY
)
2162 yydestruct ("Error: discarding lookahead",
2163 yytoken
, yylvalp
]b4_location_if([, yyllocp
])[);
2165 /* If the stack is well-formed, pop the stack until it is empty,
2166 destroying its entries as we go. But free the stack regardless
2167 of whether it is well-formed. */
2168 if (yystack
.yyitems
)
2170 yyGLRState
** yystates
= yystack
.yytops
.yystates
;
2174 yyGLRState
*yys
= yystates
[0];
2175 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]]
2176 )[ yydestruct ("Error: popping",
2177 yystos
[yys
->yylrState
],
2178 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[);
2179 yystates
[0] = yys
->yypred
;
2180 yystack
.yynextFree
-= 1;
2181 yystack
.yyspaceLeft
+= 1;
2183 yyfreeGLRStack (&yystack
);
2189 /* DEBUGGING ONLY */
2191 static void yypstack (yyGLRStack
* yystack
, size_t yyk
) ATTRIBUTE_UNUSED
;
2192 static void yypdumpstack (yyGLRStack
* yystack
) ATTRIBUTE_UNUSED
;
2195 yy_yypstack (yyGLRState
* yys
)
2199 yy_yypstack (yys
->yypred
);
2200 fprintf (stderr
, " -> ");
2202 fprintf (stderr
, "%d@@%lu", yys
->yylrState
, (unsigned long int) yys
->yyposn
);
2206 yypstates (yyGLRState
* yyst
)
2209 fprintf (stderr
, "<null>");
2212 fprintf (stderr
, "\n");
2216 yypstack (yyGLRStack
* yystack
, size_t yyk
)
2218 yypstates (yystack
->yytops
.yystates
[yyk
]);
2221 #define YYINDEX(YYX) \
2222 ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
2226 yypdumpstack (yyGLRStack
* yystack
)
2228 yyGLRStackItem
* yyp
;
2230 for (yyp
= yystack
->yyitems
; yyp
< yystack
->yynextFree
; yyp
+= 1)
2232 fprintf (stderr
, "%3lu. ", (unsigned long int) (yyp
- yystack
->yyitems
));
2233 if (*(yybool
*) yyp
)
2235 fprintf (stderr
, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
2236 yyp
->yystate
.yyresolved
, yyp
->yystate
.yylrState
,
2237 (unsigned long int) yyp
->yystate
.yyposn
,
2238 (long int) YYINDEX (yyp
->yystate
.yypred
));
2239 if (! yyp
->yystate
.yyresolved
)
2240 fprintf (stderr
, ", firstVal: %ld",
2241 (long int) YYINDEX (yyp
->yystate
.yysemantics
.yyfirstVal
));
2245 fprintf (stderr
, "Option. rule: %d, state: %ld, next: %ld",
2246 yyp
->yyoption
.yyrule
,
2247 (long int) YYINDEX (yyp
->yyoption
.yystate
),
2248 (long int) YYINDEX (yyp
->yyoption
.yynext
));
2250 fprintf (stderr
, "\n");
2252 fprintf (stderr
, "Tops:");
2253 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
2254 fprintf (stderr
, "%lu: %ld; ", (unsigned long int) yyi
,
2255 (long int) YYINDEX (yystack
->yytops
.yystates
[yyi
]));
2256 fprintf (stderr
, "\n");
2262 m4_if(b4_defines_flag
, 0, [],
2263 [@output @output_header_name@
2264 b4_copyright([Skeleton parser
for GLR parsing with Bison
],
2265 [2002, 2003, 2004, 2005])
2267 b4_token_defines(b4_tokens
)
2269 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
2270 m4_ifdef([b4_stype
],
2271 [b4_syncline([b4_stype_line
], [b4_filename
])
2272 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
2273 /* Line __line__ of glr.c. */
2274 b4_syncline([@oline@
], [@ofile@
])],
2275 [typedef int YYSTYPE
;])
2276 # define YYSTYPE_IS_DECLARED 1
2277 # define YYSTYPE_IS_TRIVIAL 1
2281 [extern YYSTYPE b4_prefix
[]lval
;])
2283 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
2284 typedef struct YYLTYPE
2295 # define YYLTYPE_IS_DECLARED 1
2296 # define YYLTYPE_IS_TRIVIAL 1
2299 b4_location_if([b4_pure_if([],
2300 [extern YYLTYPE b4_prefix
[]lloc
;])