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 # The possible parse-params formal arguments preceded by a comma.
41 # This is not shared with yacc.c in c.m4 because GLR relies on ISO C
42 # formal argument declarations.
43 m4_define([b4_user_formals
],
44 [m4_ifset([b4_parse_param
], [, b4_c_ansi_formals(b4_parse_param
)])])
49 # Accumule in b4_lex_param all the yylex arguments.
50 # Yes, this is quite ugly...
51 m4_define([b4_lex_param
],
52 m4_dquote(b4_pure_if([[[[YYSTYPE
*]], [[yylvalp]]][]dnl
53 b4_location_if([, [[YYLTYPE
*], [yyllocp
]]])])dnl
54 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
)))
59 # Optional effective arguments passed to yyerror: user args plus yylloc, and
61 m4_define([b4_yyerror_args
],
62 [b4_pure_if([b4_location_if([yylocp
, ])])dnl
63 m4_ifset([b4_parse_param
], [b4_c_args(b4_parse_param
), ])])
68 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
69 m4_define([b4_lyyerror_args
],
70 [b4_pure_if([b4_location_if([yyllocp
, ])])dnl
71 m4_ifset([b4_parse_param
], [b4_c_args(b4_parse_param
), ])])
76 # Same as b4_yyerror_args, but with a leading comma.
77 m4_define([b4_pure_args
],
78 [b4_pure_if([b4_location_if([, yylocp
])])[]b4_user_args
])
83 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
84 m4_define([b4_lpure_args
],
85 [b4_pure_if([b4_location_if([, yyllocp
])])[]b4_user_args
])
90 # Arguments passed to yyerror: user formals plus yyllocp.
91 m4_define([b4_pure_formals
],
92 [b4_pure_if([b4_location_if([, YYLTYPE
*yylocp
])])[]b4_user_formals
])
97 # Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
98 m4_define([b4_lpure_formals
],
99 [b4_pure_if([b4_location_if([YYLTYPE
*yyllocp
])])[]b4_user_formals
])
102 ## ----------------- ##
103 ## Semantic Values. ##
104 ## ----------------- ##
107 # b4_lhs_value([TYPE])
108 # --------------------
109 # Expansion of $<TYPE>$.
110 m4_define([b4_lhs_value
],
111 [((*yyvalp
)[]m4_ifval([$
1], [.$
1]))])
114 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
115 # --------------------------------------
116 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
118 m4_define([b4_rhs_value
],
119 [(((yyGLRStackItem
const *)yyvsp
)@
{YYFILL ($
2 - $
1)@
}.yystate
.yysemantics
.yysval
[]m4_ifval([$
3], [.$
3]))])
130 m4_define([b4_lhs_location
],
134 # b4_rhs_location(RULE-LENGTH, NUM)
135 # ---------------------------------
136 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
138 m4_define([b4_rhs_location
],
139 [(((yyGLRStackItem
const *)yyvsp
)@
{YYFILL ($
2 - $
1)@
}.yystate
.yyloc
)])
141 # We do want M4 expansion after # for CPP macros.
144 @output @output_parser_name@
145 b4_copyright([Skeleton parser
for GLR parsing with Bison
],
146 [2002, 2003, 2004, 2005])
148 /* This is the parser code for GLR (Generalized LR) parser. */
151 m4_if(b4_prefix
[], [yy
], [],
152 [/* Substitute the variable and function names. */
153 #define yyparse b4_prefix[]parse
154 #define yylex b4_prefix[]lex
155 #define yyerror b4_prefix[]error
156 #define yylval b4_prefix[]lval
157 #define yychar b4_prefix[]char
158 #define yydebug b4_prefix[]debug
159 #define yynerrs b4_prefix[]nerrs
160 #define yylloc b4_prefix[]lloc])
162 b4_token_enums(b4_tokens
)
164 /* Copy the first part of user declarations. */
167 /* Enabling traces. */
169 # define YYDEBUG ]b4_debug[
172 /* Enabling verbose error messages. */
173 #ifdef YYERROR_VERBOSE
174 # undef YYERROR_VERBOSE
175 # define YYERROR_VERBOSE 1
177 # define YYERROR_VERBOSE ]b4_error_verbose[
180 /* Enabling the token table. */
181 #ifndef YYTOKEN_TABLE
182 # define YYTOKEN_TABLE ]b4_token_table[
185 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
186 ]m4_ifdef([b4_stype
],
187 [b4_syncline([b4_stype_line
], [b4_file_name
])
188 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
189 /* Line __line__ of glr.c. */
190 b4_syncline([@oline@
], [@ofile@
])],
191 [typedef int YYSTYPE
;])[
192 # define YYSTYPE_IS_DECLARED 1
193 # define YYSTYPE_IS_TRIVIAL 1
196 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
197 typedef struct YYLTYPE
208 # define YYLTYPE_IS_DECLARED 1
209 # define YYLTYPE_IS_TRIVIAL 1
212 /* Default (constant) value used for initialization for null
213 right-hand sides. Unlike the standard yacc.c template,
214 here we set the default value of $$ to a zeroed-out value.
215 Since the default value is undefined, this behavior is
216 technically correct. */
217 static YYSTYPE yyval_default
;
219 /* Copy the second part of user declarations. */
222 ]/* Line __line__ of glr.c. */
223 b4_syncline([@oline@
], [@ofile@
])
233 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
234 # define YY_(msgid) dgettext ("bison-runtime", msgid)
238 # define YY_(msgid) msgid
242 /* Suppress unused-variable warnings by "using" E. */
243 #define YYUSE(e) do {;} while (/*CONSTCOND*/ yyfalse && (e))
249 # define YYMALLOC malloc
252 # define YYREALLOC realloc
255 #define YYSIZEMAX ((size_t) -1)
260 typedef unsigned char yybool
;
267 # define YYJMP_BUF jmp_buf
268 # define YYSETJMP(env) setjmp (env)
269 # define YYLONGJMP(env, val) longjmp (env, val)
276 #ifndef __attribute__
277 /* This feature is available in gcc versions 2.5 and later. */
278 # if (!defined (__GNUC__) || __GNUC__ < 2 \
279 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
280 # define __attribute__(Spec) /* empty */
284 ]b4_location_if([#define YYOPTIONAL_LOC(Name) Name],[
286 # define YYOPTIONAL_LOC(Name) /* empty */
288 # define YYOPTIONAL_LOC(Name) Name __attribute__ ((__unused__))
292 # define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
295 /* YYFINAL -- State number of the termination state. */
296 #define YYFINAL ]b4_final_state_number[
297 /* YYLAST -- Last index in YYTABLE. */
298 #define YYLAST ]b4_last[
300 /* YYNTOKENS -- Number of terminals. */
301 #define YYNTOKENS ]b4_tokens_number[
302 /* YYNNTS -- Number of nonterminals. */
303 #define YYNNTS ]b4_nterms_number[
304 /* YYNRULES -- Number of rules. */
305 #define YYNRULES ]b4_rules_number[
306 /* YYNRULES -- Number of states. */
307 #define YYNSTATES ]b4_states_number[
308 /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
309 #define YYMAXRHS ]b4_r2_max[
310 /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
311 accessed by $0, $-1, etc., in any rule. */
312 #define YYMAXLEFT ]b4_max_left_semantic_context[
314 /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
315 #define YYUNDEFTOK ]b4_undef_token_number[
316 #define YYMAXUTOK ]b4_user_token_number_max[
318 #define YYTRANSLATE(YYX) \
319 ((YYX <= 0) ? YYEOF : \
320 (unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
322 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
323 static const ]b4_int_type_for([b4_translate
])[ yytranslate
[] =
329 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
331 static const ]b4_int_type_for([b4_prhs
])[ yyprhs
[] =
336 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
337 static const ]b4_int_type_for([b4_rhs
])[ yyrhs
[] =
342 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
343 static const ]b4_int_type_for([b4_rline
])[ yyrline
[] =
349 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
350 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
351 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
352 static const char *const yytname
[] =
358 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
359 static const ]b4_int_type_for([b4_r1
])[ yyr1
[] =
364 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
365 static const ]b4_int_type_for([b4_r2
])[ yyr2
[] =
370 /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
371 static const ]b4_int_type_for([b4_dprec
])[ yydprec
[] =
376 /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
377 static const ]b4_int_type_for([b4_merger
])[ yymerger
[] =
382 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
383 doesn't specify something else to do. Zero means the default is an
385 static const ]b4_int_type_for([b4_defact
])[ yydefact
[] =
390 /* YYPDEFGOTO[NTERM-NUM]. */
391 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto
[] =
396 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
398 #define YYPACT_NINF ]b4_pact_ninf[
399 static const ]b4_int_type_for([b4_pact
])[ yypact
[] =
404 /* YYPGOTO[NTERM-NUM]. */
405 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto
[] =
410 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
411 positive, shift that token. If negative, reduce the rule which
412 number is the opposite. If zero, do what YYDEFACT says.
413 If YYTABLE_NINF, syntax error. */
414 #define YYTABLE_NINF ]b4_table_ninf[
415 static const ]b4_int_type_for([b4_table
])[ yytable
[] =
420 /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
421 list of conflicting reductions corresponding to action entry for
422 state STATE-NUM in yytable. 0 means no conflicts. The list in
423 yyconfl is terminated by a rule number of 0. */
424 static const ]b4_int_type_for([b4_conflict_list_heads
])[ yyconflp
[] =
426 ]b4_conflict_list_heads
[
429 /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
430 0, pointed into by YYCONFLP. */
431 ]dnl Do
not use b4_int_type_for here
, since there are places where
432 dnl pointers onto yyconfl are taken
, which type is
"short int *".
433 dnl We probably ought to introduce a type
for confl
.
434 [static const short int yyconfl
[] =
436 ]b4_conflicting_rules
[
439 static const ]b4_int_type_for([b4_check
])[ yycheck
[] =
444 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
445 symbol of state STATE-NUM. */
446 static const ]b4_int_type_for([b4_stos
])[ yystos
[] =
452 /* Prevent warning if -Wmissing-prototypes. */
453 ]b4_c_ansi_function_decl([yyparse
], [int], b4_parse_param
)[
455 /* Error token number */
458 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
459 If N is 0, then set CURRENT to the empty location which ends
460 the previous symbol: RHS[0] (always defined). */
463 #define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
464 #ifndef YYLLOC_DEFAULT
465 # define YYLLOC_DEFAULT(Current, Rhs, N) \
469 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
470 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
471 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
472 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
476 (Current).first_line = (Current).last_line = \
477 YYRHSLOC (Rhs, 0).last_line; \
478 (Current).first_column = (Current).last_column = \
479 YYRHSLOC (Rhs, 0).last_column; \
481 while (/*CONSTCOND*/ 0)
483 /* YY_LOCATION_PRINT -- Print the location on the stream.
484 This macro was not mandated originally: define only if we know
485 we won't break user code: when these are the locations we know. */
487 # define YY_LOCATION_PRINT(File, Loc) \
488 fprintf (File, "%d.%d-%d.%d", \
489 (Loc).first_line, (Loc).first_column, \
490 (Loc).last_line, (Loc).last_column)
493 #ifndef YYLLOC_DEFAULT
494 # define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)
498 #ifndef YY_LOCATION_PRINT
499 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
503 /* YYLEX -- calling `yylex' with the right arguments. */
504 #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
509 #define yynerrs (yystack->yyerrcnt)
511 #define yychar (yystack->yyrawchar)],
519 static const int YYEOF
= 0;
520 static const int YYEMPTY
= -2;
522 typedef enum { yyok
, yyaccept
, yyabort
, yyerr
} YYRESULTTAG
;
525 do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
526 while (/*CONSTCOND*/ 0)
530 #if ! defined (YYFPRINTF)
531 # define YYFPRINTF fprintf
534 # define YYDPRINTF(Args) \
538 } while (/*CONSTCOND*/ 0)
540 ]b4_yysymprint_generate([b4_c_ansi_function_def
])[
542 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
546 YYFPRINTF (stderr, "%s ", Title); \
547 yysymprint (stderr, \
548 Type, Value]b4_location_if([, Location])[]b4_user_args[); \
549 YYFPRINTF (stderr, "\n"); \
551 } while (/*CONSTCOND*/ 0)
553 /* Nonzero means print parse trace. It is left uninitialized so that
554 multiple parsers can coexist. */
559 # define YYDPRINTF(Args)
560 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
562 #endif /* !YYDEBUG */
564 /* YYINITDEPTH -- initial size of the parser's stacks. */
566 # define YYINITDEPTH ]b4_stack_depth_init[
569 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
570 if the built-in stack extension method is used).
572 Do not make this value too large; the results are undefined if
573 SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
574 evaluated with infinite-precision integer arithmetic. */
577 # define YYMAXDEPTH ]b4_stack_depth_max[
580 /* Minimum number of free items on the stack allowed after an
581 allocation. This is to allow allocation and initialization
582 to be completed by functions that call yyexpandGLRStack before the
583 stack is expanded, thus insuring that all necessary pointers get
584 properly redirected to new data. */
587 #ifndef YYSTACKEXPANDABLE
588 # if (! defined (__cplusplus) \
589 || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \
590 && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))
591 # define YYSTACKEXPANDABLE 1
593 # define YYSTACKEXPANDABLE 0
597 #if YYSTACKEXPANDABLE
598 # define YY_RESERVE_GLRSTACK(Yystack) \
600 if (Yystack->yyspaceLeft < YYHEADROOM) \
601 yyexpandGLRStack (Yystack); \
602 } while (/*CONSTCOND*/ 0)
604 # define YY_RESERVE_GLRSTACK(Yystack) \
606 if (Yystack->yyspaceLeft < YYHEADROOM) \
607 yyMemoryExhausted (Yystack); \
608 } while (/*CONSTCOND*/ 0)
615 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
616 # define yystpcpy stpcpy
618 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
621 yystpcpy (char *yydest
, const char *yysrc
)
624 const char *yys
= yysrc
;
626 while ((*yyd
++ = *yys
++) != '\0')
635 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
636 quotes and backslashes, so that it's suitable for yyerror. The
637 heuristic is that double-quoting is unnecessary unless the string
638 contains an apostrophe, a comma, or backslash (other than
639 backslash-backslash). YYSTR is taken from yytname. If YYRES is
640 null, do not copy; instead, return the length of what the result
643 yytnamerr (char *yyres
, const char *yystr
)
648 char const *yyp
= yystr
;
655 goto do_not_strip_quotes
;
659 goto do_not_strip_quotes
;
672 do_not_strip_quotes
: ;
676 return strlen (yystr
);
678 return yystpcpy (yyres
, yystr
) - yyres
;
682 #endif /* !YYERROR_VERBOSE */
684 /** State numbers, as in LALR(1) machine */
685 typedef int yyStateNum
;
687 /** Rule numbers, as in LALR(1) machine */
688 typedef int yyRuleNum
;
690 /** Grammar symbol */
691 typedef short int yySymbol
;
693 /** Item references, as in LALR(1) machine */
694 typedef short int yyItemNum
;
696 typedef struct yyGLRState yyGLRState
;
697 typedef struct yySemanticOption yySemanticOption
;
698 typedef union yyGLRStackItem yyGLRStackItem
;
699 typedef struct yyGLRStack yyGLRStack
;
700 typedef struct yyGLRStateSet yyGLRStateSet
;
703 /** Type tag: always true. */
705 /** Type tag for yysemantics. If true, yysval applies, otherwise
706 * yyfirstVal applies. */
708 /** Number of corresponding LALR(1) machine state. */
709 yyStateNum yylrState
;
710 /** Preceding state in this stack */
712 /** Source position of the first token produced by my symbol */
715 /** First in a chain of alternative reductions producing the
716 * non-terminal corresponding to this state, threaded through
718 yySemanticOption
* yyfirstVal
;
719 /** Semantic value for this state. */
722 /** Source location for this state. */
726 struct yyGLRStateSet
{
727 yyGLRState
** yystates
;
728 size_t yysize
, yycapacity
;
731 struct yySemanticOption
{
732 /** Type tag: always false. */
734 /** Rule number for this reduction */
736 /** The last RHS state in the list of states to be reduced. */
738 /** Next sibling in chain of options. To facilitate merging,
739 * options are chained in decreasing order by address. */
740 yySemanticOption
* yynext
;
743 /** Type of the items in the GLR stack. The yyisState field
744 * indicates which item of the union is valid. */
745 union yyGLRStackItem
{
747 yySemanticOption yyoption
;
752 ]b4_location_if([[ /* To compute the location of the error token. */
753 yyGLRStackItem yyerror_range
[3];]])[
760 YYJMP_BUF yyexception_buffer
;
761 yyGLRStackItem
* yyitems
;
762 yyGLRStackItem
* yynextFree
;
764 yyGLRState
* yysplitPoint
;
765 yyGLRState
* yylastDeleted
;
766 yyGLRStateSet yytops
;
769 static void yyexpandGLRStack (yyGLRStack
* yystack
);
771 static void yyFail (yyGLRStack
* yystack
]b4_pure_formals
[, const char* yymsg
)
772 __attribute__ ((__noreturn__
));
774 yyFail (yyGLRStack
* yystack
]b4_pure_formals
[, const char* yymsg
)
777 yyerror (]b4_yyerror_args
[yymsg
);
778 YYLONGJMP (yystack
->yyexception_buffer
, 1);
781 static void yyMemoryExhausted (yyGLRStack
* yystack
)
782 __attribute__ ((__noreturn__
));
784 yyMemoryExhausted (yyGLRStack
* yystack
)
786 YYLONGJMP (yystack
->yyexception_buffer
, 2);
789 #if YYDEBUG || YYERROR_VERBOSE
790 /** A printable representation of TOKEN. */
791 static inline const char*
792 yytokenName (yySymbol yytoken
)
794 if (yytoken
== YYEMPTY
)
797 return yytname
[yytoken
];
801 /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
802 * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
803 * containing the pointer to the next state in the chain. */
804 static void yyfillin (yyGLRStackItem
*, int, int) __attribute__ ((__unused__
));
806 yyfillin (yyGLRStackItem
*yyvsp
, int yylow0
, int yylow1
)
810 s
= yyvsp
[yylow0
].yystate
.yypred
;
811 for (i
= yylow0
-1; i
>= yylow1
; i
-= 1)
813 YYASSERT (s
->yyresolved
);
814 yyvsp
[i
].yystate
.yyresolved
= yytrue
;
815 yyvsp
[i
].yystate
.yysemantics
.yysval
= s
->yysemantics
.yysval
;
816 yyvsp
[i
].yystate
.yyloc
= s
->yyloc
;
817 s
= yyvsp
[i
].yystate
.yypred
= s
->yypred
;
821 /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
822 * YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
823 * For convenience, always return YYLOW1. */
824 static inline int yyfill (yyGLRStackItem
*, int *, int, yybool
)
825 __attribute__ ((__unused__
));
827 yyfill (yyGLRStackItem
*yyvsp
, int *yylow
, int yylow1
, yybool yynormal
)
829 if (!yynormal
&& yylow1
< *yylow
)
831 yyfillin (yyvsp
, *yylow
, yylow1
);
837 /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
838 * and top stack item YYVSP. YYLVALP points to place to put semantic
839 * value ($$), and yylocp points to place for location information
840 * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
841 * yyerr for YYERROR, yyabort for YYABORT. */
843 yyuserAction (yyRuleNum yyn
, int yyrhslen
, yyGLRStackItem
* yyvsp
,
845 YYLTYPE
* YYOPTIONAL_LOC (yylocp
),
849 yybool yynormal
__attribute__ ((__unused__
)) =
850 (yystack
->yysplitPoint
== NULL
);
854 # define yyerrok (yystack->yyerrState = 0)
856 # define YYACCEPT return yyaccept
858 # define YYABORT return yyabort
860 # define YYERROR return yyerrok, yyerr
862 # define YYRECOVERING (yystack->yyerrState != 0)
864 # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)
866 # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
868 # define YYBACKUP(Token, Value) \
869 return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
874 *yyvalp
= yyval_default
;
876 *yyvalp
= yyvsp
[YYFILL (1-yyrhslen
)].yystate
.yysemantics
.yysval
;
877 YYLLOC_DEFAULT (*yylocp
, yyvsp
- yyrhslen
, yyrhslen
);
878 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= *yylocp
;
894 /* Line __line__ of glr.c. */
895 b4_syncline([@oline@
], [@ofile@
])
900 yyuserMerge (int yyn
, YYSTYPE
* yy0
, YYSTYPE
* yy1
)
912 /* Bison grammar-table manipulation. */
914 ]b4_yydestruct_generate([b4_c_ansi_function_def
])[
916 /** Number of symbols composing the right hand side of rule #RULE. */
918 yyrhsLength (yyRuleNum yyrule
)
924 yydestroyGLRState (char const *yymsg
, yyGLRState
*yys
]b4_user_formals
[)
927 yydestruct (yymsg
, yystos
[yys
->yylrState
],
928 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[]b4_user_args
[);
934 YYFPRINTF (stderr
, "%s unresolved ", yymsg
);
935 yysymprint (stderr
, yystos
[yys
->yylrState
],
936 &yys
->yysemantics
.yysval
]b4_location_if([, &yys
->yyloc
])[]b4_user_args
[);
937 YYFPRINTF (stderr
, "\n");
941 if (yys
->yysemantics
.yyfirstVal
)
943 yySemanticOption
*yyoption
= yys
->yysemantics
.yyfirstVal
;
946 for (yyrh
= yyoption
->yystate
, yyn
= yyrhsLength (yyoption
->yyrule
);
948 yyrh
= yyrh
->yypred
, yyn
-= 1)
949 yydestroyGLRState (yymsg
, yyrh
]b4_user_args
[);
954 /** Left-hand-side symbol for rule #RULE. */
955 static inline yySymbol
956 yylhsNonterm (yyRuleNum yyrule
)
961 #define yyis_pact_ninf(yystate) \
962 ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), [1],
964 [((yystate
) == YYPACT_NINF
)])[
966 /** True iff LR state STATE has only a default reduction (regardless
969 yyisDefaultedState (yyStateNum yystate
)
971 return yyis_pact_ninf (yypact
[yystate
]);
974 /** The default reduction for STATE, assuming it has one. */
975 static inline yyRuleNum
976 yydefaultAction (yyStateNum yystate
)
978 return yydefact
[yystate
];
981 #define yyis_table_ninf(yytable_value) \
982 ]m4_if(m4_eval(b4_table_ninf < b4_table_min), [1],
984 [((yytable_value
) == YYTABLE_NINF
)])[
986 /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
988 * R < 0: Reduce on rule -R.
990 * R > 0: Shift to state R.
991 * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
992 * conflicting reductions.
995 yygetLRActions (yyStateNum yystate
, int yytoken
,
996 int* yyaction
, const short int** yyconflicts
)
998 int yyindex
= yypact
[yystate
] + yytoken
;
999 if (yyindex
< 0 || YYLAST
< yyindex
|| yycheck
[yyindex
] != yytoken
)
1001 *yyaction
= -yydefact
[yystate
];
1002 *yyconflicts
= yyconfl
;
1004 else if (! yyis_table_ninf (yytable
[yyindex
]))
1006 *yyaction
= yytable
[yyindex
];
1007 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
1012 *yyconflicts
= yyconfl
+ yyconflp
[yyindex
];
1016 static inline yyStateNum
1017 yyLRgotoState (yyStateNum yystate
, yySymbol yylhs
)
1020 yyr
= yypgoto
[yylhs
- YYNTOKENS
] + yystate
;
1021 if (0 <= yyr
&& yyr
<= YYLAST
&& yycheck
[yyr
] == yystate
)
1022 return yytable
[yyr
];
1024 return yydefgoto
[yylhs
- YYNTOKENS
];
1027 static inline yybool
1028 yyisShiftAction (int yyaction
)
1030 return 0 < yyaction
;
1033 static inline yybool
1034 yyisErrorAction (int yyaction
)
1036 return yyaction
== 0;
1041 /** Return a fresh GLRStackItem. Callers should call
1042 * YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
1045 static inline yyGLRStackItem
*
1046 yynewGLRStackItem (yyGLRStack
* yystack
, yybool yyisState
)
1048 yyGLRStackItem
* yynewItem
= yystack
->yynextFree
;
1049 yystack
->yyspaceLeft
-= 1;
1050 yystack
->yynextFree
+= 1;
1051 yynewItem
->yystate
.yyisState
= yyisState
;
1056 yyaddDeferredAction (yyGLRStack
* yystack
, yyGLRState
* yystate
,
1057 yyGLRState
* rhs
, yyRuleNum yyrule
)
1059 yySemanticOption
* yynewOption
=
1060 &yynewGLRStackItem (yystack
, yyfalse
)->yyoption
;
1061 yynewOption
->yystate
= rhs
;
1062 yynewOption
->yyrule
= yyrule
;
1063 yynewOption
->yynext
= yystate
->yysemantics
.yyfirstVal
;
1064 yystate
->yysemantics
.yyfirstVal
= yynewOption
;
1066 YY_RESERVE_GLRSTACK (yystack
);
1071 /** Initialize SET to a singleton set containing an empty stack. */
1073 yyinitStateSet (yyGLRStateSet
* yyset
)
1076 yyset
->yycapacity
= 16;
1077 yyset
->yystates
= (yyGLRState
**) YYMALLOC (16 * sizeof yyset
->yystates
[0]);
1078 if (! yyset
->yystates
)
1080 yyset
->yystates
[0] = NULL
;
1084 static void yyfreeStateSet (yyGLRStateSet
* yyset
)
1086 YYFREE (yyset
->yystates
);
1089 /** Initialize STACK to a single empty stack, with total maximum
1090 * capacity for all stacks of SIZE. */
1092 yyinitGLRStack (yyGLRStack
* yystack
, size_t yysize
)
1094 yystack
->yyerrState
= 0;
1096 yystack
->yyspaceLeft
= yysize
;
1098 (yyGLRStackItem
*) YYMALLOC (yysize
* sizeof yystack
->yynextFree
[0]);
1099 if (!yystack
->yyitems
)
1101 yystack
->yynextFree
= yystack
->yyitems
;
1102 yystack
->yysplitPoint
= NULL
;
1103 yystack
->yylastDeleted
= NULL
;
1104 return yyinitStateSet (&yystack
->yytops
);
1108 #if YYSTACKEXPANDABLE
1109 # define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
1110 &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
1112 /** If STACK is expandable, extend it. WARNING: Pointers into the
1113 stack from outside should be considered invalid after this call.
1114 We always expand when there are 1 or fewer items left AFTER an
1115 allocation, so that we can avoid having external pointers exist
1116 across an allocation. */
1118 yyexpandGLRStack (yyGLRStack
* yystack
)
1120 yyGLRStackItem
* yynewItems
;
1121 yyGLRStackItem
* yyp0
, *yyp1
;
1122 size_t yysize
, yynewSize
;
1124 yysize
= yystack
->yynextFree
- yystack
->yyitems
;
1125 if (YYMAXDEPTH
<= yysize
)
1126 yyMemoryExhausted (yystack
);
1127 yynewSize
= 2*yysize
;
1128 if (YYMAXDEPTH
< yynewSize
)
1129 yynewSize
= YYMAXDEPTH
;
1130 yynewItems
= (yyGLRStackItem
*) YYMALLOC (yynewSize
* sizeof yynewItems
[0]);
1132 yyMemoryExhausted (yystack
);
1133 for (yyp0
= yystack
->yyitems
, yyp1
= yynewItems
, yyn
= yysize
;
1135 yyn
-= 1, yyp0
+= 1, yyp1
+= 1)
1138 if (*(yybool
*) yyp0
)
1140 yyGLRState
* yys0
= &yyp0
->yystate
;
1141 yyGLRState
* yys1
= &yyp1
->yystate
;
1142 if (yys0
->yypred
!= NULL
)
1144 YYRELOC (yyp0
, yyp1
, yys0
->yypred
, yystate
);
1145 if (! yys0
->yyresolved
&& yys0
->yysemantics
.yyfirstVal
!= NULL
)
1146 yys1
->yysemantics
.yyfirstVal
=
1147 YYRELOC(yyp0
, yyp1
, yys0
->yysemantics
.yyfirstVal
, yyoption
);
1151 yySemanticOption
* yyv0
= &yyp0
->yyoption
;
1152 yySemanticOption
* yyv1
= &yyp1
->yyoption
;
1153 if (yyv0
->yystate
!= NULL
)
1154 yyv1
->yystate
= YYRELOC (yyp0
, yyp1
, yyv0
->yystate
, yystate
);
1155 if (yyv0
->yynext
!= NULL
)
1156 yyv1
->yynext
= YYRELOC (yyp0
, yyp1
, yyv0
->yynext
, yyoption
);
1159 if (yystack
->yysplitPoint
!= NULL
)
1160 yystack
->yysplitPoint
= YYRELOC (yystack
->yyitems
, yynewItems
,
1161 yystack
->yysplitPoint
, yystate
);
1163 for (yyn
= 0; yyn
< yystack
->yytops
.yysize
; yyn
+= 1)
1164 if (yystack
->yytops
.yystates
[yyn
] != NULL
)
1165 yystack
->yytops
.yystates
[yyn
] =
1166 YYRELOC (yystack
->yyitems
, yynewItems
,
1167 yystack
->yytops
.yystates
[yyn
], yystate
);
1168 YYFREE (yystack
->yyitems
);
1169 yystack
->yyitems
= yynewItems
;
1170 yystack
->yynextFree
= yynewItems
+ yysize
;
1171 yystack
->yyspaceLeft
= yynewSize
- yysize
;
1176 yyfreeGLRStack (yyGLRStack
* yystack
)
1178 YYFREE (yystack
->yyitems
);
1179 yyfreeStateSet (&yystack
->yytops
);
1182 /** Assuming that S is a GLRState somewhere on STACK, update the
1183 * splitpoint of STACK, if needed, so that it is at least as deep as
1186 yyupdateSplit (yyGLRStack
* yystack
, yyGLRState
* yys
)
1188 if (yystack
->yysplitPoint
!= NULL
&& yystack
->yysplitPoint
> yys
)
1189 yystack
->yysplitPoint
= yys
;
1192 /** Invalidate stack #K in STACK. */
1194 yymarkStackDeleted (yyGLRStack
* yystack
, size_t yyk
)
1196 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
1197 yystack
->yylastDeleted
= yystack
->yytops
.yystates
[yyk
];
1198 yystack
->yytops
.yystates
[yyk
] = NULL
;
1201 /** Undelete the last stack that was marked as deleted. Can only be
1202 done once after a deletion, and only when all other stacks have
1205 yyundeleteLastStack (yyGLRStack
* yystack
)
1207 if (yystack
->yylastDeleted
== NULL
|| yystack
->yytops
.yysize
!= 0)
1209 yystack
->yytops
.yystates
[0] = yystack
->yylastDeleted
;
1210 yystack
->yytops
.yysize
= 1;
1211 YYDPRINTF ((stderr
, "Restoring last deleted stack as stack #0.\n"));
1212 yystack
->yylastDeleted
= NULL
;
1216 yyremoveDeletes (yyGLRStack
* yystack
)
1220 while (yyj
< yystack
->yytops
.yysize
)
1222 if (yystack
->yytops
.yystates
[yyi
] == NULL
)
1226 YYDPRINTF ((stderr
, "Removing dead stacks.\n"));
1228 yystack
->yytops
.yysize
-= 1;
1232 yystack
->yytops
.yystates
[yyj
] = yystack
->yytops
.yystates
[yyi
];
1235 YYDPRINTF ((stderr
, "Rename stack %lu -> %lu.\n",
1236 (unsigned long int) yyi
, (unsigned long int) yyj
));
1244 /** Shift to a new state on stack #K of STACK, corresponding to LR state
1245 * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
1247 yyglrShift (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1249 YYSTYPE yysval
, YYLTYPE
* yylocp
)
1251 yyGLRState
* yynewState
= &yynewGLRStackItem (yystack
, yytrue
)->yystate
;
1253 yynewState
->yylrState
= yylrState
;
1254 yynewState
->yyposn
= yyposn
;
1255 yynewState
->yyresolved
= yytrue
;
1256 yynewState
->yypred
= yystack
->yytops
.yystates
[yyk
];
1257 yynewState
->yysemantics
.yysval
= yysval
;
1258 yynewState
->yyloc
= *yylocp
;
1259 yystack
->yytops
.yystates
[yyk
] = yynewState
;
1261 YY_RESERVE_GLRSTACK (yystack
);
1264 /** Shift stack #K of YYSTACK, to a new state corresponding to LR
1265 * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
1266 * semantic value of YYRHS under the action for YYRULE. */
1268 yyglrShiftDefer (yyGLRStack
* yystack
, size_t yyk
, yyStateNum yylrState
,
1269 size_t yyposn
, yyGLRState
* rhs
, yyRuleNum yyrule
)
1271 yyGLRState
* yynewState
= &yynewGLRStackItem (yystack
, yytrue
)->yystate
;
1273 yynewState
->yylrState
= yylrState
;
1274 yynewState
->yyposn
= yyposn
;
1275 yynewState
->yyresolved
= yyfalse
;
1276 yynewState
->yypred
= yystack
->yytops
.yystates
[yyk
];
1277 yynewState
->yysemantics
.yyfirstVal
= NULL
;
1278 yystack
->yytops
.yystates
[yyk
] = yynewState
;
1280 /* Invokes YY_RESERVE_GLRSTACK. */
1281 yyaddDeferredAction (yystack
, yynewState
, rhs
, yyrule
);
1284 /** Pop the symbols consumed by reduction #RULE from the top of stack
1285 * #K of STACK, and perform the appropriate semantic action on their
1286 * semantic values. Assumes that all ambiguities in semantic values
1287 * have been previously resolved. Set *VALP to the resulting value,
1288 * and *LOCP to the computed location (if any). Return value is as
1289 * for userAction. */
1290 static inline YYRESULTTAG
1291 yydoAction (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1292 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1294 int yynrhs
= yyrhsLength (yyrule
);
1296 if (yystack
->yysplitPoint
== NULL
)
1298 /* Standard special case: single stack. */
1299 yyGLRStackItem
* rhs
= (yyGLRStackItem
*) yystack
->yytops
.yystates
[yyk
];
1300 YYASSERT (yyk
== 0);
1301 yystack
->yynextFree
-= yynrhs
;
1302 yystack
->yyspaceLeft
+= yynrhs
;
1303 yystack
->yytops
.yystates
[0] = & yystack
->yynextFree
[-1].yystate
;
1304 return yyuserAction (yyrule
, yynrhs
, rhs
,
1305 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1309 /* At present, doAction is never called in nondeterministic
1310 * mode, so this branch is never taken. It is here in
1311 * anticipation of a future feature that will allow immediate
1312 * evaluation of selected actions in nondeterministic mode. */
1315 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1316 yys
= yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
1317 = yystack
->yytops
.yystates
[yyk
];]b4_location_if([[
1319 /* Set default location. */
1320 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
- 1].yystate
.yyloc
= yys
->yyloc
;]])[
1321 for (yyi
= 0; yyi
< yynrhs
; yyi
+= 1)
1326 yyupdateSplit (yystack
, yys
);
1327 yystack
->yytops
.yystates
[yyk
] = yys
;
1328 return yyuserAction (yyrule
, yynrhs
, yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1329 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1334 # define YY_REDUCE_PRINT(Args)
1336 # define YY_REDUCE_PRINT(Args) \
1339 yy_reduce_print Args; \
1340 } while (/*CONSTCOND*/ 0)
1342 /*----------------------------------------------------------.
1343 | Report that the RULE is going to be reduced on stack #K. |
1344 `----------------------------------------------------------*/
1347 yy_reduce_print (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1348 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1350 int yynrhs
= yyrhsLength (yyrule
);
1351 yybool yynormal
__attribute__ ((__unused__
)) =
1352 (yystack
->yysplitPoint
== NULL
);
1353 yyGLRStackItem
* yyvsp
= (yyGLRStackItem
*) yystack
->yytops
.yystates
[yyk
];
1356 YYFPRINTF (stderr
, "Reducing stack %lu by rule %d (line %lu):\n",
1357 (unsigned long int) yyk
, yyrule
- 1,
1358 (unsigned long int) yyrline
[yyrule
]);
1359 /* Print the symbols being reduced, and their result. */
1360 //for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
1361 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
1363 fprintf (stderr
, " $%d = ", yyi
);
1364 yysymprint (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
1365 &]b4_rhs_value(yynrhs
, yyi
)[
1366 ]b4_location_if([, &]b4_rhs_location(yynrhs
, yyi
))[]dnl
1368 fprintf (stderr
, "\n");
1373 /** Pop items off stack #K of STACK according to grammar rule RULE,
1374 * and push back on the resulting nonterminal symbol. Perform the
1375 * semantic action associated with RULE and store its value with the
1376 * newly pushed state, if FORCEEVAL or if STACK is currently
1377 * unambiguous. Otherwise, store the deferred semantic action with
1378 * the new state. If the new state would have an identical input
1379 * position, LR state, and predecessor to an existing state on the stack,
1380 * it is identified with that existing state, eliminating stack #K from
1381 * the STACK. In this case, the (necessarily deferred) semantic value is
1382 * added to the options for the existing state's semantic value.
1384 static inline YYRESULTTAG
1385 yyglrReduce (yyGLRStack
* yystack
, size_t yyk
, yyRuleNum yyrule
,
1386 yybool yyforceEval
]b4_user_formals
[)
1388 size_t yyposn
= yystack
->yytops
.yystates
[yyk
]->yyposn
;
1390 if (yyforceEval
|| yystack
->yysplitPoint
== NULL
)
1395 YY_REDUCE_PRINT ((yystack
, yyk
, yyrule
, &yysval
, &yyloc
]b4_user_args
[));
1396 YYCHK (yydoAction (yystack
, yyk
, yyrule
, &yysval
, &yyloc
]b4_user_args
[));
1397 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyrule
], &yysval
, &yyloc
);
1398 yyglrShift (yystack
, yyk
,
1399 yyLRgotoState (yystack
->yytops
.yystates
[yyk
]->yylrState
,
1400 yylhsNonterm (yyrule
)),
1401 yyposn
, yysval
, &yyloc
);
1407 yyGLRState
* yys
, *yys0
= yystack
->yytops
.yystates
[yyk
];
1408 yyStateNum yynewLRState
;
1410 for (yys
= yystack
->yytops
.yystates
[yyk
], yyn
= yyrhsLength (yyrule
);
1416 yyupdateSplit (yystack
, yys
);
1417 yynewLRState
= yyLRgotoState (yys
->yylrState
, yylhsNonterm (yyrule
));
1419 "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
1420 (unsigned long int) yyk
, yyrule
- 1, yynewLRState
));
1421 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
1422 if (yyi
!= yyk
&& yystack
->yytops
.yystates
[yyi
] != NULL
)
1424 yyGLRState
* yyp
, *yysplit
= yystack
->yysplitPoint
;
1425 yyp
= yystack
->yytops
.yystates
[yyi
];
1426 while (yyp
!= yys
&& yyp
!= yysplit
&& yyp
->yyposn
>= yyposn
)
1428 if (yyp
->yylrState
== yynewLRState
&& yyp
->yypred
== yys
)
1430 yyaddDeferredAction (yystack
, yyp
, yys0
, yyrule
);
1431 yymarkStackDeleted (yystack
, yyk
);
1432 YYDPRINTF ((stderr
, "Merging stack %lu into stack %lu.\n",
1433 (unsigned long int) yyk
,
1434 (unsigned long int) yyi
));
1440 yystack
->yytops
.yystates
[yyk
] = yys
;
1441 yyglrShiftDefer (yystack
, yyk
, yynewLRState
, yyposn
, yys0
, yyrule
);
1447 yysplitStack (yyGLRStack
* yystack
, size_t yyk
)
1449 if (yystack
->yysplitPoint
== NULL
)
1451 YYASSERT (yyk
== 0);
1452 yystack
->yysplitPoint
= yystack
->yytops
.yystates
[yyk
];
1454 if (yystack
->yytops
.yysize
>= yystack
->yytops
.yycapacity
)
1456 yyGLRState
** yynewStates
;
1457 if (! ((yystack
->yytops
.yycapacity
1458 <= (YYSIZEMAX
/ (2 * sizeof yynewStates
[0])))
1460 (yyGLRState
**) YYREALLOC (yystack
->yytops
.yystates
,
1461 ((yystack
->yytops
.yycapacity
*= 2)
1462 * sizeof yynewStates
[0])))))
1463 yyMemoryExhausted (yystack
);
1464 yystack
->yytops
.yystates
= yynewStates
;
1466 yystack
->yytops
.yystates
[yystack
->yytops
.yysize
]
1467 = yystack
->yytops
.yystates
[yyk
];
1468 yystack
->yytops
.yysize
+= 1;
1469 return yystack
->yytops
.yysize
-1;
1472 /** True iff Y0 and Y1 represent identical options at the top level.
1473 * That is, they represent the same rule applied to RHS symbols
1474 * that produce the same terminal symbols. */
1476 yyidenticalOptions (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1478 if (yyy0
->yyrule
== yyy1
->yyrule
)
1480 yyGLRState
*yys0
, *yys1
;
1482 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1483 yyn
= yyrhsLength (yyy0
->yyrule
);
1485 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1486 if (yys0
->yyposn
!= yys1
->yyposn
)
1494 /** Assuming identicalOptions (Y0,Y1), destructively merge the
1495 * alternative semantic values for the RHS-symbols of Y1 and Y0. */
1497 yymergeOptionSets (yySemanticOption
* yyy0
, yySemanticOption
* yyy1
)
1499 yyGLRState
*yys0
, *yys1
;
1501 for (yys0
= yyy0
->yystate
, yys1
= yyy1
->yystate
,
1502 yyn
= yyrhsLength (yyy0
->yyrule
);
1504 yys0
= yys0
->yypred
, yys1
= yys1
->yypred
, yyn
-= 1)
1508 else if (yys0
->yyresolved
)
1510 yys1
->yyresolved
= yytrue
;
1511 yys1
->yysemantics
.yysval
= yys0
->yysemantics
.yysval
;
1513 else if (yys1
->yyresolved
)
1515 yys0
->yyresolved
= yytrue
;
1516 yys0
->yysemantics
.yysval
= yys1
->yysemantics
.yysval
;
1520 yySemanticOption
** yyz0p
;
1521 yySemanticOption
* yyz1
;
1522 yyz0p
= &yys0
->yysemantics
.yyfirstVal
;
1523 yyz1
= yys1
->yysemantics
.yyfirstVal
;
1526 if (yyz1
== *yyz0p
|| yyz1
== NULL
)
1528 else if (*yyz0p
== NULL
)
1533 else if (*yyz0p
< yyz1
)
1535 yySemanticOption
* yyz
= *yyz0p
;
1537 yyz1
= yyz1
->yynext
;
1538 (*yyz0p
)->yynext
= yyz
;
1540 yyz0p
= &(*yyz0p
)->yynext
;
1542 yys1
->yysemantics
.yyfirstVal
= yys0
->yysemantics
.yyfirstVal
;
1547 /** Y0 and Y1 represent two possible actions to take in a given
1548 * parsing state; return 0 if no combination is possible,
1549 * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
1551 yypreference (yySemanticOption
* y0
, yySemanticOption
* y1
)
1553 yyRuleNum r0
= y0
->yyrule
, r1
= y1
->yyrule
;
1554 int p0
= yydprec
[r0
], p1
= yydprec
[r1
];
1558 if (yymerger
[r0
] == 0 || yymerger
[r0
] != yymerger
[r1
])
1563 if (p0
== 0 || p1
== 0)
1572 static YYRESULTTAG
yyresolveValue (yySemanticOption
* yyoptionList
,
1573 yyGLRStack
* yystack
, YYSTYPE
* yyvalp
,
1574 YYLTYPE
* yylocp
]b4_user_formals
[);
1577 yyresolveStates (yyGLRState
* yys
, int yyn
, yyGLRStack
* yystack
]b4_user_formals
[)
1582 YYASSERT (yys
->yypred
);
1583 yyflag
= yyresolveStates (yys
->yypred
, yyn
-1, yystack
]b4_user_args
[);
1586 if (! yys
->yyresolved
)
1588 yyflag
= yyresolveValue (yys
->yysemantics
.yyfirstVal
, yystack
,
1589 &yys
->yysemantics
.yysval
, &yys
->yyloc
1593 yys
->yyresolved
= yytrue
;
1600 yyresolveAction (yySemanticOption
* yyopt
, yyGLRStack
* yystack
,
1601 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1603 yyGLRStackItem yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
+ 1];
1606 yynrhs
= yyrhsLength (yyopt
->yyrule
);
1607 YYCHK (yyresolveStates (yyopt
->yystate
, yynrhs
, yystack
]b4_user_args
[));
1608 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
].yystate
.yypred
= yyopt
->yystate
;]b4_location_if([[
1610 /* Set default location. */
1611 yyrhsVals
[YYMAXRHS
+ YYMAXLEFT
- 1].yystate
.yyloc
= yyopt
->yystate
->yyloc
;]])[
1612 return yyuserAction (yyopt
->yyrule
, yynrhs
,
1613 yyrhsVals
+ YYMAXRHS
+ YYMAXLEFT
- 1,
1614 yyvalp
, yylocp
, yystack
]b4_user_args
[);
1619 yyreportTree (yySemanticOption
* yyx
, int yyindent
)
1621 int yynrhs
= yyrhsLength (yyx
->yyrule
);
1624 yyGLRState
* yystates
[YYMAXRHS
];
1625 yyGLRState yyleftmost_state
;
1627 for (yyi
= yynrhs
, yys
= yyx
->yystate
; 0 < yyi
; yyi
-= 1, yys
= yys
->yypred
)
1628 yystates
[yyi
] = yys
;
1631 yyleftmost_state
.yyposn
= 0;
1632 yystates
[0] = &yyleftmost_state
;
1637 if (yyx
->yystate
->yyposn
< yys
->yyposn
+ 1)
1638 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, empty>\n",
1639 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1642 YYFPRINTF (stderr
, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
1643 yyindent
, "", yytokenName (yylhsNonterm (yyx
->yyrule
)),
1644 yyx
->yyrule
, (unsigned long int) (yys
->yyposn
+ 1),
1645 (unsigned long int) yyx
->yystate
->yyposn
);
1646 for (yyi
= 1; yyi
<= yynrhs
; yyi
+= 1)
1648 if (yystates
[yyi
]->yyresolved
)
1650 if (yystates
[yyi
-1]->yyposn
+1 > yystates
[yyi
]->yyposn
)
1651 YYFPRINTF (stderr
, "%*s%s <empty>\n", yyindent
+2, "",
1652 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]));
1654 YYFPRINTF (stderr
, "%*s%s <tokens %lu .. %lu>\n", yyindent
+2, "",
1655 yytokenName (yyrhs
[yyprhs
[yyx
->yyrule
]+yyi
-1]),
1656 (unsigned long int) (yystates
[yyi
- 1]->yyposn
+ 1),
1657 (unsigned long int) yystates
[yyi
]->yyposn
);
1660 yyreportTree (yystates
[yyi
]->yysemantics
.yyfirstVal
, yyindent
+2);
1665 static void yyreportAmbiguity (yySemanticOption
* yyx0
, yySemanticOption
* yyx1
,
1666 yyGLRStack
* yystack
]b4_pure_formals
[)
1667 __attribute__ ((__noreturn__
));
1669 yyreportAmbiguity (yySemanticOption
* yyx0
, yySemanticOption
* yyx1
,
1670 yyGLRStack
* yystack
]b4_pure_formals
[)
1676 YYFPRINTF (stderr
, "Ambiguity detected.\n");
1677 YYFPRINTF (stderr
, "Option 1,\n");
1678 yyreportTree (yyx0
, 2);
1679 YYFPRINTF (stderr
, "\nOption 2,\n");
1680 yyreportTree (yyx1
, 2);
1681 YYFPRINTF (stderr
, "\n");
1683 yyFail (yystack
][]b4_pure_args
[, YY_("syntax is ambiguous"));
1687 /** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
1688 * actions, and return the result. */
1690 yyresolveValue (yySemanticOption
* yyoptionList
, yyGLRStack
* yystack
,
1691 YYSTYPE
* yyvalp
, YYLTYPE
* yylocp
]b4_user_formals
[)
1693 yySemanticOption
* yybest
;
1694 yySemanticOption
** yypp
;
1697 yybest
= yyoptionList
;
1699 for (yypp
= &yyoptionList
->yynext
; *yypp
!= NULL
; )
1701 yySemanticOption
* yyp
= *yypp
;
1703 if (yyidenticalOptions (yybest
, yyp
))
1705 yymergeOptionSets (yybest
, yyp
);
1706 *yypp
= yyp
->yynext
;
1710 switch (yypreference (yybest
, yyp
))
1713 yyreportAmbiguity (yybest
, yyp
, yystack
]b4_pure_args
[);
1725 /* This cannot happen so it is not worth a YYASSERT (yyfalse),
1726 but some compilers complain if the default case is
1730 yypp
= &yyp
->yynext
;
1736 yySemanticOption
* yyp
;
1737 int yyprec
= yydprec
[yybest
->yyrule
];
1738 YYCHK (yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[));
1739 for (yyp
= yybest
->yynext
; yyp
!= NULL
; yyp
= yyp
->yynext
)
1741 if (yyprec
== yydprec
[yyp
->yyrule
])
1745 YYCHK (yyresolveAction (yyp
, yystack
, &yyval1
, &yydummy
]b4_user_args
[));
1746 yyuserMerge (yymerger
[yyp
->yyrule
], yyvalp
, &yyval1
);
1752 return yyresolveAction (yybest
, yystack
, yyvalp
, yylocp
]b4_user_args
[);
1756 yyresolveStack (yyGLRStack
* yystack
]b4_user_formals
[)
1758 if (yystack
->yysplitPoint
!= NULL
)
1763 for (yyn
= 0, yys
= yystack
->yytops
.yystates
[0];
1764 yys
!= yystack
->yysplitPoint
;
1765 yys
= yys
->yypred
, yyn
+= 1)
1767 YYCHK (yyresolveStates (yystack
->yytops
.yystates
[0], yyn
, yystack
1774 yycompressStack (yyGLRStack
* yystack
)
1776 yyGLRState
* yyp
, *yyq
, *yyr
;
1778 if (yystack
->yytops
.yysize
!= 1 || yystack
->yysplitPoint
== NULL
)
1781 for (yyp
= yystack
->yytops
.yystates
[0], yyq
= yyp
->yypred
, yyr
= NULL
;
1782 yyp
!= yystack
->yysplitPoint
;
1783 yyr
= yyp
, yyp
= yyq
, yyq
= yyp
->yypred
)
1786 yystack
->yyspaceLeft
+= yystack
->yynextFree
- yystack
->yyitems
;
1787 yystack
->yynextFree
= ((yyGLRStackItem
*) yystack
->yysplitPoint
) + 1;
1788 yystack
->yyspaceLeft
-= yystack
->yynextFree
- yystack
->yyitems
;
1789 yystack
->yysplitPoint
= NULL
;
1790 yystack
->yylastDeleted
= NULL
;
1794 yystack
->yynextFree
->yystate
= *yyr
;
1796 yystack
->yynextFree
->yystate
.yypred
= & yystack
->yynextFree
[-1].yystate
;
1797 yystack
->yytops
.yystates
[0] = &yystack
->yynextFree
->yystate
;
1798 yystack
->yynextFree
+= 1;
1799 yystack
->yyspaceLeft
-= 1;
1804 yyprocessOneStack (yyGLRStack
* yystack
, size_t yyk
,
1805 size_t yyposn
, YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
1809 const short int* yyconflicts
;
1811 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1813 while (yystack
->yytops
.yystates
[yyk
] != NULL
)
1815 yyStateNum yystate
= yystack
->yytops
.yystates
[yyk
]->yylrState
;
1816 YYDPRINTF ((stderr
, "Stack %lu Entering state %d\n",
1817 (unsigned long int) yyk
, yystate
));
1819 YYASSERT (yystate
!= YYFINAL
);
1821 if (yyisDefaultedState (yystate
))
1823 yyrule
= yydefaultAction (yystate
);
1826 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1827 (unsigned long int) yyk
));
1828 yymarkStackDeleted (yystack
, yyk
);
1831 YYCHK (yyglrReduce (yystack
, yyk
, yyrule
, yyfalse
]b4_user_args
[));
1835 if (*yytokenp
== YYEMPTY
)
1837 YYDPRINTF ((stderr
, "Reading a token: "));
1839 *yytokenp
= YYTRANSLATE (yychar
);
1840 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
1842 yygetLRActions (yystate
, *yytokenp
, &yyaction
, &yyconflicts
);
1844 while (*yyconflicts
!= 0)
1846 size_t yynewStack
= yysplitStack (yystack
, yyk
);
1847 YYDPRINTF ((stderr
, "Splitting off stack %lu from %lu.\n",
1848 (unsigned long int) yynewStack
,
1849 (unsigned long int) yyk
));
1850 YYCHK (yyglrReduce (yystack
, yynewStack
,
1851 *yyconflicts
, yyfalse
]b4_user_args
[));
1852 YYCHK (yyprocessOneStack (yystack
, yynewStack
, yyposn
,
1853 yylvalp
, yyllocp
]b4_pure_args
[));
1857 if (yyisShiftAction (yyaction
))
1859 YYDPRINTF ((stderr
, "On stack %lu, ", (unsigned long int) yyk
));
1860 YY_SYMBOL_PRINT ("shifting", *yytokenp
, yylvalp
, yyllocp
);
1861 yyglrShift (yystack
, yyk
, yyaction
, yyposn
+1,
1863 YYDPRINTF ((stderr
, "Stack %lu now in state #%d\n",
1864 (unsigned long int) yyk
,
1865 yystack
->yytops
.yystates
[yyk
]->yylrState
));
1868 else if (yyisErrorAction (yyaction
))
1870 YYDPRINTF ((stderr
, "Stack %lu dies.\n",
1871 (unsigned long int) yyk
));
1872 yymarkStackDeleted (yystack
, yyk
);
1876 YYCHK (yyglrReduce (yystack
, yyk
, -yyaction
, yyfalse
]b4_user_args
[));
1883 yyreportSyntaxError (yyGLRStack
* yystack
,
1884 YYSTYPE
* yylvalp
, YYLTYPE
* yyllocp
]b4_user_formals
[)
1889 if (yystack
->yyerrState
== 0)
1892 yySymbol
* const yytokenp
= yystack
->yytokenp
;
1894 yyn
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
1895 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1897 size_t yysize0
= yytnamerr (NULL
, yytokenName (*yytokenp
));
1898 size_t yysize
= yysize0
;
1900 yybool yysize_overflow
= yyfalse
;
1902 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1903 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1907 static char const yyunexpected
[] = "syntax error, unexpected %s";
1908 static char const yyexpecting
[] = ", expecting %s";
1909 static char const yyor
[] = " or %s";
1910 char yyformat
[sizeof yyunexpected
1911 + sizeof yyexpecting
- 1
1912 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1913 * (sizeof yyor
- 1))];
1914 char const *yyprefix
= yyexpecting
;
1916 /* Start YYX at -YYN if negative to avoid negative indexes in
1918 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1920 /* Stay within bounds of both yycheck and yytname. */
1921 int yychecklim
= YYLAST
- yyn
;
1922 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1925 yyarg
[0] = yytokenName (*yytokenp
);
1926 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1928 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1929 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1931 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1935 yyformat
[sizeof yyunexpected
- 1] = '\0';
1938 yyarg
[yycount
++] = yytokenName (yyx
);
1939 yysize1
= yysize
+ yytnamerr (NULL
, yytokenName (yyx
));
1940 yysize_overflow
|= yysize1
< yysize
;
1942 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1946 yyf
= YY_(yyformat
);
1947 yysize1
= yysize
+ strlen (yyf
);
1948 yysize_overflow
|= yysize1
< yysize
;
1951 if (!yysize_overflow
)
1952 yymsg
= (char *) YYMALLOC (yysize
);
1958 while ((*yyp
= *yyf
))
1960 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1962 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1971 yyerror (]b4_lyyerror_args
[yymsg
);
1976 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1977 yyMemoryExhausted (yystack
);
1981 #endif /* YYERROR_VERBOSE */
1982 yyerror (]b4_lyyerror_args
[YY_("syntax error"));
1987 /* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
1988 YYLVALP, and YYLLOCP point to the syntactic category, semantic
1989 value, and location of the look-ahead. */
1991 yyrecoverSyntaxError (yyGLRStack
* yystack
,
1993 YYLTYPE
* YYOPTIONAL_LOC (yyllocp
)
1996 yySymbol
* const yytokenp
= yystack
->yytokenp
;
2000 if (yystack
->yyerrState
== 3)
2001 /* We just shifted the error token and (perhaps) took some
2002 reductions. Skip tokens until we can proceed. */
2005 if (*yytokenp
== YYEOF
)
2006 yyFail (yystack
][]b4_lpure_args
[, NULL
);
2007 if (*yytokenp
!= YYEMPTY
)
2009 /* We throw away the lookahead, but the error range
2010 of the shifted error token must take it into account. */
2011 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
2012 yyGLRStackItem yyerror_range
[3];
2013 yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;
2014 yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
2015 YYLLOC_DEFAULT (yys
->yyloc
, yyerror_range
, 2);]])[
2016 yydestruct ("Error: discarding",
2017 *yytokenp
, yylvalp
]b4_location_if([, yyllocp
])[]b4_user_args
[);
2019 YYDPRINTF ((stderr
, "Reading a token: "));
2021 *yytokenp
= YYTRANSLATE (yychar
);
2022 YY_SYMBOL_PRINT ("Next token is", *yytokenp
, yylvalp
, yyllocp
);
2023 yyj
= yypact
[yystack
->yytops
.yystates
[0]->yylrState
];
2024 if (yyis_pact_ninf (yyj
))
2027 if (yyj
< 0 || YYLAST
< yyj
|| yycheck
[yyj
] != *yytokenp
)
2029 if (yydefact
[yystack
->yytops
.yystates
[0]->yylrState
] != 0)
2032 else if (yytable
[yyj
] != 0 && ! yyis_table_ninf (yytable
[yyj
]))
2036 /* Reduce to one stack. */
2037 for (yyk
= 0; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
2038 if (yystack
->yytops
.yystates
[yyk
] != NULL
)
2040 if (yyk
>= yystack
->yytops
.yysize
)
2041 yyFail (yystack
][]b4_lpure_args
[, NULL
);
2042 for (yyk
+= 1; yyk
< yystack
->yytops
.yysize
; yyk
+= 1)
2043 yymarkStackDeleted (yystack
, yyk
);
2044 yyremoveDeletes (yystack
);
2045 yycompressStack (yystack
);
2047 /* Now pop stack until we find a state that shifts the error token. */
2048 yystack
->yyerrState
= 3;
2049 while (yystack
->yytops
.yystates
[0] != NULL
)
2051 yyGLRState
*yys
= yystack
->yytops
.yystates
[0];
2052 yyj
= yypact
[yys
->yylrState
];
2053 if (! yyis_pact_ninf (yyj
))
2056 if (0 <= yyj
&& yyj
<= YYLAST
&& yycheck
[yyj
] == YYTERROR
2057 && yyisShiftAction (yytable
[yyj
]))
2059 /* Shift the error token having adjusted its location. */
2060 YYLTYPE yyerrloc
;]b4_location_if([[
2061 yystack
->yyerror_range
[2].yystate
.yyloc
= *yyllocp
;
2062 YYLLOC_DEFAULT (yyerrloc
, yystack
->yyerror_range
, 2);]])[
2063 YY_SYMBOL_PRINT ("Shifting", yystos
[yytable
[yyj
]],
2064 yylvalp
, &yyerrloc
);
2065 yyglrShift (yystack
, 0, yytable
[yyj
],
2066 yys
->yyposn
, *yylvalp
, &yyerrloc
);
2067 yys
= yystack
->yytops
.yystates
[0];
2071 ]b4_location_if([[ yystack
->yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]])[
2072 yydestroyGLRState ("Error: popping", yys
]b4_user_args
[);
2073 yystack
->yytops
.yystates
[0] = yys
->yypred
;
2074 yystack
->yynextFree
-= 1;
2075 yystack
->yyspaceLeft
+= 1;
2077 if (yystack
->yytops
.yystates
[0] == NULL
)
2078 yyFail (yystack
][]b4_lpure_args
[, NULL
);
2081 #define YYCHK1(YYE) \
2091 goto yyuser_error; \
2095 } while (/*CONSTCOND*/ 0)
2102 ]b4_c_ansi_function_def([yyparse
], [int], b4_parse_param
)[
2113 #define yychar (yystack.yyrawchar)
2116 YYSTYPE
* const yylvalp
= &yylval
;
2117 YYLTYPE
* const yyllocp
= &yylloc
;
2119 YYDPRINTF ((stderr
, "Starting parse\n"));
2122 yylval
= yyval_default
;
2124 #if YYLTYPE_IS_TRIVIAL
2125 yylloc
.first_line
= yylloc
.last_line
= 1;
2126 yylloc
.first_column
= yylloc
.last_column
= 0;
2129 m4_ifdef([b4_initial_action
], [
2130 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
2131 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
2132 /* User initialization code. */
2134 m4_popdef([b4_dollar_dollar
])dnl
2135 m4_popdef([b4_at_dollar
])dnl
2136 /* Line __line__ of glr.c. */
2137 b4_syncline([@oline@
], [@ofile@
])])dnl
2139 if (! yyinitGLRStack (&yystack
, YYINITDEPTH
))
2140 goto yyexhaustedlab
;
2141 switch (YYSETJMP (yystack
.yyexception_buffer
))
2144 case 1: goto yyabortlab
;
2145 case 2: goto yyexhaustedlab
;
2146 default: goto yybuglab
;
2148 yystack
.yytokenp
= &yytoken
;
2149 yyglrShift (&yystack
, 0, 0, 0, yylval
, &yylloc
);
2154 /* For efficiency, we have two loops, the first of which is
2155 specialized to deterministic operation (single stack, no
2156 potential ambiguity). */
2162 const short int* yyconflicts
;
2164 yyStateNum yystate
= yystack
.yytops
.yystates
[0]->yylrState
;
2165 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
2166 if (yystate
== YYFINAL
)
2168 if (yyisDefaultedState (yystate
))
2170 yyrule
= yydefaultAction (yystate
);
2173 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2174 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2177 YYCHK1 (yyglrReduce (&yystack
, 0, yyrule
, yytrue
]b4_user_args
[));
2181 if (yytoken
== YYEMPTY
)
2183 YYDPRINTF ((stderr
, "Reading a token: "));
2185 yytoken
= YYTRANSLATE (yychar
);
2186 YY_SYMBOL_PRINT ("Next token is", yytoken
, yylvalp
, yyllocp
);
2188 yygetLRActions (yystate
, yytoken
, &yyaction
, &yyconflicts
);
2189 if (*yyconflicts
!= 0)
2191 if (yyisShiftAction (yyaction
))
2193 YY_SYMBOL_PRINT ("Shifting", yytoken
, yylvalp
, yyllocp
);
2194 if (yytoken
!= YYEOF
)
2197 yyglrShift (&yystack
, 0, yyaction
, yyposn
, yylval
, yyllocp
);
2198 if (0 < yystack
.yyerrState
)
2199 yystack
.yyerrState
-= 1;
2201 else if (yyisErrorAction (yyaction
))
2203 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2204 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2208 YYCHK1 (yyglrReduce (&yystack
, 0, -yyaction
, yytrue
]b4_user_args
[));
2215 size_t yyn
= yystack
.yytops
.yysize
;
2216 for (yys
= 0; yys
< yyn
; yys
+= 1)
2217 YYCHK1 (yyprocessOneStack (&yystack
, yys
, yyposn
,
2218 yylvalp
, yyllocp
]b4_lpure_args
[));
2221 yyremoveDeletes (&yystack
);
2222 if (yystack
.yytops
.yysize
== 0)
2224 yyundeleteLastStack (&yystack
);
2225 if (yystack
.yytops
.yysize
== 0)
2226 yyFail (&yystack
][]b4_lpure_args
[, YY_("syntax error"));
2227 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2228 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2229 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= *yyllocp
;]])[
2230 yyreportSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2233 else if (yystack
.yytops
.yysize
== 1)
2235 YYCHK1 (yyresolveStack (&yystack
]b4_user_args
[));
2236 YYDPRINTF ((stderr
, "Returning to deterministic operation.\n"));
2237 yycompressStack (&yystack
);
2243 yyrecoverSyntaxError (&yystack
, yylvalp
, yyllocp
]b4_user_args
[);
2244 yyposn
= yystack
.yytops
.yystates
[0]->yyposn
;
2260 yyerror (]b4_lyyerror_args
[YY_("memory exhausted"));
2265 if (yytoken
!= YYEOF
&& yytoken
!= YYEMPTY
)
2266 yydestruct ("Cleanup: discarding lookahead",
2267 yytoken
, yylvalp
]b4_location_if([, yyllocp
])[]b4_user_args
[);
2269 /* If the stack is well-formed, pop the stack until it is empty,
2270 destroying its entries as we go. But free the stack regardless
2271 of whether it is well-formed. */
2272 if (yystack
.yyitems
)
2274 yyGLRState
** yystates
= yystack
.yytops
.yystates
;
2278 yyGLRState
*yys
= yystates
[0];
2279 ]b4_location_if([[ yystack
.yyerror_range
[1].yystate
.yyloc
= yys
->yyloc
;]]
2280 )[ yydestroyGLRState ("Cleanup: popping", yys
]b4_user_args
[);
2281 yystates
[0] = yys
->yypred
;
2282 yystack
.yynextFree
-= 1;
2283 yystack
.yyspaceLeft
+= 1;
2285 yyfreeGLRStack (&yystack
);
2291 /* DEBUGGING ONLY */
2293 static void yypstack (yyGLRStack
* yystack
, size_t yyk
)
2294 __attribute__ ((__unused__
));
2295 static void yypdumpstack (yyGLRStack
* yystack
) __attribute__ ((__unused__
));
2298 yy_yypstack (yyGLRState
* yys
)
2302 yy_yypstack (yys
->yypred
);
2303 fprintf (stderr
, " -> ");
2305 fprintf (stderr
, "%d@@%lu", yys
->yylrState
, (unsigned long int) yys
->yyposn
);
2309 yypstates (yyGLRState
* yyst
)
2312 fprintf (stderr
, "<null>");
2315 fprintf (stderr
, "\n");
2319 yypstack (yyGLRStack
* yystack
, size_t yyk
)
2321 yypstates (yystack
->yytops
.yystates
[yyk
]);
2324 #define YYINDEX(YYX) \
2325 ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
2329 yypdumpstack (yyGLRStack
* yystack
)
2331 yyGLRStackItem
* yyp
;
2333 for (yyp
= yystack
->yyitems
; yyp
< yystack
->yynextFree
; yyp
+= 1)
2335 fprintf (stderr
, "%3lu. ", (unsigned long int) (yyp
- yystack
->yyitems
));
2336 if (*(yybool
*) yyp
)
2338 fprintf (stderr
, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
2339 yyp
->yystate
.yyresolved
, yyp
->yystate
.yylrState
,
2340 (unsigned long int) yyp
->yystate
.yyposn
,
2341 (long int) YYINDEX (yyp
->yystate
.yypred
));
2342 if (! yyp
->yystate
.yyresolved
)
2343 fprintf (stderr
, ", firstVal: %ld",
2344 (long int) YYINDEX (yyp
->yystate
.yysemantics
.yyfirstVal
));
2348 fprintf (stderr
, "Option. rule: %d, state: %ld, next: %ld",
2349 yyp
->yyoption
.yyrule
,
2350 (long int) YYINDEX (yyp
->yyoption
.yystate
),
2351 (long int) YYINDEX (yyp
->yyoption
.yynext
));
2353 fprintf (stderr
, "\n");
2355 fprintf (stderr
, "Tops:");
2356 for (yyi
= 0; yyi
< yystack
->yytops
.yysize
; yyi
+= 1)
2357 fprintf (stderr
, "%lu: %ld; ", (unsigned long int) yyi
,
2358 (long int) YYINDEX (yystack
->yytops
.yystates
[yyi
]));
2359 fprintf (stderr
, "\n");
2365 m4_if(b4_defines_flag
, 0, [],
2366 [@output @output_header_name@
2367 b4_copyright([Skeleton parser
for GLR parsing with Bison
],
2368 [2002, 2003, 2004, 2005])
2370 b4_token_enums(b4_tokens
)
2372 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
2373 m4_ifdef([b4_stype
],
2374 [b4_syncline([b4_stype_line
], [b4_file_name
])
2375 typedef union m4_bregexp(b4_stype
, [^{], [YYSTYPE
])b4_stype YYSTYPE
;
2376 /* Line __line__ of glr.c. */
2377 b4_syncline([@oline@
], [@ofile@
])],
2378 [typedef int YYSTYPE
;])
2379 # define YYSTYPE_IS_DECLARED 1
2380 # define YYSTYPE_IS_TRIVIAL 1
2384 [extern YYSTYPE b4_prefix
[]lval
;])
2386 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
2387 typedef struct YYLTYPE
2398 # define YYLTYPE_IS_DECLARED 1
2399 # define YYLTYPE_IS_TRIVIAL 1
2402 b4_location_if([b4_pure_if([],
2403 [extern YYLTYPE b4_prefix
[]lloc
;])