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@
])
224 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
225 # define YY_(msgid) dgettext ("bison-runtime", msgid)
229 # define YY_(msgid) msgid
237 # define YYMALLOC malloc
240 # define YYREALLOC realloc
243 #define YYSIZEMAX ((size_t) -1)
248 typedef unsigned char yybool
;
257 #ifndef __attribute__
258 /* This feature is available in gcc versions 2.5 and later. */
259 # if !defined (__GNUC__) || __GNUC__ < 2 || \
260 (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
261 # define __attribute__(Spec) /* empty */
263 ]b4_location_if([# define YYOPTIONAL_LOC(Name) Name],[
264 # if defined (__cplusplus)
265 # define YYOPTIONAL_LOC(Name) /* empty */
267 # define YYOPTIONAL_LOC(Name) Name ATTRIBUTE_UNUSED
273 # define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
276 #ifndef ATTRIBUTE_UNUSED
277 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
280 /* YYFINAL -- State number of the termination state. */
281 #define YYFINAL ]b4_final_state_number[
282 /* YYLAST -- Last index in YYTABLE. */
283 #define YYLAST ]b4_last[
285 /* YYNTOKENS -- Number of terminals. */
286 #define YYNTOKENS ]b4_tokens_number[
287 /* YYNNTS -- Number of nonterminals. */
288 #define YYNNTS ]b4_nterms_number[
289 /* YYNRULES -- Number of rules. */
290 #define YYNRULES ]b4_rules_number[
291 /* YYNRULES -- Number of states. */
292 #define YYNSTATES ]b4_states_number[
293 /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
294 #define YYMAXRHS ]b4_r2_max[
295 /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
296 accessed by $0, $-1, etc., in any rule. */
297 #define YYMAXLEFT ]b4_max_left_semantic_context[
299 /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
300 #define YYUNDEFTOK ]b4_undef_token_number[
301 #define YYMAXUTOK ]b4_user_token_number_max[
303 #define YYTRANSLATE(YYX) \
304 ((YYX <= 0) ? YYEOF : \
305 (unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
307 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
308 static const ]b4_int_type_for([b4_translate
])[ yytranslate
[] =
314 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
316 static const ]b4_int_type_for([b4_prhs
])[ yyprhs
[] =
321 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
322 static const ]b4_int_type_for([b4_rhs
])[ yyrhs
[] =
327 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
328 static const ]b4_int_type_for([b4_rline
])[ yyrline
[] =
334 #if (YYDEBUG) || YYERROR_VERBOSE
335 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
336 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
337 static const char *const yytname
[] =
343 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
344 static const ]b4_int_type_for([b4_r1
])[ yyr1
[] =
349 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
350 static const ]b4_int_type_for([b4_r2
])[ yyr2
[] =
355 /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
356 static const ]b4_int_type_for([b4_dprec
])[ yydprec
[] =
361 /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
362 static const ]b4_int_type_for([b4_merger
])[ yymerger
[] =
367 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
368 doesn't specify something else to do. Zero means the default is an
370 static const ]b4_int_type_for([b4_defact
])[ yydefact
[] =
375 /* YYPDEFGOTO[NTERM-NUM]. */
376 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto
[] =
381 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
383 #define YYPACT_NINF ]b4_pact_ninf[
384 static const ]b4_int_type_for([b4_pact
])[ yypact
[] =
389 /* YYPGOTO[NTERM-NUM]. */
390 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto
[] =
395 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
396 positive, shift that token. If negative, reduce the rule which
397 number is the opposite. If zero, do what YYDEFACT says.
398 If YYTABLE_NINF, syntax error. */
399 #define YYTABLE_NINF ]b4_table_ninf[
400 static const ]b4_int_type_for([b4_table
])[ yytable
[] =
405 /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
406 list of conflicting reductions corresponding to action entry for
407 state STATE-NUM in yytable. 0 means no conflicts. The list in
408 yyconfl is terminated by a rule number of 0. */
409 static const ]b4_int_type_for([b4_conflict_list_heads
])[ yyconflp
[] =
411 ]b4_conflict_list_heads
[
414 /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
415 0, pointed into by YYCONFLP. */
416 ]dnl Do
not use b4_int_type_for here
, since there are places where
417 dnl pointers onto yyconfl are taken
, which type is
"short int *".
418 dnl We probably ought to introduce a type
for confl
.
419 [static const short int yyconfl
[] =
421 ]b4_conflicting_rules
[
424 static const ]b4_int_type_for([b4_check
])[ yycheck
[] =
429 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
430 symbol of state STATE-NUM. */
431 static const ]b4_int_type_for([b4_stos
])[ yystos
[] =
437 /* Prevent warning if -Wmissing-prototypes. */
438 ]b4_c_ansi_function_decl([yyparse
], [int], b4_parse_param
)[
440 /* Error token number */
443 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
444 If N is 0, then set CURRENT to the empty location which ends
445 the previous symbol: RHS[0] (always defined). */
448 #define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
449 #ifndef YYLLOC_DEFAULT
450 # define YYLLOC_DEFAULT(Current, Rhs, N) \
454 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
455 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
456 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
457 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
461 (Current).first_line = (Current).last_line = \
462 YYRHSLOC (Rhs, 0).last_line; \
463 (Current).first_column = (Current).last_column = \
464 YYRHSLOC (Rhs, 0).last_column; \
468 /* YY_LOCATION_PRINT -- Print the location on the stream.
469 This macro was not mandated originally: define only if we know
470 we won't break user code: when these are the locations we know. */
472 # define YY_LOCATION_PRINT(File, Loc) \
473 fprintf (File, "%d.%d-%d.%d", \
474 (Loc).first_line, (Loc).first_column, \
475 (Loc).last_line, (Loc).last_column)
478 #ifndef YYLLOC_DEFAULT
479 # define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)
483 #ifndef YY_LOCATION_PRINT
484 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
488 /* YYLEX -- calling `yylex' with the right arguments. */
489 #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
494 #define yynerrs (yystack->yyerrcnt)
496 #define yychar (yystack->yyrawchar)],
504 static const int YYEOF
= 0;
505 static const int YYEMPTY
= -2;
507 typedef enum { yyok
, yyaccept
, yyabort
, yyerr
} YYRESULTTAG
;
510 do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
515 #if ! defined (YYFPRINTF)
516 # define YYFPRINTF fprintf
519 # define YYDPRINTF(Args) \
525 ]b4_yysymprint_generate([b4_c_ansi_function_def
])[
527 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
531 YYFPRINTF (stderr, "%s ", Title); \
532 yysymprint (stderr, \
533 Type, Value]b4_location_if([, Location])[); \
537 /* Nonzero means print parse trace. It is left uninitialized so that
538 multiple parsers can coexist. */
543 # define YYDPRINTF(Args)
544 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
546 #endif /* !YYDEBUG */
548 /* YYINITDEPTH -- initial size of the parser's stacks. */
550 # define YYINITDEPTH ]b4_stack_depth_init[
553 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
554 if the built-in stack extension method is used).
556 Do not make this value too large; the results are undefined if
557 SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
558 evaluated with infinite-precision integer arithmetic. */
561 # define YYMAXDEPTH ]b4_stack_depth_max[
564 /* Minimum number of free items on the stack allowed after an
565 allocation. This is to allow allocation and initialization
566 to be completed by functions that call yyexpandGLRStack before the
567 stack is expanded, thus insuring that all necessary pointers get
568 properly redirected to new data. */
571 #ifndef YYSTACKEXPANDABLE
572 # if (! defined (__cplusplus) \
573 || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \
574 && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))
575 # define YYSTACKEXPANDABLE 1
577 # define YYSTACKEXPANDABLE 0
584 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
585 # define yystpcpy stpcpy
587 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
590 yystpcpy (char *yydest
, const char *yysrc
)
593 const char *yys
= yysrc
;
595 while ((*yyd
++ = *yys
++) != '\0')
604 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
605 quotes and backslashes, so that it's suitable for yyerror. The
606 heuristic is that double-quoting is unnecessary unless the string
607 contains an apostrophe, a comma, or backslash (other than
608 backslash-backslash). YYSTR is taken from yytname. If YYRES is
609 null, do not copy; instead, return the length of what the result
612 yytnamerr (char *yyres
, const char *yystr
)
617 char const *yyp
= yystr
;
624 goto do_not_strip_quotes
;
628 goto do_not_strip_quotes
;
641 do_not_strip_quotes
: ;
645 return strlen (yystr
);
647 return yystpcpy (yyres
, yystr
) - yyres
;
651 #endif /* !YYERROR_VERBOSE */
653 /** State numbers, as in LALR(1) machine */
654 typedef int yyStateNum
;
656 /** Rule numbers, as in LALR(1) machine */
657 typedef int yyRuleNum
;
659 /** Grammar symbol */
660 typedef short int yySymbol
;
662 /** Item references, as in LALR(1) machine */
663 typedef short int yyItemNum
;
665 typedef struct yyGLRState yyGLRState
;
666 typedef struct yySemanticOption yySemanticOption
;
667 typedef union yyGLRStackItem yyGLRStackItem
;
668 typedef struct yyGLRStack yyGLRStack
;
669 typedef struct yyGLRStateSet yyGLRStateSet
;
672 /** Type tag: always true. */
674 /** Type tag for yysemantics. If true, yysval applies, otherwise
675 * yyfirstVal applies. */
677 /** Number of corresponding LALR(1) machine state. */
678 yyStateNum yylrState
;
679 /** Preceding state in this stack */
681 /** Source position of the first token produced by my symbol */
684 /** First in a chain of alternative reductions producing the
685 * non-terminal corresponding to this state, threaded through
687 yySemanticOption
* yyfirstVal
;
688 /** Semantic value for this state. */
691 /** Source location for this state. */
695 struct yyGLRStateSet
{
696 yyGLRState
** yystates
;
697 size_t yysize
, yycapacity
;
700 struct yySemanticOption
{
701 /** Type tag: always false. */
703 /** Rule number for this reduction */
705 /** The last RHS state in the list of states to be reduced. */
707 /** Next sibling in chain of options. To facilitate merging,
708 * options are chained in decreasing order by address. */
709 yySemanticOption
* yynext
;
712 /** Type of the items in the GLR stack. The yyisState field
713 * indicates which item of the union is valid. */
714 union yyGLRStackItem
{
716 yySemanticOption yyoption
;
721 ]b4_location_if([[ /* To compute the location of the error token. */
722 yyGLRStackItem yyerror_range
[3];]])[
729 jmp_buf yyexception_buffer
;
730 yyGLRStackItem
* yyitems
;
731 yyGLRStackItem
* yynextFree
;
733 yyGLRState
* yysplitPoint
;
734 yyGLRState
* yylastDeleted
;
735 yyGLRStateSet yytops
;
738 static void yyexpandGLRStack (yyGLRStack
* yystack
);
741 yyFail (yyGLRStack
* yystack
]b4_pure_formals
[, const char* yymsg
)
744 yyerror (]b4_yyerror_args
[yymsg
);
745 longjmp (yystack
->yyexception_buffer
, 1);
749 yyMemoryExhausted (yyGLRStack
* yystack
)
751 longjmp (yystack
->yyexception_buffer
, 2);
754 #if YYDEBUG || YYERROR_VERBOSE
755 /** A printable representation of TOKEN. */
756 static inline const char*
757 yytokenName (yySymbol yytoken
)
759 if (yytoken
== YYEMPTY
)
762 return yytname
[yytoken
];
766 /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
767 * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
768 * containing the pointer to the next state in the chain. Assumes
769 * YYLOW1 < YYLOW0. */
770 static void yyfillin (yyGLRStackItem
*, int, int) ATTRIBUTE_UNUSED
;
772 yyfillin (yyGLRStackItem
*yyvsp
, int yylow0
, int yylow1
)
776 s
= yyvsp
[yylow0
].yystate
.yypred
;
777 for (i
= yylow0
-1; i
>= yylow1
; i
-= 1)
779 YYASSERT (s
->yyresolved
);
780 yyvsp
[i
].yystate
.yyresolved
= yytrue
;
781 yyvsp
[i
].yystate
.yysemantics
.yysval
= s
->yysemantics
.yysval
;
782 yyvsp
[i
].yystate
.yyloc
= s
->yyloc
;
783 s
= yyvsp
[i
].yystate
.yypred
= s
->yypred
;
787 /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
788 YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
789 For convenience, always return YYLOW1. */
790 static inline int yyfill (yyGLRStackItem
*, int *, int, yybool
)
793 yyfill (yyGLRStackItem
*yyvsp
, int *yylow
, int yylow1
, yybool yynormal
)
795 if (!yynormal
&& yylow1
< *yylow
)
797 yyfillin (yyvsp
, *yylow
, yylow1
);
803 /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
804 * and top stack item YYVSP. YYLVALP points to place to put semantic
805 * value ($$), and yylocp points to place for location information
806 * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
807 * yyerr for YYERROR, yyabort for YYABORT. */
809 yyuserAction (yyRuleNum yyn
, int yyrhslen
, yyGLRStackItem
* yyvsp
,
811 YYLTYPE
* YYOPTIONAL_LOC (yylocp
),
815 yybool yynormal ATTRIBUTE_UNUSED
= (yystack
->yysplitPoint
== NULL
);
819 # define yyerrok (yystack->yyerrState = 0)
821 # define YYACCEPT return yyaccept
823 # define YYABORT return yyabort
825 # define YYERROR return yyerrok, yyerr
827 # define YYRECOVERING (yystack->yyerrState != 0)
829 # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)
831 # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
833 # define YYBACKUP(Token, Value) \
834 return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
839 *yyvalp
= yyval_default
;
841 *yyvalp
= yyvsp
[YYFILL (1-yyrhslen
)].yystate
.yysemantics
.yysval
;
842 YYLLOC_DEFAULT (*yylocp
, yyvsp
- yyrhslen
, yyrhslen
);
843 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= *yylocp
;
859 /* Line __line__ of glr.c. */
860 b4_syncline([@oline@
], [@ofile@
])
865 yyuserMerge (int yyn
, YYSTYPE
* yy0
, YYSTYPE
* yy1
)
867 /* `Use' the arguments. */
878 /* Bison grammar-table manipulation. */
880 ]b4_yydestruct_generate([b4_c_ansi_function_def
])[
882 /** Number of symbols composing the right hand side of rule #RULE. */
884 yyrhsLength (yyRuleNum yyrule
)
889 /** Left-hand-side symbol for rule #RULE. */
890 static inline yySymbol
891 yylhsNonterm (yyRuleNum yyrule
)
896 #define yyis_pact_ninf(yystate) \
897 ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), 1,
899 ((yystate
) == YYPACT_NINF
))[
901 /** True iff LR state STATE has only a default reduction (regardless
904 yyisDefaultedState (yyStateNum yystate
)
906 return yyis_pact_ninf (yypact
[yystate
]);
909 /** The default reduction for STATE, assuming it has one. */
910 static inline yyRuleNum
911 yydefaultAction (yyStateNum yystate
)
913 return yydefact
[yystate
];
916 #define yyis_table_ninf(yytable_value) \
917 ]m4_if(m4_eval(b4_table_ninf < b4_table_min), 1,
919 ((yytable_value
) == YYTABLE_NINF
))[
921 /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
923 * R < 0: Reduce on rule -R.
925 * R > 0: Shift to state R.
926 * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
927 * conflicting reductions.
930 yygetLRActions (yyStateNum yystate
, int yytoken
,
931 int* yyaction
, const short int** yyconflicts
)
933 int yyindex
= yypact
[yystate
] + yytoken
;
934 if (yyindex
< 0 || YYLAST
< yyindex
|| yycheck
[yyindex
] != yytoken
)
936 *yyaction
= -yydefact
[yystate
];
937 *yyconflicts
= yyconfl
;
939 else if (! yyis_table_ninf (yytable
[yyindex
]))
941 *yyaction
= yytable
[yyindex
];
942 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
947 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
951 static inline yyStateNum
952 yyLRgotoState (yyStateNum yystate
, yySymbol yylhs
)
955 yyr
= yypgoto
[yylhs
- YYNTOKENS
] + yystate
;
956 if (0 <= yyr
&& yyr
<= YYLAST
&& yycheck
[yyr
] == yystate
)
959 return yydefgoto
[yylhs
- YYNTOKENS
];
963 yyisShiftAction (int yyaction
)
969 yyisErrorAction (int yyaction
)
971 return yyaction
== 0;
977 yyaddDeferredAction (yyGLRStack
* yystack
, yyGLRState
* yystate
,
978 yyGLRState
* rhs
, yyRuleNum yyrule
)
980 yySemanticOption
* yynewItem
;
981 yynewItem
= &yystack
->yynextFree
->yyoption
;
982 yystack
->yyspaceLeft
-= 1;
983 yystack
->yynextFree
+= 1;
984 yynewItem
->yyisState
= yyfalse
;
985 yynewItem
->yystate
= rhs
;
986 yynewItem
->yyrule
= yyrule
;
987 yynewItem
->yynext
= yystate
->yysemantics
.yyfirstVal
;
988 yystate
->yysemantics
.yyfirstVal
= yynewItem
;
989 if (yystack
->yyspaceLeft
< YYHEADROOM
)
990 yyexpandGLRStack (yystack
);
995 /** Initialize SET to a singleton set containing an empty stack. */
997 yyinitStateSet (yyGLRStateSet
* yyset
)
1000 yyset
->yycapacity
= 16;
1001 yyset
->yystates
= (yyGLRState
**) YYMALLOC (16 * sizeof yyset
->yystates
[0]);
1002 if (! yyset
->yystates
)
1004 yyset
->yystates
[0] = NULL
;
1008 static void yyfreeStateSet (yyGLRStateSet
* yyset
)
1010 YYFREE (yyset
->yystates
);
1013 /** Initialize STACK to a single empty stack, with total maximum
1014 * capacity for all stacks of SIZE. */
1016 yyinitGLRStack (yyGLRStack
* yystack
, size_t yysize
)
1018 yystack
->yyerrState
= 0;
1020 yystack
->yyspaceLeft
= yysize
;
1021 yystack
->yynextFree
= yystack
->yyitems
=
1022 (yyGLRStackItem
*) YYMALLOC (yysize
* sizeof yystack
->yynextFree
[0]);
1023 yystack
->yysplitPoint
= NULL
;
1024 yystack
->yylastDeleted
= NULL
;
1025 return yyinitStateSet (&yystack
->yytops
) && yystack
->yyitems
;
1028 #define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
1029 &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
1031 /** If STACK is expandable, extend it. WARNING: Pointers into the
1032 stack from outside should be considered invalid after this call.
1033 We always expand when there are 1 or fewer items left AFTER an
1034 allocation, so that we can avoid having external pointers exist
1035 across an allocation. */
1037 yyexpandGLRStack (yyGLRStack
* yystack
)
1039 #if YYSTACKEXPANDABLE
1040 yyGLRStackItem
* yynewItems
;
1041 yyGLRStackItem
* yyp0
, *yyp1
;
1042 size_t yysize
, yynewSize
;
1044 yysize
= yystack
->yynextFree
- yystack
->yyitems
;
1045 if (YYMAXDEPTH
<= yysize
)
1046 yyMemoryExhausted (yystack
);
1047 yynewSize
= 2*yysize
;
1048 if (YYMAXDEPTH
< yynewSize
)
1049 yynewSize
= YYMAXDEPTH
;
1050 yynewItems
= (yyGLRStackItem
*) YYMALLOC (yynewSize
* sizeof yynewItems
[0]);
1052 yyMemoryExhausted (yystack
);
1053 for (yyp0
= yystack
->yyitems
, yyp1
= yynewItems
, yyn
= yysize
;
1055 yyn
-= 1, yyp0
+= 1, yyp1
+= 1)
1058 if (*(yybool
*) yyp0
)
1060 yyGLRState
* yys0
= &yyp0
->yystate
;
1061 yyGLRState
* yys1
= &yyp1
->yystate
;
1062 if (yys0
->yypred
!= NULL
)
1064 YYRELOC (yyp0
, yyp1
, yys0
->yypred
, yystate
);
1065 if (! yys0
->yyresolved
&& yys0
->yysemantics
.yyfirstVal
!= NULL
)
1066 yys1
->yysemantics
.yyfirstVal
=
1067 YYRELOC(yyp0
, yyp1
, yys0
->yysemantics
.yyfirstVal
, yyoption
);
1071 yySemanticOption
* yyv0
= &yyp0
->yyoption
;
1072 yySemanticOption
* yyv1
= &yyp1
->yyoption
;
1073 if (yyv0
->yystate
!= NULL
)
1074 yyv1
->yystate
= YYRELOC (yyp0
, yyp1
, yyv0
->yystate
, yystate
);
1075 if (yyv0
->yynext
!= NULL
)
1076 yyv1
->yynext
= YYRELOC (yyp0
, yyp1
, yyv0
->yynext
, yyoption
);
1079 if (yystack
->yysplitPoint
!= NULL
)
1080 yystack
->yysplitPoint
= YYRELOC (yystack
->yyitems
, yynewItems
,
1081 yystack
->yysplitPoint
, yystate
);
1083 for (yyn
= 0; yyn
< yystack
->yytops
.yysize
; yyn
+= 1)
1084 if (yystack
->yytops
.yystates
[yyn
] != NULL
)
1085 yystack
->yytops
.yystates
[yyn
] =
1086 YYRELOC (yystack
->yyitems
, yynewItems
,
1087 yystack
->yytops
.yystates
[yyn
], yystate
);
1088 YYFREE (yystack
->yyitems
);
1089 yystack
->yyitems
= yynewItems
;
1090 yystack
->yynextFree
= yynewItems
+ yysize
;
1091 yystack
->yyspaceLeft
= yynewSize
- yysize
;
1094 yyMemoryExhausted (yystack
);
1099 yyfreeGLRStack (yyGLRStack
* yystack
)
1101 YYFREE (yystack
->yyitems
);
1102 yyfreeStateSet (&yystack
->yytops
);
1105 /** Assuming that S is a GLRState somewhere on STACK, update the
1106 * splitpoint of STACK, if needed, so that it is at least as deep as
1109 yyupdateSplit (yyGLRStack
* yystack
, yyGLRState
* yys
)
1111 if (yystack
->yysplitPoint
!= NULL
&& yystack
->yysplitPoint
> yys
)
1112 yystack
->yysplitPoint
= yys
;
1115 /** Invalidate stack #K in STACK. */
1117 yymarkStackDeleted (yyGLRStack
* yystack
, size_t yyk
)
1119 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1120 yystack
->yylastDeleted
= yystack
->yytops
.yystates
[yyk
];
1121 yystack
->yytops
.yystates
[yyk
] = NULL
;
1124 /** Undelete the last stack that was marked as deleted. Can only be
1125 done once after a deletion, and only when all other stacks have
1128 yyundeleteLastStack (yyGLRStack
* yystack
)
1130 if (yystack
->yylastDeleted
== NULL
|| yystack
->yytops
.yysize
!= 0)
1132 yystack
->yytops
.yystates
[0] = yystack
->yylastDeleted
;
1133 yystack
->yytops
.yysize
= 1;
1134 YYDPRINTF ((stderr
, "Restoring last deleted stack as stack #0.\n"));
1135 yystack
->yylastDeleted
= NULL
;
1139 yyremoveDeletes (yyGLRStack
* yystack
)
1143 while (yyj
< yystack
->yytops
.yysize
)
1145 if (yystack
->yytops
.yystates
[yyi
] == NULL
)
1149 YYDPRINTF ((stderr
, "Removing dead stacks.\n"));
1151 yystack
->yytops
.yysize
-= 1;
1155 yystack
->yytops
.yystates
[yyj
] = yystack
->yytops
.yystates
[yyi
];
1158 YYDPRINTF ((stderr
, "Rename stack %lu -> %lu.\n",
1159 (unsigned long int) yyi
, (unsigned long int) yyj
));
1167 /** Shift to a new state on stack #K of STACK, corresponding to LR state
1168 * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
1170 yyglrShift (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1172 YYSTYPE yysval
, YYLTYPE
* yylocp
)
1174 yyGLRStackItem
* yynewItem
;
1176 yynewItem
= yystack
->yynextFree
;
1177 yystack
->yynextFree
+= 1;
1178 yystack
->yyspaceLeft
-= 1;
1179 yynewItem
->yystate
.yyisState
= yytrue
;
1180 yynewItem
->yystate
.yylrState
= yylrState
;
1181 yynewItem
->yystate
.yyposn
= yyposn
;
1182 yynewItem
->yystate
.yyresolved
= yytrue
;
1183 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1184 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1185 yynewItem
->yystate
.yysemantics
.yysval
= yysval
;
1186 yynewItem
->yystate
.yyloc
= *yylocp
;
1187 if (yystack
->yyspaceLeft
< YYHEADROOM
)
1188 yyexpandGLRStack (yystack
);
1191 /** Shift stack #K of YYSTACK, to a new state corresponding to LR
1192 * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
1193 * semantic value of YYRHS under the action for YYRULE. */
1195 yyglrShiftDefer (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1196 size_t yyposn
, yyGLRState
* rhs
, yyRuleNum yyrule
)
1198 yyGLRStackItem
* yynewItem
;
1200 yynewItem
= yystack
->yynextFree
;
1201 yynewItem
->yystate
.yyisState
= yytrue
;
1202 yynewItem
->yystate
.yylrState
= yylrState
;
1203 yynewItem
->yystate
.yyposn
= yyposn
;
1204 yynewItem
->yystate
.yyresolved
= yyfalse
;
1205 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1206 yynewItem
->yystate
.yysemantics
.yyfirstVal
= NULL
;
1207 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1208 yystack
->yynextFree
+= 1;
1209 yystack
->yyspaceLeft
-= 1;
1210 yyaddDeferredAction (yystack
, &yynewItem
->yystate
, rhs
, yyrule
);
1213 /** Pop the symbols consumed by reduction #RULE from the top of stack
1214 * #K of STACK, and perform the appropriate semantic action on their
1215 * semantic values. Assumes that all ambiguities in semantic values
1216 * have been previously resolved. Set *VALP to the resulting value,
1217 * and *LOCP to the computed location (if any). Return value is as
1218 * for userAction. */
1219 static inline YYRESULTTAG
1220 yydoAction (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1221 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1223 int yynrhs
= yyrhsLength (yyrule
);
1225 if (yystack
->yysplitPoint
== NULL
)
1227 /* Standard special case: single stack. */
1228 yyGLRStackItem
* rhs
= (yyGLRStackItem
*) yystack
->yytops
.yystates
[yyk
];
1229 YYASSERT (yyk
== 0);
1230 yystack
->yynextFree
-= yynrhs
;
1231 yystack
->yyspaceLeft
+= yynrhs
;
1232 yystack
->yytops
.yystates
[0] = & yystack
->yynextFree
[-1].yystate
;
1233 return yyuserAction (yyrule
, yynrhs
, rhs
,
1234 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1240 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1241 yys
= yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
1242 = yystack
->yytops
.yystates
[yyk
];
1243 for (yyi
= 0; yyi
< yynrhs
; yyi
+= 1)
1248 yyupdateSplit (yystack
, yys
);
1249 yystack
->yytops
.yystates
[yyk
] = yys
;
1250 return yyuserAction (yyrule
, yynrhs
, yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1251 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1256 # define YY_REDUCE_PRINT(K, Rule)
1258 # define YY_REDUCE_PRINT(K, Rule) \
1261 yy_reduce_print (K, Rule); \
1264 /*----------------------------------------------------------.
1265 | Report that the RULE is going to be reduced on stack #K. |
1266 `----------------------------------------------------------*/
1269 yy_reduce_print (size_t yyk
, yyRuleNum yyrule
)
1272 YYFPRINTF (stderr
, "Reducing stack %lu by rule %d (line %lu), ",
1273 (unsigned long int) yyk
, yyrule
- 1,
1274 (unsigned long int) yyrline
[yyrule
]);
1275 /* Print the symbols being reduced, and their result. */
1276 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
1277 YYFPRINTF (stderr
, "%s ", yytokenName (yyrhs
[yyi
]));
1278 YYFPRINTF (stderr
, "-> %s\n", yytokenName (yyr1
[yyrule
]));
1282 /** Pop items off stack #K of STACK according to grammar rule RULE,
1283 * and push back on the resulting nonterminal symbol. Perform the
1284 * semantic action associated with RULE and store its value with the
1285 * newly pushed state, if FORCEEVAL or if STACK is currently
1286 * unambiguous. Otherwise, store the deferred semantic action with
1287 * the new state. If the new state would have an identical input
1288 * position, LR state, and predecessor to an existing state on the stack,
1289 * it is identified with that existing state, eliminating stack #K from
1290 * the STACK. In this case, the (necessarily deferred) semantic value is
1291 * added to the options for the existing state's semantic value.
1293 static inline YYRESULTTAG
1294 yyglrReduce (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1295 yybool yyforceEval
]b4_user_formals
[)
1297 size_t yyposn
= yystack
->yytops
.yystates
[yyk
]->yyposn
;
1299 if (yyforceEval
|| yystack
->yysplitPoint
== NULL
)
1304 YY_REDUCE_PRINT (yyk
, yyrule
);
1305 YYCHK (yydoAction (yystack
, yyk
, yyrule
, &yysval
, &yyloc
]b4_user_args
[));
1306 yyglrShift (yystack
, yyk
,
1307 yyLRgotoState (yystack
->yytops
.yystates
[yyk
]->yylrState
,
1308 yylhsNonterm (yyrule
)),
1309 yyposn
, yysval
, &yyloc
);
1315 yyGLRState
* yys
, *yys0
= yystack
->yytops
.yystates
[yyk
];
1316 yyStateNum yynewLRState
;
1318 for (yys
= yystack
->yytops
.yystates
[yyk
], yyn
= yyrhsLength (yyrule
);
1324 yyupdateSplit (yystack
, yys
);
1325 yynewLRState
= yyLRgotoState (yys
->yylrState
, yylhsNonterm (yyrule
));
1327 "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
1328 (unsigned long int) yyk
, yyrule
- 1, yynewLRState
));
1329 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
1330 if (yyi
!= yyk
&& yystack
->yytops
.yystates
[yyi
] != NULL
)
1332 yyGLRState
* yyp
, *yysplit
= yystack
->yysplitPoint
;
1333 yyp
= yystack
->yytops
.yystates
[yyi
];
1334 while (yyp
!= yys
&& yyp
!= yysplit
&& yyp
->yyposn
>= yyposn
)
1336 if (yyp
->yylrState
== yynewLRState
&& yyp
->yypred
== yys
)
1338 yyaddDeferredAction (yystack
, yyp
, yys0
, yyrule
);
1339 yymarkStackDeleted (yystack
, yyk
);
1340 YYDPRINTF ((stderr
, "Merging stack %lu into stack %lu.\n",
1341 (unsigned long int) yyk
,
1342 (unsigned long int) yyi
));
1348 yystack
->yytops
.yystates
[yyk
] = yys
;
1349 yyglrShiftDefer (yystack
, yyk
, yynewLRState
, yyposn
, yys0
, yyrule
);
1355 yysplitStack (yyGLRStack
* yystack
, size_t yyk
)
1357 if (yystack
->yysplitPoint
== NULL
)
1359 YYASSERT (yyk
== 0);
1360 yystack
->yysplitPoint
= yystack
->yytops
.yystates
[yyk
];
1362 if (yystack
->yytops
.yysize
>= yystack
->yytops
.yycapacity
)
1364 yyGLRState
** yynewStates
;
1365 if (! ((yystack
->yytops
.yycapacity
1366 <= (YYSIZEMAX
/ (2 * sizeof yynewStates
[0])))
1368 (yyGLRState
**) YYREALLOC (yystack
->yytops
.yystates
,
1369 ((yystack
->yytops
.yycapacity
*= 2)
1370 * sizeof yynewStates
[0])))))
1371 yyMemoryExhausted (yystack
);
1372 yystack
->yytops
.yystates
= yynewStates
;
1374 yystack
->yytops
.yystates
[yystack
->yytops
.yysize
]
1375 = yystack
->yytops
.yystates
[yyk
];
1376 yystack
->yytops
.yysize
+= 1;
1377 return yystack
->yytops
.yysize
-1;
1380 /** True iff Y0 and Y1 represent identical options at the top level.
1381 * That is, they represent the same rule applied to RHS symbols
1382 * that produce the same terminal symbols. */
1384 yyidenticalOptions (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1386 if (yyy0
->yyrule
== yyy1
->yyrule
)
1388 yyGLRState
*yys0
, *yys1
;
1390 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1391 yyn
= yyrhsLength (yyy0
->yyrule
);
1393 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1394 if (yys0
->yyposn
!= yys1
->yyposn
)
1402 /** Assuming identicalOptions (Y0,Y1), destructively merge the
1403 * alternative semantic values for the RHS-symbols of Y1 and Y0. */
1405 yymergeOptionSets (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1407 yyGLRState
*yys0
, *yys1
;
1409 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1410 yyn
= yyrhsLength (yyy0
->yyrule
);
1412 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1416 else if (yys0
->yyresolved
)
1418 yys1
->yyresolved
= yytrue
;
1419 yys1
->yysemantics
.yysval
= yys0
->yysemantics
.yysval
;
1421 else if (yys1
->yyresolved
)
1423 yys0
->yyresolved
= yytrue
;
1424 yys0
->yysemantics
.yysval
= yys1
->yysemantics
.yysval
;
1428 yySemanticOption
** yyz0p
;
1429 yySemanticOption
* yyz1
;
1430 yyz0p
= &yys0
->yysemantics
.yyfirstVal
;
1431 yyz1
= yys1
->yysemantics
.yyfirstVal
;
1434 if (yyz1
== *yyz0p
|| yyz1
== NULL
)
1436 else if (*yyz0p
== NULL
)
1441 else if (*yyz0p
< yyz1
)
1443 yySemanticOption
* yyz
= *yyz0p
;
1445 yyz1
= yyz1
->yynext
;
1446 (*yyz0p
)->yynext
= yyz
;
1448 yyz0p
= &(*yyz0p
)->yynext
;
1450 yys1
->yysemantics
.yyfirstVal
= yys0
->yysemantics
.yyfirstVal
;
1455 /** Y0 and Y1 represent two possible actions to take in a given
1456 * parsing state; return 0 if no combination is possible,
1457 * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
1459 yypreference (yySemanticOption
* y0
, yySemanticOption
* y1
)
1461 yyRuleNum r0
= y0
->yyrule
, r1
= y1
->yyrule
;
1462 int p0
= yydprec
[r0
], p1
= yydprec
[r1
];
1466 if (yymerger
[r0
] == 0 || yymerger
[r0
] != yymerger
[r1
])
1471 if (p0
== 0 || p1
== 0)
1480 static YYRESULTTAG
yyresolveValue (yySemanticOption
* yyoptionList
,
1481 yyGLRStack
* yystack
, YYSTYPE
* yyvalp
,
1482 YYLTYPE
* yylocp
]b4_user_formals
[);
1485 yyresolveStates (yyGLRState
* yys
, int yyn
, yyGLRStack
* yystack
]b4_user_formals
[)
1490 YYASSERT (yys
->yypred
);
1491 yyflag
= yyresolveStates (yys
->yypred
, yyn
-1, yystack
]b4_user_args
[);
1494 if (! yys
->yyresolved
)
1496 yyflag
= yyresolveValue (yys
->yysemantics
.yyfirstVal
, yystack
,
1497 &yys
->yysemantics
.yysval
, &yys
->yyloc
1501 yys
->yyresolved
= yytrue
;
1508 yyresolveAction (yySemanticOption
* yyopt
, yyGLRStack
* yystack
,
1509 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1511 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1514 yynrhs
= yyrhsLength (yyopt
->yyrule
);
1515 YYCHK (yyresolveStates (yyopt
->yystate
, yynrhs
, yystack
]b4_user_args
[));
1516 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
= yyopt
->yystate
;
1517 return yyuserAction (yyopt
->yyrule
, yynrhs
,
1518 yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1519 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1524 yyreportTree (yySemanticOption
* yyx
, int yyindent
)
1526 int yynrhs
= yyrhsLength (yyx
->yyrule
);
1529 yyGLRState
* yystates
[YYMAXRHS
];
1530 yyGLRState yyleftmost_state
;
1532 for (yyi
= yynrhs
, yys
= yyx
->yystate
; 0 < yyi
; yyi
-= 1, yys
= yys
->yypred
)
1533 yystates
[yyi
] = yys
;
1536 yyleftmost_state
.yyposn
= 0;
1537 yystates
[0] = &yyleftmost_state
;
1542 if (yyx
->yystate
->yyposn
< yys
->yyposn
+ 1)
1543 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, empty>\n",
1544 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1547 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
1548 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1549 yyx
->yyrule
, (unsigned long int) (yys
->yyposn
+ 1),
1550 (unsigned long int) yyx
->yystate
->yyposn
);
1551 for (yyi
= 1; yyi
<= yynrhs
; yyi
+= 1)
1553 if (yystates
[yyi
]->yyresolved
)
1555 if (yystates
[yyi
-1]->yyposn
+1 > yystates
[yyi
]->yyposn
)
1556 YYFPRINTF (stderr
, "%*s%s <empty>\n", yyindent
+2, "",
1557 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]));
1559 YYFPRINTF (stderr
, "%*s%s <tokens %lu .. %lu>\n", yyindent
+2, "",
1560 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]),
1561 (unsigned long int) (yystates
[yyi
- 1]->yyposn
+ 1),
1562 (unsigned long int) yystates
[yyi
]->yyposn
);
1565 yyreportTree (yystates
[yyi
]->yysemantics
.yyfirstVal
, yyindent
+2);
1571 yyreportAmbiguity (yySemanticOption
* yyx0
, yySemanticOption
* yyx1
,
1572 yyGLRStack
* yystack
]b4_pure_formals
[)
1574 /* `Unused' warnings. */
1579 YYFPRINTF (stderr
, "Ambiguity detected.\n");
1580 YYFPRINTF (stderr
, "Option 1,\n");
1581 yyreportTree (yyx0
, 2);
1582 YYFPRINTF (stderr
, "\nOption 2,\n");
1583 yyreportTree (yyx1
, 2);
1584 YYFPRINTF (stderr
, "\n");
1586 yyFail (yystack
][]b4_pure_args
[, YY_("syntax is ambiguous"));
1590 /** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
1591 * actions, and return the result. */
1593 yyresolveValue (yySemanticOption
* yyoptionList
, yyGLRStack
* yystack
,
1594 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1596 yySemanticOption
* yybest
;
1597 yySemanticOption
* yyp
;
1600 yybest
= yyoptionList
;
1602 for (yyp
= yyoptionList
->yynext
; yyp
!= NULL
; yyp
= yyp
->yynext
)
1604 if (yyidenticalOptions (yybest
, yyp
))
1605 yymergeOptionSets (yybest
, yyp
);
1607 switch (yypreference (yybest
, yyp
))
1610 yyreportAmbiguity (yybest
, yyp
, yystack
]b4_pure_args
[);
1626 int yyprec
= yydprec
[yybest
->yyrule
];
1627 YYCHK (yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[));
1628 for (yyp
= yybest
->yynext
; yyp
!= NULL
; yyp
= yyp
->yynext
)
1630 if (yyprec
== yydprec
[yyp
->yyrule
])
1634 YYCHK (yyresolveAction (yyp
, yystack
, &yyval1
, &yydummy
]b4_user_args
[));
1635 yyuserMerge (yymerger
[yyp
->yyrule
], yyvalp
, &yyval1
);
1641 return yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[);
1645 yyresolveStack (yyGLRStack
* yystack
]b4_user_formals
[)
1647 if (yystack
->yysplitPoint
!= NULL
)
1652 for (yyn
= 0, yys
= yystack
->yytops
.yystates
[0];
1653 yys
!= yystack
->yysplitPoint
;
1654 yys
= yys
->yypred
, yyn
+= 1)
1656 YYCHK (yyresolveStates (yystack
->yytops
.yystates
[0], yyn
, yystack
1663 yycompressStack (yyGLRStack
* yystack
)
1665 yyGLRState
* yyp
, *yyq
, *yyr
;
1667 if (yystack
->yytops
.yysize
!= 1 || yystack
->yysplitPoint
== NULL
)
1670 for (yyp
= yystack
->yytops
.yystates
[0], yyq
= yyp
->yypred
, yyr
= NULL
;
1671 yyp
!= yystack
->yysplitPoint
;
1672 yyr
= yyp
, yyp
= yyq
, yyq
= yyp
->yypred
)
1675 yystack
->yyspaceLeft
+= yystack
->yynextFree
- yystack
->yyitems
;
1676 yystack
->yynextFree
= ((yyGLRStackItem
*) yystack
->yysplitPoint
) + 1;
1677 yystack
->yyspaceLeft
-= yystack
->yynextFree
- yystack
->yyitems
;
1678 yystack
->yysplitPoint
= NULL
;
1679 yystack
->yylastDeleted
= NULL
;
1683 yystack
->yynextFree
->yystate
= *yyr
;
1685 yystack
->yynextFree
->yystate
.yypred
= & yystack
->yynextFree
[-1].yystate
;
1686 yystack
->yytops
.yystates
[0] = &yystack
->yynextFree
->yystate
;
1687 yystack
->yynextFree
+= 1;
1688 yystack
->yyspaceLeft
-= 1;
1693 yyprocessOneStack (yyGLRStack
* yystack
, size_t yyk
,
1694 size_t yyposn
, YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
1698 const short int* yyconflicts
;
1700 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1702 while (yystack
->yytops
.yystates
[yyk
] != NULL
)
1704 yyStateNum yystate
= yystack
->yytops
.yystates
[yyk
]->yylrState
;
1705 YYDPRINTF ((stderr
, "Stack %lu Entering state %d\n",
1706 (unsigned long int) yyk
, yystate
));
1708 YYASSERT (yystate
!= YYFINAL
);
1710 if (yyisDefaultedState (yystate
))
1712 yyrule
= yydefaultAction (yystate
);
1715 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1716 (unsigned long int) yyk
));
1717 yymarkStackDeleted (yystack
, yyk
);
1720 YYCHK (yyglrReduce (yystack
, yyk
, yyrule
, yyfalse
]b4_user_args
[));
1724 if (*yytokenp
== YYEMPTY
)
1726 YYDPRINTF ((stderr
, "Reading a token: "));
1728 *yytokenp
= YYTRANSLATE (yychar
);
1729 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1730 YYDPRINTF ((stderr
, "\n"));
1732 yygetLRActions (yystate
, *yytokenp
, &yyaction
, &yyconflicts
);
1734 while (*yyconflicts
!= 0)
1736 size_t yynewStack
= yysplitStack (yystack
, yyk
);
1737 YYDPRINTF ((stderr
, "Splitting off stack %lu from %lu.\n",
1738 (unsigned long int) yynewStack
,
1739 (unsigned long int) yyk
));
1740 YYCHK (yyglrReduce (yystack
, yynewStack
,
1741 *yyconflicts
, yyfalse
]b4_user_args
[));
1742 YYCHK (yyprocessOneStack (yystack
, yynewStack
, yyposn
,
1743 yylvalp
, yyllocp
]b4_pure_args
[));
1747 if (yyisShiftAction (yyaction
))
1749 YYDPRINTF ((stderr
, "On stack %lu, ", (unsigned long int) yyk
));
1750 YY_SYMBOL_PRINT ("shifting", *yytokenp
, yylvalp
, yyllocp
);
1751 yyglrShift (yystack
, yyk
, yyaction
, yyposn
+1,
1753 YYDPRINTF ((stderr
, ", now in state #%d\n",
1754 yystack
->yytops
.yystates
[yyk
]->yylrState
));
1757 else if (yyisErrorAction (yyaction
))
1759 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1760 (unsigned long int) yyk
));
1761 yymarkStackDeleted (yystack
, yyk
);
1765 YYCHK (yyglrReduce (yystack
, yyk
, -yyaction
, yyfalse
]b4_user_args
[));
1772 yyreportSyntaxError (yyGLRStack
* yystack
,
1773 YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
]b4_user_formals
[)
1775 /* `Unused' warnings. */
1779 if (yystack
->yyerrState
== 0)
1782 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1784 yyn
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1785 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1787 size_t yysize0
= yytnamerr (NULL
, yytokenName (*yytokenp
));
1788 size_t yysize
= yysize0
;
1790 yybool yysize_overflow
= yyfalse
;
1792 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1793 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1797 static char const yyunexpected
[] = "syntax error, unexpected %s";
1798 static char const yyexpecting
[] = ", expecting %s";
1799 static char const yyor
[] = " or %s";
1800 char yyformat
[sizeof yyunexpected
1801 + sizeof yyexpecting
- 1
1802 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1803 * (sizeof yyor
- 1))];
1804 char const *yyprefix
= yyexpecting
;
1806 /* Start YYX at -YYN if negative to avoid negative indexes in
1808 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1810 /* Stay within bounds of both yycheck and yytname. */
1811 int yychecklim
= YYLAST
- yyn
;
1812 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1815 yyarg
[0] = yytokenName (*yytokenp
);
1816 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1818 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1819 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1821 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1825 yyformat
[sizeof yyunexpected
- 1] = '\0';
1828 yyarg
[yycount
++] = yytokenName (yyx
);
1829 yysize1
= yysize
+ yytnamerr (NULL
, yytokenName (yyx
));
1830 yysize_overflow
|= yysize1
< yysize
;
1832 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1836 yyf
= YY_(yyformat
);
1837 yysize1
= yysize
+ strlen (yyf
);
1838 yysize_overflow
|= yysize1
< yysize
;
1841 if (!yysize_overflow
)
1842 yymsg
= (char *) YYMALLOC (yysize
);
1848 while ((*yyp
= *yyf
))
1850 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1852 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1861 yyerror (]b4_lyyerror_args
[yymsg
);
1866 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1867 yyMemoryExhausted (yystack
);
1871 #endif /* YYERROR_VERBOSE */
1872 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1877 /* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
1878 YYLVALP, and YYLLOCP point to the syntactic category, semantic
1879 value, and location of the look-ahead. */
1881 yyrecoverSyntaxError (yyGLRStack
* yystack
,
1883 YYLTYPE
* YYOPTIONAL_LOC (yyllocp
)
1886 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1890 if (yystack
->yyerrState
== 3)
1891 /* We just shifted the error token and (perhaps) took some
1892 reductions. Skip tokens until we can proceed. */
1895 if (*yytokenp
== YYEOF
)
1896 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1897 if (*yytokenp
!= YYEMPTY
)
1899 /* We throw away the lookahead, but the error range
1900 of the shifted error token must take it into account. */
1901 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
1902 yyGLRStackItem yyerror_range
[3];
1903 yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;
1904 yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
1905 YYLLOC_DEFAULT (yys
->yyloc
, yyerror_range
, 2);]])[
1906 yydestruct ("Error: discarding",
1907 *yytokenp
, yylvalp
]b4_location_if([, yyllocp
])[);
1909 YYDPRINTF ((stderr
, "Reading a token: "));
1911 *yytokenp
= YYTRANSLATE (yychar
);
1912 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1913 YYDPRINTF ((stderr
, "\n"));
1914 yyj
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1915 if (yyis_pact_ninf (yyj
))
1918 if (yyj
< 0 || YYLAST
< yyj
|| yycheck
[yyj
] != *yytokenp
)
1920 if (yydefact
[yystack
->yytops
.yystates
[0]->yylrState
] != 0)
1923 else if (yytable
[yyj
] != 0 && ! yyis_table_ninf (yytable
[yyj
]))
1927 /* Reduce to one stack. */
1928 for (yyk
= 0; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
1929 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1931 if (yyk
>= yystack
->yytops
.yysize
)
1932 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1933 for (yyk
+= 1; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
1934 yymarkStackDeleted (yystack
, yyk
);
1935 yyremoveDeletes (yystack
);
1936 yycompressStack (yystack
);
1938 /* Now pop stack until we find a state that shifts the error token. */
1939 yystack
->yyerrState
= 3;
1940 while (yystack
->yytops
.yystates
[0] != NULL
)
1942 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
1943 yyj
= yypact
[yys
->yylrState
];
1944 if (! yyis_pact_ninf (yyj
))
1947 if (0 <= yyj
&& yyj
<= YYLAST
&& yycheck
[yyj
] == YYTERROR
1948 && yyisShiftAction (yytable
[yyj
]))
1950 /* Shift the error token having adjusted its location. */
1951 YYLTYPE yyerrloc
;]b4_location_if([[
1952 yystack
->yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
1953 YYLLOC_DEFAULT (yyerrloc
, yystack
->yyerror_range
, 2);]])[
1954 YY_SYMBOL_PRINT ("Shifting", yystos
[yytable
[yyj
]],
1955 yylvalp
, &yyerrloc
);
1956 YYDPRINTF ((stderr
, "\n"));
1957 yyglrShift (yystack
, 0, yytable
[yyj
],
1958 yys
->yyposn
, *yylvalp
, &yyerrloc
);
1959 yys
= yystack
->yytops
.yystates
[0];
1963 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]])[
1964 yydestruct ("Error: popping",
1965 yystos
[yys
->yylrState
],
1966 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[);
1967 yystack
->yytops
.yystates
[0] = yys
->yypred
;
1968 yystack
->yynextFree
-= 1;
1969 yystack
->yyspaceLeft
+= 1;
1971 if (yystack
->yytops
.yystates
[0] == NULL
)
1972 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1975 #define YYCHK1(YYE) \
1985 goto yyuser_error; \
1994 ]b4_c_ansi_function_def([yyparse
], [int], b4_parse_param
)[
2005 #define yychar (yystack.yyrawchar)
2008 YYSTYPE
* const yylvalp
= &yylval
;
2009 YYLTYPE
* const yyllocp
= &yylloc
;
2011 YYDPRINTF ((stderr
, "Starting parse\n"));
2014 yylval
= yyval_default
;
2016 #if YYLTYPE_IS_TRIVIAL
2017 yylloc
.first_line
= yylloc
.last_line
= 1;
2018 yylloc
.first_column
= yylloc
.last_column
= 0;
2021 m4_ifdef([b4_initial_action
], [
2022 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
2023 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
2024 /* User initialization code. */
2026 m4_popdef([b4_dollar_dollar
])dnl
2027 m4_popdef([b4_at_dollar
])dnl
2028 /* Line __line__ of glr.c. */
2029 b4_syncline([@oline@
], [@ofile@
])])dnl
2031 if (! yyinitGLRStack (&yystack
, YYINITDEPTH
))
2032 goto yyexhaustedlab
;
2033 switch (setjmp (yystack
.yyexception_buffer
))
2035 case 1: goto yyabortlab
;
2036 case 2: goto yyexhaustedlab
;
2038 yystack
.yytokenp
= &yytoken
;
2039 yyglrShift (&yystack
, 0, 0, 0, yylval
, &yylloc
);
2044 /* For efficiency, we have two loops, the first of which is
2045 specialized to deterministic operation (single stack, no
2046 potential ambiguity). */
2052 const short int* yyconflicts
;
2054 yyStateNum yystate
= yystack
.yytops
.yystates
[0]->yylrState
;
2055 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
2056 if (yystate
== YYFINAL
)
2058 if (yyisDefaultedState (yystate
))
2060 yyrule
= yydefaultAction (yystate
);
2063 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2064 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2067 YYCHK1 (yyglrReduce (&yystack
, 0, yyrule
, yytrue
]b4_user_args
[));
2071 if (yytoken
== YYEMPTY
)
2073 YYDPRINTF ((stderr
, "Reading a token: "));
2075 yytoken
= YYTRANSLATE (yychar
);
2076 YY_SYMBOL_PRINT ("Next token is", yytoken
, yylvalp
, yyllocp
);
2077 YYDPRINTF ((stderr
, "\n"));
2079 yygetLRActions (yystate
, yytoken
, &yyaction
, &yyconflicts
);
2080 if (*yyconflicts
!= 0)
2082 if (yyisShiftAction (yyaction
))
2084 YY_SYMBOL_PRINT ("Shifting", yytoken
, yylvalp
, yyllocp
);
2085 YYDPRINTF ((stderr
, "\n"));
2086 if (yytoken
!= YYEOF
)
2089 yyglrShift (&yystack
, 0, yyaction
, yyposn
, yylval
, yyllocp
);
2090 if (0 < yystack
.yyerrState
)
2091 yystack
.yyerrState
-= 1;
2093 else if (yyisErrorAction (yyaction
))
2095 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2096 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2100 YYCHK1 (yyglrReduce (&yystack
, 0, -yyaction
, yytrue
]b4_user_args
[));
2107 size_t yyn
= yystack
.yytops
.yysize
;
2108 for (yys
= 0; yys
< yyn
; yys
+= 1)
2109 YYCHK1 (yyprocessOneStack (&yystack
, yys
, yyposn
,
2110 yylvalp
, yyllocp
]b4_lpure_args
[));
2113 yyremoveDeletes (&yystack
);
2114 if (yystack
.yytops
.yysize
== 0)
2116 yyundeleteLastStack (&yystack
);
2117 if (yystack
.yytops
.yysize
== 0)
2118 yyFail (&yystack
][]b4_lpure_args
[, YY_("syntax error"));
2119 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2120 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2121 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2122 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2125 else if (yystack
.yytops
.yysize
== 1)
2127 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2128 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2129 yycompressStack (&yystack
);
2135 yyrecoverSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2136 yyposn
= yystack
.yytops
.yystates
[0]->yyposn
;
2148 yyerror (]b4_lyyerror_args
[YY_("memory exhausted"));
2153 if (yytoken
!= YYEOF
&& yytoken
!= YYEMPTY
)
2154 yydestruct ("Error: discarding lookahead",
2155 yytoken
, yylvalp
]b4_location_if([, yyllocp
])[);
2157 /* Now pop stack until empty, destroying its entries as we go. */
2159 yyGLRState
** yystates
= yystack
.yytops
.yystates
;
2163 yyGLRState
*yys
= yystates
[0];
2164 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]]
2165 )[ yydestruct ("Error: popping",
2166 yystos
[yys
->yylrState
],
2167 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[);
2168 yystates
[0] = yys
->yypred
;
2169 yystack
.yynextFree
-= 1;
2170 yystack
.yyspaceLeft
+= 1;
2174 yyfreeGLRStack (&yystack
);
2178 /* DEBUGGING ONLY */
2180 static void yypstack (yyGLRStack
* yystack
, size_t yyk
) ATTRIBUTE_UNUSED
;
2181 static void yypdumpstack (yyGLRStack
* yystack
) ATTRIBUTE_UNUSED
;
2184 yy_yypstack (yyGLRState
* yys
)
2188 yy_yypstack (yys
->yypred
);
2189 fprintf (stderr
, " -> ");
2191 fprintf (stderr
, "%d@@%lu", yys
->yylrState
, (unsigned long int) yys
->yyposn
);
2195 yypstates (yyGLRState
* yyst
)
2198 fprintf (stderr
, "<null>");
2201 fprintf (stderr
, "\n");
2205 yypstack (yyGLRStack
* yystack
, size_t yyk
)
2207 yypstates (yystack
->yytops
.yystates
[yyk
]);
2210 #define YYINDEX(YYX) \
2211 ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
2215 yypdumpstack (yyGLRStack
* yystack
)
2217 yyGLRStackItem
* yyp
;
2219 for (yyp
= yystack
->yyitems
; yyp
< yystack
->yynextFree
; yyp
+= 1)
2221 fprintf (stderr
, "%3lu. ", (unsigned long int) (yyp
- yystack
->yyitems
));
2222 if (*(yybool
*) yyp
)
2224 fprintf (stderr
, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
2225 yyp
->yystate
.yyresolved
, yyp
->yystate
.yylrState
,
2226 (unsigned long int) yyp
->yystate
.yyposn
,
2227 (long int) YYINDEX (yyp
->yystate
.yypred
));
2228 if (! yyp
->yystate
.yyresolved
)
2229 fprintf (stderr
, ", firstVal: %ld",
2230 (long int) YYINDEX (yyp
->yystate
.yysemantics
.yyfirstVal
));
2234 fprintf (stderr
, "Option. rule: %d, state: %ld, next: %ld",
2235 yyp
->yyoption
.yyrule
,
2236 (long int) YYINDEX (yyp
->yyoption
.yystate
),
2237 (long int) YYINDEX (yyp
->yyoption
.yynext
));
2239 fprintf (stderr
, "\n");
2241 fprintf (stderr
, "Tops:");
2242 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
2243 fprintf (stderr
, "%lu: %ld; ", (unsigned long int) yyi
,
2244 (long int) YYINDEX (yystack
->yytops
.yystates
[yyi
]));
2245 fprintf (stderr
, "\n");
2251 m4_if(b4_defines_flag
, 0, [],
2252 [@output @output_header_name@
2253 b4_copyright([Skeleton parser
for GLR parsing with Bison
],
2254 [2002, 2003, 2004, 2005])
2256 b4_token_defines(b4_tokens
)
2258 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
2259 m4_ifdef([b4_stype
],
2260 [b4_syncline([b4_stype_line
], [b4_filename
])
2261 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
2262 /* Line __line__ of glr.c. */
2263 b4_syncline([@oline@
], [@ofile@
])],
2264 [typedef int YYSTYPE
;])
2265 # define YYSTYPE_IS_DECLARED 1
2266 # define YYSTYPE_IS_TRIVIAL 1
2270 [extern YYSTYPE b4_prefix
[]lval
;])
2272 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
2273 typedef struct YYLTYPE
2284 # define YYLTYPE_IS_DECLARED 1
2285 # define YYLTYPE_IS_TRIVIAL 1
2288 b4_location_if([b4_pure_if([],
2289 [extern YYLTYPE b4_prefix
[]lloc
;])