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 # This is specific to GLR because it relies on ISO C formal argument
41 m4_define([b4_user_formals
],
42 [m4_ifset([b4_parse_param
], [, b4_c_ansi_formals(b4_parse_param
)])])
47 # Accumule in b4_lex_param all the yylex arguments.
48 # Yes, this is quite ugly...
49 m4_define([b4_lex_param
],
50 m4_dquote(b4_pure_if([[[[YYSTYPE
*]], [[yylvalp]]][]dnl
51 b4_location_if([, [[YYLTYPE
*], [yyllocp
]]])])dnl
52 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
)))
57 # Arguments passed to yyerror: user args plus yylloc.
58 m4_define([b4_yyerror_args
],
59 [b4_pure_if([b4_location_if([yylocp
, ])])dnl
60 m4_ifset([b4_parse_param
], [b4_c_args(b4_parse_param
), ])])
65 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
66 m4_define([b4_lyyerror_args
],
67 [b4_pure_if([b4_location_if([yyllocp
, ])])dnl
68 m4_ifset([b4_parse_param
], [b4_c_args(b4_parse_param
), ])])
73 # Arguments needed by yyerror: user args plus yylloc.
74 m4_define([b4_pure_args
],
75 [b4_pure_if([b4_location_if([, yylocp
])])[]b4_user_args
])
80 # Arguments passed to yyerror: user formals plus yyllocp.
81 m4_define([b4_pure_formals
],
82 [b4_pure_if([b4_location_if([, YYLTYPE
*yylocp
])])[]b4_user_formals
])
87 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
88 m4_define([b4_lpure_args
],
89 [b4_pure_if([b4_location_if([, yyllocp
])])[]b4_user_args
])
94 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
95 m4_define([b4_lpure_formals
],
96 [b4_pure_if([b4_location_if([YYLTYPE
*yyllocp
])])[]b4_user_formals
])
99 ## ----------------- ##
100 ## Semantic Values. ##
101 ## ----------------- ##
104 # b4_lhs_value([TYPE])
105 # --------------------
106 # Expansion of $<TYPE>$.
107 m4_define([b4_lhs_value
],
108 [((*yyvalp
)[]m4_ifval([$
1], [.$
1]))])
111 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
112 # --------------------------------------
113 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
115 m4_define([b4_rhs_value
],
116 [(((yyGLRStackItem
const *)yyvsp
)@
{YYFILL (m4_eval([$
2 - $
1]))@
}.yystate
.yysemantics
.yysval
[]m4_ifval([$
3], [.$
3]))])
127 m4_define([b4_lhs_location
],
131 # b4_rhs_location(RULE-LENGTH, NUM)
132 # ---------------------------------
133 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
135 m4_define([b4_rhs_location
],
136 [(((yyGLRStackItem
const *)yyvsp
)@
{YYFILL (m4_eval([$
2 - $
1]))@
}.yystate
.yyloc
)])
138 # We do want M4 expansion after # for CPP macros.
141 @output @output_parser_name@
142 b4_copyright([Skeleton parser
for GLR parsing with Bison
],
143 [2002, 2003, 2004, 2005])
145 /* This is the parser code for GLR (Generalized LR) parser. */
148 m4_if(b4_prefix
[], [yy
], [],
149 [/* Substitute the variable and function names. */
150 #define yyparse b4_prefix[]parse
151 #define yylex b4_prefix[]lex
152 #define yyerror b4_prefix[]error
153 #define yylval b4_prefix[]lval
154 #define yychar b4_prefix[]char
155 #define yydebug b4_prefix[]debug
156 #define yynerrs b4_prefix[]nerrs
157 #define yylloc b4_prefix[]lloc])
159 b4_token_enums(b4_tokens
)
161 /* Copy the first part of user declarations. */
164 /* Enabling traces. */
166 # define YYDEBUG ]b4_debug[
169 /* Enabling verbose error messages. */
170 #ifdef YYERROR_VERBOSE
171 # undef YYERROR_VERBOSE
172 # define YYERROR_VERBOSE 1
174 # define YYERROR_VERBOSE ]b4_error_verbose[
177 /* Enabling the token table. */
178 #ifndef YYTOKEN_TABLE
179 # define YYTOKEN_TABLE ]b4_token_table[
182 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
183 ]m4_ifdef([b4_stype
],
184 [b4_syncline([b4_stype_line
], [b4_file_name
])
185 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
186 /* Line __line__ of glr.c. */
187 b4_syncline([@oline@
], [@ofile@
])],
188 [typedef int YYSTYPE
;])[
189 # define YYSTYPE_IS_DECLARED 1
190 # define YYSTYPE_IS_TRIVIAL 1
193 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
194 typedef struct YYLTYPE
205 # define YYLTYPE_IS_DECLARED 1
206 # define YYLTYPE_IS_TRIVIAL 1
209 /* Default (constant) value used for initialization for null
210 right-hand sides. Unlike the standard yacc.c template,
211 here we set the default value of $$ to a zeroed-out value.
212 Since the default value is undefined, this behavior is
213 technically correct. */
214 static YYSTYPE yyval_default
;
216 /* Copy the second part of user declarations. */
219 ]/* Line __line__ of glr.c. */
220 b4_syncline([@oline@
], [@ofile@
])
230 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
231 # define YY_(msgid) dgettext ("bison-runtime", msgid)
235 # define YY_(msgid) msgid
239 /* Suppress unused-variable warnings by "using" E. */
240 #define YYUSE(e) do {;} while (/*CONSTCOND*/ yyfalse && (e))
246 # define YYMALLOC malloc
249 # define YYREALLOC realloc
252 #define YYSIZEMAX ((size_t) -1)
257 typedef unsigned char yybool
;
264 # define YYJMP_BUF jmp_buf
265 # define YYSETJMP(env) setjmp (env)
266 # define YYLONGJMP(env, val) longjmp (env, val)
273 #ifndef __attribute__
274 /* This feature is available in gcc versions 2.5 and later. */
275 # if (!defined (__GNUC__) || __GNUC__ < 2 \
276 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
277 # define __attribute__(Spec) /* empty */
281 ]b4_location_if([#define YYOPTIONAL_LOC(Name) Name],[
283 # define YYOPTIONAL_LOC(Name) /* empty */
285 # define YYOPTIONAL_LOC(Name) Name __attribute__ ((__unused__))
289 # define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
292 /* YYFINAL -- State number of the termination state. */
293 #define YYFINAL ]b4_final_state_number[
294 /* YYLAST -- Last index in YYTABLE. */
295 #define YYLAST ]b4_last[
297 /* YYNTOKENS -- Number of terminals. */
298 #define YYNTOKENS ]b4_tokens_number[
299 /* YYNNTS -- Number of nonterminals. */
300 #define YYNNTS ]b4_nterms_number[
301 /* YYNRULES -- Number of rules. */
302 #define YYNRULES ]b4_rules_number[
303 /* YYNRULES -- Number of states. */
304 #define YYNSTATES ]b4_states_number[
305 /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
306 #define YYMAXRHS ]b4_r2_max[
307 /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
308 accessed by $0, $-1, etc., in any rule. */
309 #define YYMAXLEFT ]b4_max_left_semantic_context[
311 /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
312 #define YYUNDEFTOK ]b4_undef_token_number[
313 #define YYMAXUTOK ]b4_user_token_number_max[
315 #define YYTRANSLATE(YYX) \
316 ((YYX <= 0) ? YYEOF : \
317 (unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
319 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
320 static const ]b4_int_type_for([b4_translate
])[ yytranslate
[] =
326 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
328 static const ]b4_int_type_for([b4_prhs
])[ yyprhs
[] =
333 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
334 static const ]b4_int_type_for([b4_rhs
])[ yyrhs
[] =
339 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
340 static const ]b4_int_type_for([b4_rline
])[ yyrline
[] =
346 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
347 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
348 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
349 static const char *const yytname
[] =
355 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
356 static const ]b4_int_type_for([b4_r1
])[ yyr1
[] =
361 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
362 static const ]b4_int_type_for([b4_r2
])[ yyr2
[] =
367 /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
368 static const ]b4_int_type_for([b4_dprec
])[ yydprec
[] =
373 /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
374 static const ]b4_int_type_for([b4_merger
])[ yymerger
[] =
379 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
380 doesn't specify something else to do. Zero means the default is an
382 static const ]b4_int_type_for([b4_defact
])[ yydefact
[] =
387 /* YYPDEFGOTO[NTERM-NUM]. */
388 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto
[] =
393 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
395 #define YYPACT_NINF ]b4_pact_ninf[
396 static const ]b4_int_type_for([b4_pact
])[ yypact
[] =
401 /* YYPGOTO[NTERM-NUM]. */
402 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto
[] =
407 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
408 positive, shift that token. If negative, reduce the rule which
409 number is the opposite. If zero, do what YYDEFACT says.
410 If YYTABLE_NINF, syntax error. */
411 #define YYTABLE_NINF ]b4_table_ninf[
412 static const ]b4_int_type_for([b4_table
])[ yytable
[] =
417 /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
418 list of conflicting reductions corresponding to action entry for
419 state STATE-NUM in yytable. 0 means no conflicts. The list in
420 yyconfl is terminated by a rule number of 0. */
421 static const ]b4_int_type_for([b4_conflict_list_heads
])[ yyconflp
[] =
423 ]b4_conflict_list_heads
[
426 /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
427 0, pointed into by YYCONFLP. */
428 ]dnl Do
not use b4_int_type_for here
, since there are places where
429 dnl pointers onto yyconfl are taken
, which type is
"short int *".
430 dnl We probably ought to introduce a type
for confl
.
431 [static const short int yyconfl
[] =
433 ]b4_conflicting_rules
[
436 static const ]b4_int_type_for([b4_check
])[ yycheck
[] =
441 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
442 symbol of state STATE-NUM. */
443 static const ]b4_int_type_for([b4_stos
])[ yystos
[] =
449 /* Prevent warning if -Wmissing-prototypes. */
450 ]b4_c_ansi_function_decl([yyparse
], [int], b4_parse_param
)[
452 /* Error token number */
455 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
456 If N is 0, then set CURRENT to the empty location which ends
457 the previous symbol: RHS[0] (always defined). */
460 #define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
461 #ifndef YYLLOC_DEFAULT
462 # define YYLLOC_DEFAULT(Current, Rhs, N) \
466 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
467 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
468 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
469 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
473 (Current).first_line = (Current).last_line = \
474 YYRHSLOC (Rhs, 0).last_line; \
475 (Current).first_column = (Current).last_column = \
476 YYRHSLOC (Rhs, 0).last_column; \
478 while (/*CONSTCOND*/ 0)
480 /* YY_LOCATION_PRINT -- Print the location on the stream.
481 This macro was not mandated originally: define only if we know
482 we won't break user code: when these are the locations we know. */
484 # define YY_LOCATION_PRINT(File, Loc) \
485 fprintf (File, "%d.%d-%d.%d", \
486 (Loc).first_line, (Loc).first_column, \
487 (Loc).last_line, (Loc).last_column)
490 #ifndef YYLLOC_DEFAULT
491 # define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)
495 #ifndef YY_LOCATION_PRINT
496 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
500 /* YYLEX -- calling `yylex' with the right arguments. */
501 #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
506 #define yynerrs (yystack->yyerrcnt)
508 #define yychar (yystack->yyrawchar)],
516 static const int YYEOF
= 0;
517 static const int YYEMPTY
= -2;
519 typedef enum { yyok
, yyaccept
, yyabort
, yyerr
} YYRESULTTAG
;
522 do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
523 while (/*CONSTCOND*/ 0)
527 #if ! defined (YYFPRINTF)
528 # define YYFPRINTF fprintf
531 # define YYDPRINTF(Args) \
535 } while (/*CONSTCOND*/ 0)
537 ]b4_yysymprint_generate([b4_c_ansi_function_def
])[
539 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
543 YYFPRINTF (stderr, "%s ", Title); \
544 yysymprint (stderr, \
545 Type, Value]b4_location_if([, Location])[]b4_user_args[); \
546 YYFPRINTF (stderr, "\n"); \
548 } while (/*CONSTCOND*/ 0)
550 /* Nonzero means print parse trace. It is left uninitialized so that
551 multiple parsers can coexist. */
556 # define YYDPRINTF(Args)
557 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
559 #endif /* !YYDEBUG */
561 /* YYINITDEPTH -- initial size of the parser's stacks. */
563 # define YYINITDEPTH ]b4_stack_depth_init[
566 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
567 if the built-in stack extension method is used).
569 Do not make this value too large; the results are undefined if
570 SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
571 evaluated with infinite-precision integer arithmetic. */
574 # define YYMAXDEPTH ]b4_stack_depth_max[
577 /* Minimum number of free items on the stack allowed after an
578 allocation. This is to allow allocation and initialization
579 to be completed by functions that call yyexpandGLRStack before the
580 stack is expanded, thus insuring that all necessary pointers get
581 properly redirected to new data. */
584 #ifndef YYSTACKEXPANDABLE
585 # if (! defined (__cplusplus) \
586 || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \
587 && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))
588 # define YYSTACKEXPANDABLE 1
590 # define YYSTACKEXPANDABLE 0
597 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
598 # define yystpcpy stpcpy
600 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
603 yystpcpy (char *yydest
, const char *yysrc
)
606 const char *yys
= yysrc
;
608 while ((*yyd
++ = *yys
++) != '\0')
617 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
618 quotes and backslashes, so that it's suitable for yyerror. The
619 heuristic is that double-quoting is unnecessary unless the string
620 contains an apostrophe, a comma, or backslash (other than
621 backslash-backslash). YYSTR is taken from yytname. If YYRES is
622 null, do not copy; instead, return the length of what the result
625 yytnamerr (char *yyres
, const char *yystr
)
630 char const *yyp
= yystr
;
637 goto do_not_strip_quotes
;
641 goto do_not_strip_quotes
;
654 do_not_strip_quotes
: ;
658 return strlen (yystr
);
660 return yystpcpy (yyres
, yystr
) - yyres
;
664 #endif /* !YYERROR_VERBOSE */
666 /** State numbers, as in LALR(1) machine */
667 typedef int yyStateNum
;
669 /** Rule numbers, as in LALR(1) machine */
670 typedef int yyRuleNum
;
672 /** Grammar symbol */
673 typedef short int yySymbol
;
675 /** Item references, as in LALR(1) machine */
676 typedef short int yyItemNum
;
678 typedef struct yyGLRState yyGLRState
;
679 typedef struct yySemanticOption yySemanticOption
;
680 typedef union yyGLRStackItem yyGLRStackItem
;
681 typedef struct yyGLRStack yyGLRStack
;
682 typedef struct yyGLRStateSet yyGLRStateSet
;
685 /** Type tag: always true. */
687 /** Type tag for yysemantics. If true, yysval applies, otherwise
688 * yyfirstVal applies. */
690 /** Number of corresponding LALR(1) machine state. */
691 yyStateNum yylrState
;
692 /** Preceding state in this stack */
694 /** Source position of the first token produced by my symbol */
697 /** First in a chain of alternative reductions producing the
698 * non-terminal corresponding to this state, threaded through
700 yySemanticOption
* yyfirstVal
;
701 /** Semantic value for this state. */
704 /** Source location for this state. */
708 struct yyGLRStateSet
{
709 yyGLRState
** yystates
;
710 size_t yysize
, yycapacity
;
713 struct yySemanticOption
{
714 /** Type tag: always false. */
716 /** Rule number for this reduction */
718 /** The last RHS state in the list of states to be reduced. */
720 /** Next sibling in chain of options. To facilitate merging,
721 * options are chained in decreasing order by address. */
722 yySemanticOption
* yynext
;
725 /** Type of the items in the GLR stack. The yyisState field
726 * indicates which item of the union is valid. */
727 union yyGLRStackItem
{
729 yySemanticOption yyoption
;
734 ]b4_location_if([[ /* To compute the location of the error token. */
735 yyGLRStackItem yyerror_range
[3];]])[
742 YYJMP_BUF yyexception_buffer
;
743 yyGLRStackItem
* yyitems
;
744 yyGLRStackItem
* yynextFree
;
746 yyGLRState
* yysplitPoint
;
747 yyGLRState
* yylastDeleted
;
748 yyGLRStateSet yytops
;
751 static void yyexpandGLRStack (yyGLRStack
* yystack
);
753 static void yyFail (yyGLRStack
* yystack
]b4_pure_formals
[, const char* yymsg
)
754 __attribute__ ((__noreturn__
));
756 yyFail (yyGLRStack
* yystack
]b4_pure_formals
[, const char* yymsg
)
759 yyerror (]b4_yyerror_args
[yymsg
);
760 YYLONGJMP (yystack
->yyexception_buffer
, 1);
763 static void yyMemoryExhausted (yyGLRStack
* yystack
)
764 __attribute__ ((__noreturn__
));
766 yyMemoryExhausted (yyGLRStack
* yystack
)
768 YYLONGJMP (yystack
->yyexception_buffer
, 2);
771 #if YYDEBUG || YYERROR_VERBOSE
772 /** A printable representation of TOKEN. */
773 static inline const char*
774 yytokenName (yySymbol yytoken
)
776 if (yytoken
== YYEMPTY
)
779 return yytname
[yytoken
];
783 /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
784 * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
785 * containing the pointer to the next state in the chain. */
786 static void yyfillin (yyGLRStackItem
*, int, int) __attribute__ ((__unused__
));
788 yyfillin (yyGLRStackItem
*yyvsp
, int yylow0
, int yylow1
)
792 s
= yyvsp
[yylow0
].yystate
.yypred
;
793 for (i
= yylow0
-1; i
>= yylow1
; i
-= 1)
795 YYASSERT (s
->yyresolved
);
796 yyvsp
[i
].yystate
.yyresolved
= yytrue
;
797 yyvsp
[i
].yystate
.yysemantics
.yysval
= s
->yysemantics
.yysval
;
798 yyvsp
[i
].yystate
.yyloc
= s
->yyloc
;
799 s
= yyvsp
[i
].yystate
.yypred
= s
->yypred
;
803 /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
804 * YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
805 * For convenience, always return YYLOW1. */
806 static inline int yyfill (yyGLRStackItem
*, int *, int, yybool
)
807 __attribute__ ((__unused__
));
809 yyfill (yyGLRStackItem
*yyvsp
, int *yylow
, int yylow1
, yybool yynormal
)
811 if (!yynormal
&& yylow1
< *yylow
)
813 yyfillin (yyvsp
, *yylow
, yylow1
);
819 /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
820 * and top stack item YYVSP. YYLVALP points to place to put semantic
821 * value ($$), and yylocp points to place for location information
822 * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
823 * yyerr for YYERROR, yyabort for YYABORT. */
825 yyuserAction (yyRuleNum yyn
, int yyrhslen
, yyGLRStackItem
* yyvsp
,
827 YYLTYPE
* YYOPTIONAL_LOC (yylocp
),
831 yybool yynormal
__attribute__ ((__unused__
)) =
832 (yystack
->yysplitPoint
== NULL
);
836 # define yyerrok (yystack->yyerrState = 0)
838 # define YYACCEPT return yyaccept
840 # define YYABORT return yyabort
842 # define YYERROR return yyerrok, yyerr
844 # define YYRECOVERING (yystack->yyerrState != 0)
846 # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)
848 # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
850 # define YYBACKUP(Token, Value) \
851 return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
856 *yyvalp
= yyval_default
;
858 *yyvalp
= yyvsp
[YYFILL (1-yyrhslen
)].yystate
.yysemantics
.yysval
;
859 YYLLOC_DEFAULT (*yylocp
, yyvsp
- yyrhslen
, yyrhslen
);
860 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= *yylocp
;
876 /* Line __line__ of glr.c. */
877 b4_syncline([@oline@
], [@ofile@
])
882 yyuserMerge (int yyn
, YYSTYPE
* yy0
, YYSTYPE
* yy1
)
894 /* Bison grammar-table manipulation. */
896 ]b4_yydestruct_generate([b4_c_ansi_function_def
])[
898 /** Number of symbols composing the right hand side of rule #RULE. */
900 yyrhsLength (yyRuleNum yyrule
)
906 yydestroyGLRState (char const *yymsg
, yyGLRState
*yys
]b4_user_formals
[)
909 yydestruct (yymsg
, yystos
[yys
->yylrState
],
910 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[]b4_user_args
[);
916 YYFPRINTF (stderr
, "%s unresolved ", yymsg
);
917 yysymprint (stderr
, yystos
[yys
->yylrState
],
918 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[]b4_user_args
[);
919 YYFPRINTF (stderr
, "\n");
923 if (yys
->yysemantics
.yyfirstVal
)
925 yySemanticOption
*yyoption
= yys
->yysemantics
.yyfirstVal
;
928 for (yyrh
= yyoption
->yystate
, yyn
= yyrhsLength (yyoption
->yyrule
);
930 yyrh
= yyrh
->yypred
, yyn
-= 1)
931 yydestroyGLRState (yymsg
, yyrh
]b4_user_args
[);
936 /** Left-hand-side symbol for rule #RULE. */
937 static inline yySymbol
938 yylhsNonterm (yyRuleNum yyrule
)
943 #define yyis_pact_ninf(yystate) \
944 ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), 1,
946 ((yystate
) == YYPACT_NINF
))[
948 /** True iff LR state STATE has only a default reduction (regardless
951 yyisDefaultedState (yyStateNum yystate
)
953 return yyis_pact_ninf (yypact
[yystate
]);
956 /** The default reduction for STATE, assuming it has one. */
957 static inline yyRuleNum
958 yydefaultAction (yyStateNum yystate
)
960 return yydefact
[yystate
];
963 #define yyis_table_ninf(yytable_value) \
964 ]m4_if(m4_eval(b4_table_ninf < b4_table_min), 1,
966 ((yytable_value
) == YYTABLE_NINF
))[
968 /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
970 * R < 0: Reduce on rule -R.
972 * R > 0: Shift to state R.
973 * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
974 * conflicting reductions.
977 yygetLRActions (yyStateNum yystate
, int yytoken
,
978 int* yyaction
, const short int** yyconflicts
)
980 int yyindex
= yypact
[yystate
] + yytoken
;
981 if (yyindex
< 0 || YYLAST
< yyindex
|| yycheck
[yyindex
] != yytoken
)
983 *yyaction
= -yydefact
[yystate
];
984 *yyconflicts
= yyconfl
;
986 else if (! yyis_table_ninf (yytable
[yyindex
]))
988 *yyaction
= yytable
[yyindex
];
989 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
994 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
998 static inline yyStateNum
999 yyLRgotoState (yyStateNum yystate
, yySymbol yylhs
)
1002 yyr
= yypgoto
[yylhs
- YYNTOKENS
] + yystate
;
1003 if (0 <= yyr
&& yyr
<= YYLAST
&& yycheck
[yyr
] == yystate
)
1004 return yytable
[yyr
];
1006 return yydefgoto
[yylhs
- YYNTOKENS
];
1009 static inline yybool
1010 yyisShiftAction (int yyaction
)
1012 return 0 < yyaction
;
1015 static inline yybool
1016 yyisErrorAction (int yyaction
)
1018 return yyaction
== 0;
1024 yyaddDeferredAction (yyGLRStack
* yystack
, yyGLRState
* yystate
,
1025 yyGLRState
* rhs
, yyRuleNum yyrule
)
1027 yySemanticOption
* yynewItem
;
1028 yynewItem
= &yystack
->yynextFree
->yyoption
;
1029 yystack
->yyspaceLeft
-= 1;
1030 yystack
->yynextFree
+= 1;
1031 yynewItem
->yyisState
= yyfalse
;
1032 yynewItem
->yystate
= rhs
;
1033 yynewItem
->yyrule
= yyrule
;
1034 yynewItem
->yynext
= yystate
->yysemantics
.yyfirstVal
;
1035 yystate
->yysemantics
.yyfirstVal
= yynewItem
;
1036 if (yystack
->yyspaceLeft
< YYHEADROOM
)
1037 yyexpandGLRStack (yystack
);
1042 /** Initialize SET to a singleton set containing an empty stack. */
1044 yyinitStateSet (yyGLRStateSet
* yyset
)
1047 yyset
->yycapacity
= 16;
1048 yyset
->yystates
= (yyGLRState
**) YYMALLOC (16 * sizeof yyset
->yystates
[0]);
1049 if (! yyset
->yystates
)
1051 yyset
->yystates
[0] = NULL
;
1055 static void yyfreeStateSet (yyGLRStateSet
* yyset
)
1057 YYFREE (yyset
->yystates
);
1060 /** Initialize STACK to a single empty stack, with total maximum
1061 * capacity for all stacks of SIZE. */
1063 yyinitGLRStack (yyGLRStack
* yystack
, size_t yysize
)
1065 yystack
->yyerrState
= 0;
1067 yystack
->yyspaceLeft
= yysize
;
1069 (yyGLRStackItem
*) YYMALLOC (yysize
* sizeof yystack
->yynextFree
[0]);
1070 if (!yystack
->yyitems
)
1072 yystack
->yynextFree
= yystack
->yyitems
;
1073 yystack
->yysplitPoint
= NULL
;
1074 yystack
->yylastDeleted
= NULL
;
1075 return yyinitStateSet (&yystack
->yytops
);
1078 #define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
1079 &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
1081 /** If STACK is expandable, extend it. WARNING: Pointers into the
1082 stack from outside should be considered invalid after this call.
1083 We always expand when there are 1 or fewer items left AFTER an
1084 allocation, so that we can avoid having external pointers exist
1085 across an allocation. */
1087 yyexpandGLRStack (yyGLRStack
* yystack
)
1089 #if YYSTACKEXPANDABLE
1090 yyGLRStackItem
* yynewItems
;
1091 yyGLRStackItem
* yyp0
, *yyp1
;
1092 size_t yysize
, yynewSize
;
1094 yysize
= yystack
->yynextFree
- yystack
->yyitems
;
1095 if (YYMAXDEPTH
<= yysize
)
1096 yyMemoryExhausted (yystack
);
1097 yynewSize
= 2*yysize
;
1098 if (YYMAXDEPTH
< yynewSize
)
1099 yynewSize
= YYMAXDEPTH
;
1100 yynewItems
= (yyGLRStackItem
*) YYMALLOC (yynewSize
* sizeof yynewItems
[0]);
1102 yyMemoryExhausted (yystack
);
1103 for (yyp0
= yystack
->yyitems
, yyp1
= yynewItems
, yyn
= yysize
;
1105 yyn
-= 1, yyp0
+= 1, yyp1
+= 1)
1108 if (*(yybool
*) yyp0
)
1110 yyGLRState
* yys0
= &yyp0
->yystate
;
1111 yyGLRState
* yys1
= &yyp1
->yystate
;
1112 if (yys0
->yypred
!= NULL
)
1114 YYRELOC (yyp0
, yyp1
, yys0
->yypred
, yystate
);
1115 if (! yys0
->yyresolved
&& yys0
->yysemantics
.yyfirstVal
!= NULL
)
1116 yys1
->yysemantics
.yyfirstVal
=
1117 YYRELOC(yyp0
, yyp1
, yys0
->yysemantics
.yyfirstVal
, yyoption
);
1121 yySemanticOption
* yyv0
= &yyp0
->yyoption
;
1122 yySemanticOption
* yyv1
= &yyp1
->yyoption
;
1123 if (yyv0
->yystate
!= NULL
)
1124 yyv1
->yystate
= YYRELOC (yyp0
, yyp1
, yyv0
->yystate
, yystate
);
1125 if (yyv0
->yynext
!= NULL
)
1126 yyv1
->yynext
= YYRELOC (yyp0
, yyp1
, yyv0
->yynext
, yyoption
);
1129 if (yystack
->yysplitPoint
!= NULL
)
1130 yystack
->yysplitPoint
= YYRELOC (yystack
->yyitems
, yynewItems
,
1131 yystack
->yysplitPoint
, yystate
);
1133 for (yyn
= 0; yyn
< yystack
->yytops
.yysize
; yyn
+= 1)
1134 if (yystack
->yytops
.yystates
[yyn
] != NULL
)
1135 yystack
->yytops
.yystates
[yyn
] =
1136 YYRELOC (yystack
->yyitems
, yynewItems
,
1137 yystack
->yytops
.yystates
[yyn
], yystate
);
1138 YYFREE (yystack
->yyitems
);
1139 yystack
->yyitems
= yynewItems
;
1140 yystack
->yynextFree
= yynewItems
+ yysize
;
1141 yystack
->yyspaceLeft
= yynewSize
- yysize
;
1144 yyMemoryExhausted (yystack
);
1149 yyfreeGLRStack (yyGLRStack
* yystack
)
1151 YYFREE (yystack
->yyitems
);
1152 yyfreeStateSet (&yystack
->yytops
);
1155 /** Assuming that S is a GLRState somewhere on STACK, update the
1156 * splitpoint of STACK, if needed, so that it is at least as deep as
1159 yyupdateSplit (yyGLRStack
* yystack
, yyGLRState
* yys
)
1161 if (yystack
->yysplitPoint
!= NULL
&& yystack
->yysplitPoint
> yys
)
1162 yystack
->yysplitPoint
= yys
;
1165 /** Invalidate stack #K in STACK. */
1167 yymarkStackDeleted (yyGLRStack
* yystack
, size_t yyk
)
1169 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1170 yystack
->yylastDeleted
= yystack
->yytops
.yystates
[yyk
];
1171 yystack
->yytops
.yystates
[yyk
] = NULL
;
1174 /** Undelete the last stack that was marked as deleted. Can only be
1175 done once after a deletion, and only when all other stacks have
1178 yyundeleteLastStack (yyGLRStack
* yystack
)
1180 if (yystack
->yylastDeleted
== NULL
|| yystack
->yytops
.yysize
!= 0)
1182 yystack
->yytops
.yystates
[0] = yystack
->yylastDeleted
;
1183 yystack
->yytops
.yysize
= 1;
1184 YYDPRINTF ((stderr
, "Restoring last deleted stack as stack #0.\n"));
1185 yystack
->yylastDeleted
= NULL
;
1189 yyremoveDeletes (yyGLRStack
* yystack
)
1193 while (yyj
< yystack
->yytops
.yysize
)
1195 if (yystack
->yytops
.yystates
[yyi
] == NULL
)
1199 YYDPRINTF ((stderr
, "Removing dead stacks.\n"));
1201 yystack
->yytops
.yysize
-= 1;
1205 yystack
->yytops
.yystates
[yyj
] = yystack
->yytops
.yystates
[yyi
];
1208 YYDPRINTF ((stderr
, "Rename stack %lu -> %lu.\n",
1209 (unsigned long int) yyi
, (unsigned long int) yyj
));
1217 /** Shift to a new state on stack #K of STACK, corresponding to LR state
1218 * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
1220 yyglrShift (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1222 YYSTYPE yysval
, YYLTYPE
* yylocp
)
1224 yyGLRStackItem
* yynewItem
;
1226 yynewItem
= yystack
->yynextFree
;
1227 yystack
->yynextFree
+= 1;
1228 yystack
->yyspaceLeft
-= 1;
1229 yynewItem
->yystate
.yyisState
= yytrue
;
1230 yynewItem
->yystate
.yylrState
= yylrState
;
1231 yynewItem
->yystate
.yyposn
= yyposn
;
1232 yynewItem
->yystate
.yyresolved
= yytrue
;
1233 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1234 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1235 yynewItem
->yystate
.yysemantics
.yysval
= yysval
;
1236 yynewItem
->yystate
.yyloc
= *yylocp
;
1237 if (yystack
->yyspaceLeft
< YYHEADROOM
)
1238 yyexpandGLRStack (yystack
);
1241 /** Shift stack #K of YYSTACK, to a new state corresponding to LR
1242 * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
1243 * semantic value of YYRHS under the action for YYRULE. */
1245 yyglrShiftDefer (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1246 size_t yyposn
, yyGLRState
* rhs
, yyRuleNum yyrule
)
1248 yyGLRStackItem
* yynewItem
;
1250 yynewItem
= yystack
->yynextFree
;
1251 yynewItem
->yystate
.yyisState
= yytrue
;
1252 yynewItem
->yystate
.yylrState
= yylrState
;
1253 yynewItem
->yystate
.yyposn
= yyposn
;
1254 yynewItem
->yystate
.yyresolved
= yyfalse
;
1255 yynewItem
->yystate
.yypred
= yystack
->yytops
.yystates
[yyk
];
1256 yynewItem
->yystate
.yysemantics
.yyfirstVal
= NULL
;
1257 yystack
->yytops
.yystates
[yyk
] = &yynewItem
->yystate
;
1258 yystack
->yynextFree
+= 1;
1259 yystack
->yyspaceLeft
-= 1;
1260 yyaddDeferredAction (yystack
, &yynewItem
->yystate
, rhs
, yyrule
);
1263 /** Pop the symbols consumed by reduction #RULE from the top of stack
1264 * #K of STACK, and perform the appropriate semantic action on their
1265 * semantic values. Assumes that all ambiguities in semantic values
1266 * have been previously resolved. Set *VALP to the resulting value,
1267 * and *LOCP to the computed location (if any). Return value is as
1268 * for userAction. */
1269 static inline YYRESULTTAG
1270 yydoAction (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1271 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1273 int yynrhs
= yyrhsLength (yyrule
);
1275 if (yystack
->yysplitPoint
== NULL
)
1277 /* Standard special case: single stack. */
1278 yyGLRStackItem
* rhs
= (yyGLRStackItem
*) yystack
->yytops
.yystates
[yyk
];
1279 YYASSERT (yyk
== 0);
1280 yystack
->yynextFree
-= yynrhs
;
1281 yystack
->yyspaceLeft
+= yynrhs
;
1282 yystack
->yytops
.yystates
[0] = & yystack
->yynextFree
[-1].yystate
;
1283 return yyuserAction (yyrule
, yynrhs
, rhs
,
1284 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1288 /* At present, doAction is never called in nondeterministic
1289 * mode, so this branch is never taken. It is here in
1290 * anticipation of a future feature that will allow immediate
1291 * evaluation of selected actions in nondeterministic mode. */
1294 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1295 yys
= yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
1296 = yystack
->yytops
.yystates
[yyk
];]b4_location_if([[
1298 /* Set default location. */
1299 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
- 1].yystate
.yyloc
= yys
->yyloc
;]])[
1300 for (yyi
= 0; yyi
< yynrhs
; yyi
+= 1)
1305 yyupdateSplit (yystack
, yys
);
1306 yystack
->yytops
.yystates
[yyk
] = yys
;
1307 return yyuserAction (yyrule
, yynrhs
, yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1308 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1313 # define YY_REDUCE_PRINT(K, Rule)
1315 # define YY_REDUCE_PRINT(K, Rule) \
1318 yy_reduce_print (K, Rule); \
1319 } while (/*CONSTCOND*/ 0)
1321 /*----------------------------------------------------------.
1322 | Report that the RULE is going to be reduced on stack #K. |
1323 `----------------------------------------------------------*/
1326 yy_reduce_print (size_t yyk
, yyRuleNum yyrule
)
1329 YYFPRINTF (stderr
, "Reducing stack %lu by rule %d (line %lu), ",
1330 (unsigned long int) yyk
, yyrule
- 1,
1331 (unsigned long int) yyrline
[yyrule
]);
1332 /* Print the symbols being reduced, and their result. */
1333 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
1334 YYFPRINTF (stderr
, "%s ", yytokenName (yyrhs
[yyi
]));
1335 YYFPRINTF (stderr
, "-> %s\n", yytokenName (yyr1
[yyrule
]));
1339 /** Pop items off stack #K of STACK according to grammar rule RULE,
1340 * and push back on the resulting nonterminal symbol. Perform the
1341 * semantic action associated with RULE and store its value with the
1342 * newly pushed state, if FORCEEVAL or if STACK is currently
1343 * unambiguous. Otherwise, store the deferred semantic action with
1344 * the new state. If the new state would have an identical input
1345 * position, LR state, and predecessor to an existing state on the stack,
1346 * it is identified with that existing state, eliminating stack #K from
1347 * the STACK. In this case, the (necessarily deferred) semantic value is
1348 * added to the options for the existing state's semantic value.
1350 static inline YYRESULTTAG
1351 yyglrReduce (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1352 yybool yyforceEval
]b4_user_formals
[)
1354 size_t yyposn
= yystack
->yytops
.yystates
[yyk
]->yyposn
;
1356 if (yyforceEval
|| yystack
->yysplitPoint
== NULL
)
1361 YY_REDUCE_PRINT (yyk
, yyrule
);
1362 YYCHK (yydoAction (yystack
, yyk
, yyrule
, &yysval
, &yyloc
]b4_user_args
[));
1363 yyglrShift (yystack
, yyk
,
1364 yyLRgotoState (yystack
->yytops
.yystates
[yyk
]->yylrState
,
1365 yylhsNonterm (yyrule
)),
1366 yyposn
, yysval
, &yyloc
);
1372 yyGLRState
* yys
, *yys0
= yystack
->yytops
.yystates
[yyk
];
1373 yyStateNum yynewLRState
;
1375 for (yys
= yystack
->yytops
.yystates
[yyk
], yyn
= yyrhsLength (yyrule
);
1381 yyupdateSplit (yystack
, yys
);
1382 yynewLRState
= yyLRgotoState (yys
->yylrState
, yylhsNonterm (yyrule
));
1384 "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
1385 (unsigned long int) yyk
, yyrule
- 1, yynewLRState
));
1386 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
1387 if (yyi
!= yyk
&& yystack
->yytops
.yystates
[yyi
] != NULL
)
1389 yyGLRState
* yyp
, *yysplit
= yystack
->yysplitPoint
;
1390 yyp
= yystack
->yytops
.yystates
[yyi
];
1391 while (yyp
!= yys
&& yyp
!= yysplit
&& yyp
->yyposn
>= yyposn
)
1393 if (yyp
->yylrState
== yynewLRState
&& yyp
->yypred
== yys
)
1395 yyaddDeferredAction (yystack
, yyp
, yys0
, yyrule
);
1396 yymarkStackDeleted (yystack
, yyk
);
1397 YYDPRINTF ((stderr
, "Merging stack %lu into stack %lu.\n",
1398 (unsigned long int) yyk
,
1399 (unsigned long int) yyi
));
1405 yystack
->yytops
.yystates
[yyk
] = yys
;
1406 yyglrShiftDefer (yystack
, yyk
, yynewLRState
, yyposn
, yys0
, yyrule
);
1412 yysplitStack (yyGLRStack
* yystack
, size_t yyk
)
1414 if (yystack
->yysplitPoint
== NULL
)
1416 YYASSERT (yyk
== 0);
1417 yystack
->yysplitPoint
= yystack
->yytops
.yystates
[yyk
];
1419 if (yystack
->yytops
.yysize
>= yystack
->yytops
.yycapacity
)
1421 yyGLRState
** yynewStates
;
1422 if (! ((yystack
->yytops
.yycapacity
1423 <= (YYSIZEMAX
/ (2 * sizeof yynewStates
[0])))
1425 (yyGLRState
**) YYREALLOC (yystack
->yytops
.yystates
,
1426 ((yystack
->yytops
.yycapacity
*= 2)
1427 * sizeof yynewStates
[0])))))
1428 yyMemoryExhausted (yystack
);
1429 yystack
->yytops
.yystates
= yynewStates
;
1431 yystack
->yytops
.yystates
[yystack
->yytops
.yysize
]
1432 = yystack
->yytops
.yystates
[yyk
];
1433 yystack
->yytops
.yysize
+= 1;
1434 return yystack
->yytops
.yysize
-1;
1437 /** True iff Y0 and Y1 represent identical options at the top level.
1438 * That is, they represent the same rule applied to RHS symbols
1439 * that produce the same terminal symbols. */
1441 yyidenticalOptions (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1443 if (yyy0
->yyrule
== yyy1
->yyrule
)
1445 yyGLRState
*yys0
, *yys1
;
1447 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1448 yyn
= yyrhsLength (yyy0
->yyrule
);
1450 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1451 if (yys0
->yyposn
!= yys1
->yyposn
)
1459 /** Assuming identicalOptions (Y0,Y1), destructively merge the
1460 * alternative semantic values for the RHS-symbols of Y1 and Y0. */
1462 yymergeOptionSets (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1464 yyGLRState
*yys0
, *yys1
;
1466 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1467 yyn
= yyrhsLength (yyy0
->yyrule
);
1469 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1473 else if (yys0
->yyresolved
)
1475 yys1
->yyresolved
= yytrue
;
1476 yys1
->yysemantics
.yysval
= yys0
->yysemantics
.yysval
;
1478 else if (yys1
->yyresolved
)
1480 yys0
->yyresolved
= yytrue
;
1481 yys0
->yysemantics
.yysval
= yys1
->yysemantics
.yysval
;
1485 yySemanticOption
** yyz0p
;
1486 yySemanticOption
* yyz1
;
1487 yyz0p
= &yys0
->yysemantics
.yyfirstVal
;
1488 yyz1
= yys1
->yysemantics
.yyfirstVal
;
1491 if (yyz1
== *yyz0p
|| yyz1
== NULL
)
1493 else if (*yyz0p
== NULL
)
1498 else if (*yyz0p
< yyz1
)
1500 yySemanticOption
* yyz
= *yyz0p
;
1502 yyz1
= yyz1
->yynext
;
1503 (*yyz0p
)->yynext
= yyz
;
1505 yyz0p
= &(*yyz0p
)->yynext
;
1507 yys1
->yysemantics
.yyfirstVal
= yys0
->yysemantics
.yyfirstVal
;
1512 /** Y0 and Y1 represent two possible actions to take in a given
1513 * parsing state; return 0 if no combination is possible,
1514 * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
1516 yypreference (yySemanticOption
* y0
, yySemanticOption
* y1
)
1518 yyRuleNum r0
= y0
->yyrule
, r1
= y1
->yyrule
;
1519 int p0
= yydprec
[r0
], p1
= yydprec
[r1
];
1523 if (yymerger
[r0
] == 0 || yymerger
[r0
] != yymerger
[r1
])
1528 if (p0
== 0 || p1
== 0)
1537 static YYRESULTTAG
yyresolveValue (yySemanticOption
* yyoptionList
,
1538 yyGLRStack
* yystack
, YYSTYPE
* yyvalp
,
1539 YYLTYPE
* yylocp
]b4_user_formals
[);
1542 yyresolveStates (yyGLRState
* yys
, int yyn
, yyGLRStack
* yystack
]b4_user_formals
[)
1547 YYASSERT (yys
->yypred
);
1548 yyflag
= yyresolveStates (yys
->yypred
, yyn
-1, yystack
]b4_user_args
[);
1551 if (! yys
->yyresolved
)
1553 yyflag
= yyresolveValue (yys
->yysemantics
.yyfirstVal
, yystack
,
1554 &yys
->yysemantics
.yysval
, &yys
->yyloc
1558 yys
->yyresolved
= yytrue
;
1565 yyresolveAction (yySemanticOption
* yyopt
, yyGLRStack
* yystack
,
1566 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1568 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1571 yynrhs
= yyrhsLength (yyopt
->yyrule
);
1572 YYCHK (yyresolveStates (yyopt
->yystate
, yynrhs
, yystack
]b4_user_args
[));
1573 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
= yyopt
->yystate
;]b4_location_if([[
1575 /* Set default location. */
1576 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
- 1].yystate
.yyloc
= yyopt
->yystate
->yyloc
;]])[
1577 return yyuserAction (yyopt
->yyrule
, yynrhs
,
1578 yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1579 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1584 yyreportTree (yySemanticOption
* yyx
, int yyindent
)
1586 int yynrhs
= yyrhsLength (yyx
->yyrule
);
1589 yyGLRState
* yystates
[YYMAXRHS
];
1590 yyGLRState yyleftmost_state
;
1592 for (yyi
= yynrhs
, yys
= yyx
->yystate
; 0 < yyi
; yyi
-= 1, yys
= yys
->yypred
)
1593 yystates
[yyi
] = yys
;
1596 yyleftmost_state
.yyposn
= 0;
1597 yystates
[0] = &yyleftmost_state
;
1602 if (yyx
->yystate
->yyposn
< yys
->yyposn
+ 1)
1603 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, empty>\n",
1604 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1607 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
1608 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1609 yyx
->yyrule
, (unsigned long int) (yys
->yyposn
+ 1),
1610 (unsigned long int) yyx
->yystate
->yyposn
);
1611 for (yyi
= 1; yyi
<= yynrhs
; yyi
+= 1)
1613 if (yystates
[yyi
]->yyresolved
)
1615 if (yystates
[yyi
-1]->yyposn
+1 > yystates
[yyi
]->yyposn
)
1616 YYFPRINTF (stderr
, "%*s%s <empty>\n", yyindent
+2, "",
1617 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]));
1619 YYFPRINTF (stderr
, "%*s%s <tokens %lu .. %lu>\n", yyindent
+2, "",
1620 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]),
1621 (unsigned long int) (yystates
[yyi
- 1]->yyposn
+ 1),
1622 (unsigned long int) yystates
[yyi
]->yyposn
);
1625 yyreportTree (yystates
[yyi
]->yysemantics
.yyfirstVal
, yyindent
+2);
1630 static void yyreportAmbiguity (yySemanticOption
* yyx0
, yySemanticOption
* yyx1
,
1631 yyGLRStack
* yystack
]b4_pure_formals
[)
1632 __attribute__ ((__noreturn__
));
1634 yyreportAmbiguity (yySemanticOption
* yyx0
, yySemanticOption
* yyx1
,
1635 yyGLRStack
* yystack
]b4_pure_formals
[)
1641 YYFPRINTF (stderr
, "Ambiguity detected.\n");
1642 YYFPRINTF (stderr
, "Option 1,\n");
1643 yyreportTree (yyx0
, 2);
1644 YYFPRINTF (stderr
, "\nOption 2,\n");
1645 yyreportTree (yyx1
, 2);
1646 YYFPRINTF (stderr
, "\n");
1648 yyFail (yystack
][]b4_pure_args
[, YY_("syntax is ambiguous"));
1652 /** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
1653 * actions, and return the result. */
1655 yyresolveValue (yySemanticOption
* yyoptionList
, yyGLRStack
* yystack
,
1656 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1658 yySemanticOption
* yybest
;
1659 yySemanticOption
** yypp
;
1662 yybest
= yyoptionList
;
1664 for (yypp
= &yyoptionList
->yynext
; *yypp
!= NULL
; )
1666 yySemanticOption
* yyp
= *yypp
;
1668 if (yyidenticalOptions (yybest
, yyp
))
1670 yymergeOptionSets (yybest
, yyp
);
1671 *yypp
= yyp
->yynext
;
1675 switch (yypreference (yybest
, yyp
))
1678 yyreportAmbiguity (yybest
, yyp
, yystack
]b4_pure_args
[);
1690 /* This cannot happen so it is not worth a YYASSERT (yyfalse),
1691 but some compilers complain if the default case is
1695 yypp
= &yyp
->yynext
;
1701 yySemanticOption
* yyp
;
1702 int yyprec
= yydprec
[yybest
->yyrule
];
1703 YYCHK (yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[));
1704 for (yyp
= yybest
->yynext
; yyp
!= NULL
; yyp
= yyp
->yynext
)
1706 if (yyprec
== yydprec
[yyp
->yyrule
])
1710 YYCHK (yyresolveAction (yyp
, yystack
, &yyval1
, &yydummy
]b4_user_args
[));
1711 yyuserMerge (yymerger
[yyp
->yyrule
], yyvalp
, &yyval1
);
1717 return yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[);
1721 yyresolveStack (yyGLRStack
* yystack
]b4_user_formals
[)
1723 if (yystack
->yysplitPoint
!= NULL
)
1728 for (yyn
= 0, yys
= yystack
->yytops
.yystates
[0];
1729 yys
!= yystack
->yysplitPoint
;
1730 yys
= yys
->yypred
, yyn
+= 1)
1732 YYCHK (yyresolveStates (yystack
->yytops
.yystates
[0], yyn
, yystack
1739 yycompressStack (yyGLRStack
* yystack
)
1741 yyGLRState
* yyp
, *yyq
, *yyr
;
1743 if (yystack
->yytops
.yysize
!= 1 || yystack
->yysplitPoint
== NULL
)
1746 for (yyp
= yystack
->yytops
.yystates
[0], yyq
= yyp
->yypred
, yyr
= NULL
;
1747 yyp
!= yystack
->yysplitPoint
;
1748 yyr
= yyp
, yyp
= yyq
, yyq
= yyp
->yypred
)
1751 yystack
->yyspaceLeft
+= yystack
->yynextFree
- yystack
->yyitems
;
1752 yystack
->yynextFree
= ((yyGLRStackItem
*) yystack
->yysplitPoint
) + 1;
1753 yystack
->yyspaceLeft
-= yystack
->yynextFree
- yystack
->yyitems
;
1754 yystack
->yysplitPoint
= NULL
;
1755 yystack
->yylastDeleted
= NULL
;
1759 yystack
->yynextFree
->yystate
= *yyr
;
1761 yystack
->yynextFree
->yystate
.yypred
= & yystack
->yynextFree
[-1].yystate
;
1762 yystack
->yytops
.yystates
[0] = &yystack
->yynextFree
->yystate
;
1763 yystack
->yynextFree
+= 1;
1764 yystack
->yyspaceLeft
-= 1;
1769 yyprocessOneStack (yyGLRStack
* yystack
, size_t yyk
,
1770 size_t yyposn
, YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
1774 const short int* yyconflicts
;
1776 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1778 while (yystack
->yytops
.yystates
[yyk
] != NULL
)
1780 yyStateNum yystate
= yystack
->yytops
.yystates
[yyk
]->yylrState
;
1781 YYDPRINTF ((stderr
, "Stack %lu Entering state %d\n",
1782 (unsigned long int) yyk
, yystate
));
1784 YYASSERT (yystate
!= YYFINAL
);
1786 if (yyisDefaultedState (yystate
))
1788 yyrule
= yydefaultAction (yystate
);
1791 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1792 (unsigned long int) yyk
));
1793 yymarkStackDeleted (yystack
, yyk
);
1796 YYCHK (yyglrReduce (yystack
, yyk
, yyrule
, yyfalse
]b4_user_args
[));
1800 if (*yytokenp
== YYEMPTY
)
1802 YYDPRINTF ((stderr
, "Reading a token: "));
1804 *yytokenp
= YYTRANSLATE (yychar
);
1805 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1807 yygetLRActions (yystate
, *yytokenp
, &yyaction
, &yyconflicts
);
1809 while (*yyconflicts
!= 0)
1811 size_t yynewStack
= yysplitStack (yystack
, yyk
);
1812 YYDPRINTF ((stderr
, "Splitting off stack %lu from %lu.\n",
1813 (unsigned long int) yynewStack
,
1814 (unsigned long int) yyk
));
1815 YYCHK (yyglrReduce (yystack
, yynewStack
,
1816 *yyconflicts
, yyfalse
]b4_user_args
[));
1817 YYCHK (yyprocessOneStack (yystack
, yynewStack
, yyposn
,
1818 yylvalp
, yyllocp
]b4_pure_args
[));
1822 if (yyisShiftAction (yyaction
))
1824 YYDPRINTF ((stderr
, "On stack %lu, ", (unsigned long int) yyk
));
1825 YY_SYMBOL_PRINT ("shifting", *yytokenp
, yylvalp
, yyllocp
);
1826 yyglrShift (yystack
, yyk
, yyaction
, yyposn
+1,
1828 YYDPRINTF ((stderr
, "Stack %lu now in state #%d\n",
1829 (unsigned long int) yyk
,
1830 yystack
->yytops
.yystates
[yyk
]->yylrState
));
1833 else if (yyisErrorAction (yyaction
))
1835 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1836 (unsigned long int) yyk
));
1837 yymarkStackDeleted (yystack
, yyk
);
1841 YYCHK (yyglrReduce (yystack
, yyk
, -yyaction
, yyfalse
]b4_user_args
[));
1848 yyreportSyntaxError (yyGLRStack
* yystack
,
1849 YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
]b4_user_formals
[)
1854 if (yystack
->yyerrState
== 0)
1857 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1859 yyn
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1860 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1862 size_t yysize0
= yytnamerr (NULL
, yytokenName (*yytokenp
));
1863 size_t yysize
= yysize0
;
1865 yybool yysize_overflow
= yyfalse
;
1867 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1868 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1872 static char const yyunexpected
[] = "syntax error, unexpected %s";
1873 static char const yyexpecting
[] = ", expecting %s";
1874 static char const yyor
[] = " or %s";
1875 char yyformat
[sizeof yyunexpected
1876 + sizeof yyexpecting
- 1
1877 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1878 * (sizeof yyor
- 1))];
1879 char const *yyprefix
= yyexpecting
;
1881 /* Start YYX at -YYN if negative to avoid negative indexes in
1883 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1885 /* Stay within bounds of both yycheck and yytname. */
1886 int yychecklim
= YYLAST
- yyn
;
1887 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1890 yyarg
[0] = yytokenName (*yytokenp
);
1891 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1893 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1894 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1896 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1900 yyformat
[sizeof yyunexpected
- 1] = '\0';
1903 yyarg
[yycount
++] = yytokenName (yyx
);
1904 yysize1
= yysize
+ yytnamerr (NULL
, yytokenName (yyx
));
1905 yysize_overflow
|= yysize1
< yysize
;
1907 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1911 yyf
= YY_(yyformat
);
1912 yysize1
= yysize
+ strlen (yyf
);
1913 yysize_overflow
|= yysize1
< yysize
;
1916 if (!yysize_overflow
)
1917 yymsg
= (char *) YYMALLOC (yysize
);
1923 while ((*yyp
= *yyf
))
1925 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1927 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1936 yyerror (]b4_lyyerror_args
[yymsg
);
1941 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1942 yyMemoryExhausted (yystack
);
1946 #endif /* YYERROR_VERBOSE */
1947 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1952 /* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
1953 YYLVALP, and YYLLOCP point to the syntactic category, semantic
1954 value, and location of the look-ahead. */
1956 yyrecoverSyntaxError (yyGLRStack
* yystack
,
1958 YYLTYPE
* YYOPTIONAL_LOC (yyllocp
)
1961 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1965 if (yystack
->yyerrState
== 3)
1966 /* We just shifted the error token and (perhaps) took some
1967 reductions. Skip tokens until we can proceed. */
1970 if (*yytokenp
== YYEOF
)
1971 yyFail (yystack
][]b4_lpure_args
[, NULL
);
1972 if (*yytokenp
!= YYEMPTY
)
1974 /* We throw away the lookahead, but the error range
1975 of the shifted error token must take it into account. */
1976 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
1977 yyGLRStackItem yyerror_range
[3];
1978 yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;
1979 yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
1980 YYLLOC_DEFAULT (yys
->yyloc
, yyerror_range
, 2);]])[
1981 yydestruct ("Error: discarding",
1982 *yytokenp
, yylvalp
]b4_location_if([, yyllocp
])[]b4_user_args
[);
1984 YYDPRINTF ((stderr
, "Reading a token: "));
1986 *yytokenp
= YYTRANSLATE (yychar
);
1987 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1988 yyj
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1989 if (yyis_pact_ninf (yyj
))
1992 if (yyj
< 0 || YYLAST
< yyj
|| yycheck
[yyj
] != *yytokenp
)
1994 if (yydefact
[yystack
->yytops
.yystates
[0]->yylrState
] != 0)
1997 else if (yytable
[yyj
] != 0 && ! yyis_table_ninf (yytable
[yyj
]))
2001 /* Reduce to one stack. */
2002 for (yyk
= 0; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
2003 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
2005 if (yyk
>= yystack
->yytops
.yysize
)
2006 yyFail (yystack
][]b4_lpure_args
[, NULL
);
2007 for (yyk
+= 1; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
2008 yymarkStackDeleted (yystack
, yyk
);
2009 yyremoveDeletes (yystack
);
2010 yycompressStack (yystack
);
2012 /* Now pop stack until we find a state that shifts the error token. */
2013 yystack
->yyerrState
= 3;
2014 while (yystack
->yytops
.yystates
[0] != NULL
)
2016 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
2017 yyj
= yypact
[yys
->yylrState
];
2018 if (! yyis_pact_ninf (yyj
))
2021 if (0 <= yyj
&& yyj
<= YYLAST
&& yycheck
[yyj
] == YYTERROR
2022 && yyisShiftAction (yytable
[yyj
]))
2024 /* Shift the error token having adjusted its location. */
2025 YYLTYPE yyerrloc
;]b4_location_if([[
2026 yystack
->yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
2027 YYLLOC_DEFAULT (yyerrloc
, yystack
->yyerror_range
, 2);]])[
2028 YY_SYMBOL_PRINT ("Shifting", yystos
[yytable
[yyj
]],
2029 yylvalp
, &yyerrloc
);
2030 yyglrShift (yystack
, 0, yytable
[yyj
],
2031 yys
->yyposn
, *yylvalp
, &yyerrloc
);
2032 yys
= yystack
->yytops
.yystates
[0];
2036 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]])[
2037 yydestroyGLRState ("Error: popping", yys
]b4_user_args
[);
2038 yystack
->yytops
.yystates
[0] = yys
->yypred
;
2039 yystack
->yynextFree
-= 1;
2040 yystack
->yyspaceLeft
+= 1;
2042 if (yystack
->yytops
.yystates
[0] == NULL
)
2043 yyFail (yystack
][]b4_lpure_args
[, NULL
);
2046 #define YYCHK1(YYE) \
2056 goto yyuser_error; \
2060 } while (/*CONSTCOND*/ 0)
2067 ]b4_c_ansi_function_def([yyparse
], [int], b4_parse_param
)[
2078 #define yychar (yystack.yyrawchar)
2081 YYSTYPE
* const yylvalp
= &yylval
;
2082 YYLTYPE
* const yyllocp
= &yylloc
;
2084 YYDPRINTF ((stderr
, "Starting parse\n"));
2087 yylval
= yyval_default
;
2089 #if YYLTYPE_IS_TRIVIAL
2090 yylloc
.first_line
= yylloc
.last_line
= 1;
2091 yylloc
.first_column
= yylloc
.last_column
= 0;
2094 m4_ifdef([b4_initial_action
], [
2095 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
2096 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
2097 /* User initialization code. */
2099 m4_popdef([b4_dollar_dollar
])dnl
2100 m4_popdef([b4_at_dollar
])dnl
2101 /* Line __line__ of glr.c. */
2102 b4_syncline([@oline@
], [@ofile@
])])dnl
2104 if (! yyinitGLRStack (&yystack
, YYINITDEPTH
))
2105 goto yyexhaustedlab
;
2106 switch (YYSETJMP (yystack
.yyexception_buffer
))
2109 case 1: goto yyabortlab
;
2110 case 2: goto yyexhaustedlab
;
2111 default: goto yybuglab
;
2113 yystack
.yytokenp
= &yytoken
;
2114 yyglrShift (&yystack
, 0, 0, 0, yylval
, &yylloc
);
2119 /* For efficiency, we have two loops, the first of which is
2120 specialized to deterministic operation (single stack, no
2121 potential ambiguity). */
2127 const short int* yyconflicts
;
2129 yyStateNum yystate
= yystack
.yytops
.yystates
[0]->yylrState
;
2130 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
2131 if (yystate
== YYFINAL
)
2133 if (yyisDefaultedState (yystate
))
2135 yyrule
= yydefaultAction (yystate
);
2138 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2139 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2142 YYCHK1 (yyglrReduce (&yystack
, 0, yyrule
, yytrue
]b4_user_args
[));
2146 if (yytoken
== YYEMPTY
)
2148 YYDPRINTF ((stderr
, "Reading a token: "));
2150 yytoken
= YYTRANSLATE (yychar
);
2151 YY_SYMBOL_PRINT ("Next token is", yytoken
, yylvalp
, yyllocp
);
2153 yygetLRActions (yystate
, yytoken
, &yyaction
, &yyconflicts
);
2154 if (*yyconflicts
!= 0)
2156 if (yyisShiftAction (yyaction
))
2158 YY_SYMBOL_PRINT ("Shifting", yytoken
, yylvalp
, yyllocp
);
2159 if (yytoken
!= YYEOF
)
2162 yyglrShift (&yystack
, 0, yyaction
, yyposn
, yylval
, yyllocp
);
2163 if (0 < yystack
.yyerrState
)
2164 yystack
.yyerrState
-= 1;
2166 else if (yyisErrorAction (yyaction
))
2168 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2169 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2173 YYCHK1 (yyglrReduce (&yystack
, 0, -yyaction
, yytrue
]b4_user_args
[));
2180 size_t yyn
= yystack
.yytops
.yysize
;
2181 for (yys
= 0; yys
< yyn
; yys
+= 1)
2182 YYCHK1 (yyprocessOneStack (&yystack
, yys
, yyposn
,
2183 yylvalp
, yyllocp
]b4_lpure_args
[));
2186 yyremoveDeletes (&yystack
);
2187 if (yystack
.yytops
.yysize
== 0)
2189 yyundeleteLastStack (&yystack
);
2190 if (yystack
.yytops
.yysize
== 0)
2191 yyFail (&yystack
][]b4_lpure_args
[, YY_("syntax error"));
2192 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2193 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2194 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2195 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2198 else if (yystack
.yytops
.yysize
== 1)
2200 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2201 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2202 yycompressStack (&yystack
);
2208 yyrecoverSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2209 yyposn
= yystack
.yytops
.yystates
[0]->yyposn
;
2225 yyerror (]b4_lyyerror_args
[YY_("memory exhausted"));
2230 if (yytoken
!= YYEOF
&& yytoken
!= YYEMPTY
)
2231 yydestruct ("Cleanup: discarding lookahead",
2232 yytoken
, yylvalp
]b4_location_if([, yyllocp
])[]b4_user_args
[);
2234 /* If the stack is well-formed, pop the stack until it is empty,
2235 destroying its entries as we go. But free the stack regardless
2236 of whether it is well-formed. */
2237 if (yystack
.yyitems
)
2239 yyGLRState
** yystates
= yystack
.yytops
.yystates
;
2243 yyGLRState
*yys
= yystates
[0];
2244 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]]
2245 )[ yydestroyGLRState ("Cleanup: popping", yys
]b4_user_args
[);
2246 yystates
[0] = yys
->yypred
;
2247 yystack
.yynextFree
-= 1;
2248 yystack
.yyspaceLeft
+= 1;
2250 yyfreeGLRStack (&yystack
);
2256 /* DEBUGGING ONLY */
2258 static void yypstack (yyGLRStack
* yystack
, size_t yyk
)
2259 __attribute__ ((__unused__
));
2260 static void yypdumpstack (yyGLRStack
* yystack
) __attribute__ ((__unused__
));
2263 yy_yypstack (yyGLRState
* yys
)
2267 yy_yypstack (yys
->yypred
);
2268 fprintf (stderr
, " -> ");
2270 fprintf (stderr
, "%d@@%lu", yys
->yylrState
, (unsigned long int) yys
->yyposn
);
2274 yypstates (yyGLRState
* yyst
)
2277 fprintf (stderr
, "<null>");
2280 fprintf (stderr
, "\n");
2284 yypstack (yyGLRStack
* yystack
, size_t yyk
)
2286 yypstates (yystack
->yytops
.yystates
[yyk
]);
2289 #define YYINDEX(YYX) \
2290 ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
2294 yypdumpstack (yyGLRStack
* yystack
)
2296 yyGLRStackItem
* yyp
;
2298 for (yyp
= yystack
->yyitems
; yyp
< yystack
->yynextFree
; yyp
+= 1)
2300 fprintf (stderr
, "%3lu. ", (unsigned long int) (yyp
- yystack
->yyitems
));
2301 if (*(yybool
*) yyp
)
2303 fprintf (stderr
, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
2304 yyp
->yystate
.yyresolved
, yyp
->yystate
.yylrState
,
2305 (unsigned long int) yyp
->yystate
.yyposn
,
2306 (long int) YYINDEX (yyp
->yystate
.yypred
));
2307 if (! yyp
->yystate
.yyresolved
)
2308 fprintf (stderr
, ", firstVal: %ld",
2309 (long int) YYINDEX (yyp
->yystate
.yysemantics
.yyfirstVal
));
2313 fprintf (stderr
, "Option. rule: %d, state: %ld, next: %ld",
2314 yyp
->yyoption
.yyrule
,
2315 (long int) YYINDEX (yyp
->yyoption
.yystate
),
2316 (long int) YYINDEX (yyp
->yyoption
.yynext
));
2318 fprintf (stderr
, "\n");
2320 fprintf (stderr
, "Tops:");
2321 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
2322 fprintf (stderr
, "%lu: %ld; ", (unsigned long int) yyi
,
2323 (long int) YYINDEX (yystack
->yytops
.yystates
[yyi
]));
2324 fprintf (stderr
, "\n");
2330 m4_if(b4_defines_flag
, 0, [],
2331 [@output @output_header_name@
2332 b4_copyright([Skeleton parser
for GLR parsing with Bison
],
2333 [2002, 2003, 2004, 2005])
2335 b4_token_enums(b4_tokens
)
2337 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
2338 m4_ifdef([b4_stype
],
2339 [b4_syncline([b4_stype_line
], [b4_file_name
])
2340 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
2341 /* Line __line__ of glr.c. */
2342 b4_syncline([@oline@
], [@ofile@
])],
2343 [typedef int YYSTYPE
;])
2344 # define YYSTYPE_IS_DECLARED 1
2345 # define YYSTYPE_IS_TRIVIAL 1
2349 [extern YYSTYPE b4_prefix
[]lval
;])
2351 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
2352 typedef struct YYLTYPE
2363 # define YYLTYPE_IS_DECLARED 1
2364 # define YYLTYPE_IS_TRIVIAL 1
2367 b4_location_if([b4_pure_if([],
2368 [extern YYLTYPE b4_prefix
[]lloc
;])