]>
Commit | Line | Data |
---|---|---|
08af01c2 | 1 | -*- C -*- |
01241d47 | 2 | |
fb8135fa | 3 | # GLR skeleton for Bison |
6e30ede8 | 4 | |
c932d613 | 5 | # Copyright (C) 2002-2012 Free Software Foundation, Inc. |
fb8135fa | 6 | |
f16b0819 | 7 | # This program is free software: you can redistribute it and/or modify |
fb8135fa | 8 | # it under the terms of the GNU General Public License as published by |
f16b0819 | 9 | # the Free Software Foundation, either version 3 of the License, or |
fb8135fa | 10 | # (at your option) any later version. |
f16b0819 | 11 | # |
fb8135fa AD |
12 | # This program is distributed in the hope that it will be useful, |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
f16b0819 | 16 | # |
fb8135fa | 17 | # You should have received a copy of the GNU General Public License |
f16b0819 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
fb8135fa | 19 | |
66d30cd4 | 20 | |
53ab797d AD |
21 | # If we are loaded by glr.cc, do not override c++.m4 definitions by |
22 | # those of c.m4. | |
23 | m4_if(b4_skeleton, ["glr.c"], | |
24 | [m4_include(b4_pkgdatadir/[c.m4])]) | |
7eb8a0bc | 25 | |
66d30cd4 AD |
26 | ## ---------------- ## |
27 | ## Default values. ## | |
28 | ## ---------------- ## | |
29 | ||
30 | # Stack parameters. | |
31 | m4_define_default([b4_stack_depth_max], [10000]) | |
32 | m4_define_default([b4_stack_depth_init], [200]) | |
33 | ||
2a8d363a AD |
34 | |
35 | ||
36 | ## ------------------------ ## | |
37 | ## Pure/impure interfaces. ## | |
38 | ## ------------------------ ## | |
39 | ||
d9df47b6 | 40 | b4_define_flag_if([pure]) |
7e5ef706 PE |
41 | # If glr.cc is including this file and thus has already set b4_pure_flag, |
42 | # do not change the value of b4_pure_flag, and do not record a use of api.pure. | |
d9df47b6 JD |
43 | m4_ifndef([b4_pure_flag], |
44 | [b4_percent_define_default([[api.pure]], [[false]]) | |
45 | m4_define([b4_pure_flag], | |
46 | [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])]) | |
2a8d363a | 47 | |
4b367315 AD |
48 | # b4_user_formals |
49 | # --------------- | |
1989d947 AD |
50 | # The possible parse-params formal arguments preceded by a comma. |
51 | # | |
52 | # This is not shared with yacc.c in c.m4 because GLR relies on ISO C | |
53 | # formal argument declarations. | |
4b367315 AD |
54 | m4_define([b4_user_formals], |
55 | [m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])]) | |
56 | ||
57 | ||
2a8d363a AD |
58 | # b4_lex_param |
59 | # ------------ | |
21964f43 AD |
60 | # Accumule in b4_lex_param all the yylex arguments. |
61 | # Yes, this is quite ugly... | |
62 | m4_define([b4_lex_param], | |
d6cff4dc | 63 | m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl |
327afc7c | 64 | b4_locations_if([, [[YYLTYPE *], [&yylloc]]])])dnl |
21964f43 AD |
65 | m4_ifdef([b4_lex_param], [, ]b4_lex_param))) |
66 | ||
2a8d363a | 67 | |
93724f13 AD |
68 | # b4_yyerror_args |
69 | # --------------- | |
1989d947 AD |
70 | # Optional effective arguments passed to yyerror: user args plus yylloc, and |
71 | # a trailing comma. | |
93724f13 | 72 | m4_define([b4_yyerror_args], |
327afc7c | 73 | [b4_pure_if([b4_locations_if([yylocp, ])])dnl |
93724f13 AD |
74 | m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) |
75 | ||
76 | ||
77 | # b4_lyyerror_args | |
78 | # ---------------- | |
742e4900 | 79 | # Same as above, but on the lookahead, hence &yylloc instead of yylocp. |
93724f13 | 80 | m4_define([b4_lyyerror_args], |
327afc7c | 81 | [b4_pure_if([b4_locations_if([&yylloc, ])])dnl |
93724f13 AD |
82 | m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) |
83 | ||
84 | ||
2a8d363a AD |
85 | # b4_pure_args |
86 | # ------------ | |
1989d947 | 87 | # Same as b4_yyerror_args, but with a leading comma. |
2a8d363a | 88 | m4_define([b4_pure_args], |
327afc7c | 89 | [b4_pure_if([b4_locations_if([, yylocp])])[]b4_user_args]) |
2a8d363a AD |
90 | |
91 | ||
2a8d363a AD |
92 | # b4_lpure_args |
93 | # ------------- | |
742e4900 | 94 | # Same as above, but on the lookahead, hence &yylloc instead of yylocp. |
2a8d363a | 95 | m4_define([b4_lpure_args], |
327afc7c | 96 | [b4_pure_if([b4_locations_if([, &yylloc])])[]b4_user_args]) |
0245f82d | 97 | |
66d30cd4 | 98 | |
769a8ef9 | 99 | |
1989d947 AD |
100 | # b4_pure_formals |
101 | # --------------- | |
769a8ef9 | 102 | # Arguments passed to yyerror: user formals plus yylocp with leading comma. |
1989d947 | 103 | m4_define([b4_pure_formals], |
327afc7c | 104 | [b4_pure_if([b4_locations_if([, YYLTYPE *yylocp])])[]b4_user_formals]) |
1989d947 AD |
105 | |
106 | ||
769a8ef9 AD |
107 | # b4_locuser_formals(LOC = yylocp) |
108 | # -------------------------------- | |
109 | m4_define([b4_locuser_formals], | |
110 | [b4_locations_if([, YYLTYPE *m4_default([$1], [yylocp])])[]b4_user_formals]) | |
111 | ||
112 | ||
113 | # b4_locuser_args(LOC = yylocp) | |
114 | # ----------------------------- | |
115 | m4_define([b4_locuser_args], | |
116 | [b4_locations_if([, m4_default([$1], [yylocp])])[]b4_user_args]) | |
117 | ||
118 | ||
119 | ||
66d30cd4 AD |
120 | ## ----------------- ## |
121 | ## Semantic Values. ## | |
122 | ## ----------------- ## | |
123 | ||
124 | ||
01241d47 PH |
125 | # b4_lhs_value([TYPE]) |
126 | # -------------------- | |
127 | # Expansion of $<TYPE>$. | |
128 | m4_define([b4_lhs_value], | |
bc82c5a5 | 129 | [((*yyvalp)[]m4_ifval([$1], [.$1]))]) |
01241d47 PH |
130 | |
131 | ||
132 | # b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) | |
133 | # -------------------------------------- | |
134 | # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH | |
135 | # symbols on RHS. | |
136 | m4_define([b4_rhs_value], | |
6de5398d | 137 | [(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))]) |
01241d47 PH |
138 | |
139 | ||
140 | ||
141 | ## ----------- ## | |
142 | ## Locations. ## | |
143 | ## ----------- ## | |
144 | ||
01241d47 PH |
145 | # b4_lhs_location() |
146 | # ----------------- | |
147 | # Expansion of @$. | |
148 | m4_define([b4_lhs_location], | |
149 | [(*yylocp)]) | |
150 | ||
151 | ||
152 | # b4_rhs_location(RULE-LENGTH, NUM) | |
153 | # --------------------------------- | |
154 | # Expansion of @NUM, where the current rule has RULE-LENGTH symbols | |
155 | # on RHS. | |
156 | m4_define([b4_rhs_location], | |
6de5398d | 157 | [(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)]) |
01241d47 | 158 | |
5059b5c8 | 159 | |
5059b5c8 | 160 | ## -------------- ## |
e9807a79 | 161 | ## Declarations. ## |
5059b5c8 AD |
162 | ## -------------- ## |
163 | ||
e9807a79 AD |
164 | # b4_shared_declarations |
165 | # ---------------------- | |
166 | # Declaration that might either go into the header (if --defines) | |
167 | # or open coded in the parser body. | |
5059b5c8 | 168 | m4_define([b4_shared_declarations], |
56ca3d8f AD |
169 | [b4_declare_yydebug[ |
170 | ]b4_percent_code_get([[requires]])[ | |
c0828abf AD |
171 | ]b4_token_enums(b4_tokens)[ |
172 | ]b4_declare_yylstype[ | |
c3e9f08f | 173 | ]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[ |
a4e25e1d | 174 | ]b4_percent_code_get([[provides]])[]dnl |
9bc0dd67 | 175 | ]) |
5059b5c8 | 176 | |
e9807a79 AD |
177 | |
178 | ## -------------- ## | |
179 | ## Output files. ## | |
180 | ## -------------- ## | |
181 | ||
1c7ec959 | 182 | b4_output_begin([b4_parser_file_name]) |
e9807a79 | 183 | b4_copyright([Skeleton implementation for Bison GLR parsers in C], |
1c7ec959 AD |
184 | [2002-2012])[ |
185 | ||
e9807a79 AD |
186 | /* C GLR parser skeleton written by Paul Hilfinger. */ |
187 | ||
188 | ]b4_identification | |
189 | ||
6e2d7b09 | 190 | b4_percent_code_get([[top]])[ |
4b3847c3 AD |
191 | ]m4_if(b4_api_prefix, [yy], [], |
192 | [[/* Substitute the type names. */ | |
9104636b AD |
193 | #define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[ |
194 | #define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[ | |
6e2d7b09 AD |
195 | ]m4_if(b4_prefix, [yy], [], |
196 | [[/* Substitute the variable and function names. */ | |
197 | #define yyparse ]b4_prefix[parse | |
198 | #define yylex ]b4_prefix[lex | |
199 | #define yyerror ]b4_prefix[error | |
200 | #define yylval ]b4_prefix[lval | |
201 | #define yychar ]b4_prefix[char | |
202 | #define yydebug ]b4_prefix[debug | |
203 | #define yynerrs ]b4_prefix[nerrs]b4_locations_if([[ | |
204 | #define yylloc ]b4_prefix[lloc]])])[ | |
e9807a79 AD |
205 | |
206 | /* Copy the first part of user declarations. */ | |
207 | ]b4_user_pre_prologue[ | |
208 | ||
209 | ]b4_null_define[ | |
210 | ||
211 | ]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], | |
0f11eec2 | 212 | [b4_shared_declarations])[ |
5059b5c8 | 213 | |
5059b5c8 AD |
214 | /* Enabling verbose error messages. */ |
215 | #ifdef YYERROR_VERBOSE | |
216 | # undef YYERROR_VERBOSE | |
217 | # define YYERROR_VERBOSE 1 | |
218 | #else | |
327afc7c | 219 | # define YYERROR_VERBOSE ]b4_error_verbose_flag[ |
5059b5c8 AD |
220 | #endif |
221 | ||
288006a2 | 222 | /* Default (constant) value used for initialization for null |
a68b1f23 AD |
223 | right-hand sides. Unlike the standard yacc.c template, here we set |
224 | the default value of $$ to a zeroed-out value. Since the default | |
225 | value is undefined, this behavior is technically correct. */ | |
a1d1ab50 AD |
226 | static YYSTYPE yyval_default;]b4_locations_if([[ |
227 | static YYLTYPE yyloc_default][]b4_yyloc_default;])[ | |
01241d47 PH |
228 | |
229 | /* Copy the second part of user declarations. */ | |
8e0a5e9e | 230 | ]b4_user_post_prologue |
a4e25e1d | 231 | b4_percent_code_get[]dnl |
01241d47 | 232 | |
8e0a5e9e | 233 | [#include <stdio.h> |
63cb01d6 PE |
234 | #include <stdlib.h> |
235 | #include <string.h> | |
63cb01d6 | 236 | |
30757c8c | 237 | #ifndef YY_ |
06caf0e1 | 238 | # if defined YYENABLE_NLS && YYENABLE_NLS |
30757c8c PE |
239 | # if ENABLE_NLS |
240 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ | |
39845e8e | 241 | # define YY_(Msgid) dgettext ("bison-runtime", Msgid) |
30757c8c PE |
242 | # endif |
243 | # endif | |
244 | # ifndef YY_ | |
39845e8e | 245 | # define YY_(Msgid) Msgid |
30757c8c PE |
246 | # endif |
247 | #endif | |
248 | ||
2a4647a3 | 249 | /* Suppress unused-variable warnings by "using" E. */ |
02650b7f | 250 | #if ! defined lint || defined __GNUC__ |
39845e8e | 251 | # define YYUSE(E) ((void) (E)) |
613d8952 | 252 | #else |
39845e8e | 253 | # define YYUSE(E) /* empty */ |
12ce2df6 PE |
254 | #endif |
255 | ||
256 | /* Identity function, used to suppress warnings about constant conditions. */ | |
257 | #ifndef lint | |
39845e8e | 258 | # define YYID(N) (N) |
12ce2df6 PE |
259 | #else |
260 | ]b4_c_function_def([YYID], [static int], [[int i], [i]])[ | |
261 | { | |
262 | return i; | |
263 | } | |
613d8952 | 264 | #endif |
2a4647a3 | 265 | |
a525b568 PE |
266 | #ifndef YYFREE |
267 | # define YYFREE free | |
268 | #endif | |
269 | #ifndef YYMALLOC | |
270 | # define YYMALLOC malloc | |
271 | #endif | |
272 | #ifndef YYREALLOC | |
273 | # define YYREALLOC realloc | |
274 | #endif | |
275 | ||
63cb01d6 PE |
276 | #define YYSIZEMAX ((size_t) -1) |
277 | ||
f7c398aa PE |
278 | #ifdef __cplusplus |
279 | typedef bool yybool; | |
280 | #else | |
281 | typedef unsigned char yybool; | |
01241d47 | 282 | #endif |
f7c398aa PE |
283 | #define yytrue 1 |
284 | #define yyfalse 0 | |
01241d47 | 285 | |
c89b4c03 PE |
286 | #ifndef YYSETJMP |
287 | # include <setjmp.h> | |
288 | # define YYJMP_BUF jmp_buf | |
39845e8e | 289 | # define YYSETJMP(Env) setjmp (Env) |
19d9b607 AD |
290 | // Pacify clang. |
291 | # define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0)) | |
c89b4c03 PE |
292 | #endif |
293 | ||
1154cced AD |
294 | /*-----------------. |
295 | | GCC extensions. | | |
296 | `-----------------*/ | |
297 | ||
298 | #ifndef __attribute__ | |
299 | /* This feature is available in gcc versions 2.5 and later. */ | |
02650b7f | 300 | # if (! defined __GNUC__ || __GNUC__ < 2 \ |
ef51bfa7 | 301 | || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) |
1154cced AD |
302 | # define __attribute__(Spec) /* empty */ |
303 | # endif | |
304 | #endif | |
305 | ||
64c4fd52 | 306 | #ifndef YYASSERT |
39845e8e | 307 | # define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0))) |
64c4fd52 PE |
308 | #endif |
309 | ||
9d9b8b70 | 310 | /* YYFINAL -- State number of the termination state. */ |
7db2ed2d | 311 | #define YYFINAL ]b4_final_state_number[ |
39912f52 | 312 | /* YYLAST -- Last index in YYTABLE. */ |
01241d47 PH |
313 | #define YYLAST ]b4_last[ |
314 | ||
9d9b8b70 | 315 | /* YYNTOKENS -- Number of terminals. */ |
7db2ed2d | 316 | #define YYNTOKENS ]b4_tokens_number[ |
9d9b8b70 | 317 | /* YYNNTS -- Number of nonterminals. */ |
7db2ed2d | 318 | #define YYNNTS ]b4_nterms_number[ |
9d9b8b70 | 319 | /* YYNRULES -- Number of rules. */ |
7db2ed2d | 320 | #define YYNRULES ]b4_rules_number[ |
9d9b8b70 | 321 | /* YYNRULES -- Number of states. */ |
7db2ed2d | 322 | #define YYNSTATES ]b4_states_number[ |
9d9b8b70 | 323 | /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */ |
01241d47 | 324 | #define YYMAXRHS ]b4_r2_max[ |
25005f6a | 325 | /* YYMAXLEFT -- Maximum number of symbols to the left of a handle |
9d9b8b70 | 326 | accessed by $0, $-1, etc., in any rule. */ |
25005f6a | 327 | #define YYMAXLEFT ]b4_max_left_semantic_context[ |
01241d47 PH |
328 | |
329 | /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */ | |
330 | #define YYUNDEFTOK ]b4_undef_token_number[ | |
331 | #define YYMAXUTOK ]b4_user_token_number_max[ | |
332 | ||
7020e5f0 | 333 | #define YYTRANSLATE(YYX) \ |
cf806753 | 334 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
01241d47 PH |
335 | |
336 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ | |
a762e609 | 337 | static const ]b4_int_type_for([b4_translate])[ yytranslate[] = |
01241d47 PH |
338 | { |
339 | ]b4_translate[ | |
340 | }; | |
341 | ||
5f108727 | 342 | #if ]b4_api_PREFIX[DEBUG |
01241d47 PH |
343 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
344 | YYRHS. */ | |
a762e609 | 345 | static const ]b4_int_type_for([b4_prhs])[ yyprhs[] = |
01241d47 PH |
346 | { |
347 | ]b4_prhs[ | |
348 | }; | |
349 | ||
9d9b8b70 | 350 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
a762e609 | 351 | static const ]b4_int_type_for([b4_rhs])[ yyrhs[] = |
01241d47 PH |
352 | { |
353 | ]b4_rhs[ | |
354 | }; | |
355 | ||
356 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ | |
a762e609 | 357 | static const ]b4_int_type_for([b4_rline])[ yyrline[] = |
01241d47 PH |
358 | { |
359 | ]b4_rline[ | |
360 | }; | |
361 | #endif | |
362 | ||
5f108727 | 363 | #if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[ |
9e0876fb | 364 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
9d9b8b70 | 365 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
01241d47 PH |
366 | static const char *const yytname[] = |
367 | { | |
368 | ]b4_tname[ | |
369 | }; | |
01241d47 PH |
370 | #endif |
371 | ||
372 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | |
a762e609 | 373 | static const ]b4_int_type_for([b4_r1])[ yyr1[] = |
01241d47 PH |
374 | { |
375 | ]b4_r1[ | |
376 | }; | |
377 | ||
378 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ | |
a762e609 | 379 | static const ]b4_int_type_for([b4_r2])[ yyr2[] = |
01241d47 PH |
380 | { |
381 | ]b4_r2[ | |
382 | }; | |
383 | ||
9d9b8b70 | 384 | /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */ |
a762e609 | 385 | static const ]b4_int_type_for([b4_dprec])[ yydprec[] = |
01241d47 PH |
386 | { |
387 | ]b4_dprec[ | |
388 | }; | |
389 | ||
9d9b8b70 | 390 | /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */ |
a762e609 | 391 | static const ]b4_int_type_for([b4_merger])[ yymerger[] = |
01241d47 PH |
392 | { |
393 | ]b4_merger[ | |
394 | }; | |
395 | ||
620b5727 JD |
396 | /* YYDEFACT[S] -- default reduction number in state S. Performed when |
397 | YYTABLE doesn't specify something else to do. Zero means the default | |
398 | is an error. */ | |
a762e609 | 399 | static const ]b4_int_type_for([b4_defact])[ yydefact[] = |
01241d47 PH |
400 | { |
401 | ]b4_defact[ | |
402 | }; | |
403 | ||
9d9b8b70 | 404 | /* YYPDEFGOTO[NTERM-NUM]. */ |
a762e609 | 405 | static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] = |
01241d47 PH |
406 | { |
407 | ]b4_defgoto[ | |
408 | }; | |
409 | ||
410 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | |
411 | STATE-NUM. */ | |
12b0043a | 412 | #define YYPACT_NINF ]b4_pact_ninf[ |
a762e609 | 413 | static const ]b4_int_type_for([b4_pact])[ yypact[] = |
01241d47 PH |
414 | { |
415 | ]b4_pact[ | |
416 | }; | |
417 | ||
418 | /* YYPGOTO[NTERM-NUM]. */ | |
a762e609 | 419 | static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] = |
01241d47 PH |
420 | { |
421 | ]b4_pgoto[ | |
422 | }; | |
423 | ||
424 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | |
425 | positive, shift that token. If negative, reduce the rule which | |
e4bcae3c | 426 | number is the opposite. If YYTABLE_NINF, syntax error. */ |
12b0043a | 427 | #define YYTABLE_NINF ]b4_table_ninf[ |
a762e609 | 428 | static const ]b4_int_type_for([b4_table])[ yytable[] = |
01241d47 PH |
429 | { |
430 | ]b4_table[ | |
431 | }; | |
432 | ||
ea99527d AD |
433 | /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of |
434 | list of conflicting reductions corresponding to action entry for | |
435 | state STATE-NUM in yytable. 0 means no conflicts. The list in | |
436 | yyconfl is terminated by a rule number of 0. */ | |
a762e609 | 437 | static const ]b4_int_type_for([b4_conflict_list_heads])[ yyconflp[] = |
01241d47 PH |
438 | { |
439 | ]b4_conflict_list_heads[ | |
440 | }; | |
441 | ||
ea99527d AD |
442 | /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by |
443 | 0, pointed into by YYCONFLP. */ | |
a762e609 | 444 | ]dnl Do not use b4_int_type_for here, since there are places where |
779e7ceb | 445 | dnl pointers onto yyconfl are taken, which type is "short int *". |
a762e609 | 446 | dnl We probably ought to introduce a type for confl. |
779e7ceb | 447 | [static const short int yyconfl[] = |
01241d47 PH |
448 | { |
449 | ]b4_conflicting_rules[ | |
450 | }; | |
451 | ||
a762e609 | 452 | static const ]b4_int_type_for([b4_check])[ yycheck[] = |
01241d47 PH |
453 | { |
454 | ]b4_check[ | |
455 | }; | |
456 | ||
7bd6c77e AD |
457 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
458 | symbol of state STATE-NUM. */ | |
459 | static const ]b4_int_type_for([b4_stos])[ yystos[] = | |
460 | { | |
461 | ]b4_stos[ | |
462 | }; | |
463 | ||
2a8d363a | 464 | /* Error token number */ |
01241d47 PH |
465 | #define YYTERROR 1 |
466 | ||
327afc7c | 467 | ]b4_locations_if([[ |
426903aa AD |
468 | ]b4_yylloc_default_define[ |
469 | # define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc) | |
3237f570 AD |
470 | ]])[ |
471 | ]b4_yy_location_print_define[ | |
3fc16193 | 472 | |
01241d47 | 473 | /* YYLEX -- calling `yylex' with the right arguments. */ |
21964f43 | 474 | #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[ |
01241d47 PH |
475 | |
476 | ]b4_pure_if( | |
477 | [ | |
01241d47 | 478 | #undef yynerrs |
3e7a2cd9 | 479 | #define yynerrs (yystackp->yyerrcnt) |
01241d47 | 480 | #undef yychar |
d6cff4dc AD |
481 | #define yychar (yystackp->yyrawchar) |
482 | #undef yylval | |
483 | #define yylval (yystackp->yyval) | |
484 | #undef yylloc | |
485 | #define yylloc (yystackp->yyloc) | |
486 | m4_if(b4_prefix[], [yy], [], | |
487 | [#define b4_prefix[]nerrs yynerrs | |
488 | #define b4_prefix[]char yychar | |
489 | #define b4_prefix[]lval yylval | |
490 | #define b4_prefix[]lloc yylloc])], | |
d834eca0 AD |
491 | [YYSTYPE yylval;]b4_locations_if([[ |
492 | YYLTYPE yylloc;]])[ | |
01241d47 PH |
493 | |
494 | int yynerrs; | |
495 | int yychar;])[ | |
496 | ||
497 | static const int YYEOF = 0; | |
498 | static const int YYEMPTY = -2; | |
499 | ||
500 | typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG; | |
501 | ||
7020e5f0 AD |
502 | #define YYCHK(YYE) \ |
503 | do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \ | |
12ce2df6 | 504 | while (YYID (0)) |
01241d47 | 505 | |
5f108727 | 506 | #if ]b4_api_PREFIX[DEBUG |
01241d47 | 507 | |
02650b7f | 508 | # ifndef YYFPRINTF |
01241d47 | 509 | # define YYFPRINTF fprintf |
02650b7f | 510 | # endif |
01241d47 | 511 | |
7020e5f0 AD |
512 | # define YYDPRINTF(Args) \ |
513 | do { \ | |
514 | if (yydebug) \ | |
515 | YYFPRINTF Args; \ | |
12ce2df6 | 516 | } while (YYID (0)) |
7bd6c77e | 517 | |
a0af42fc | 518 | ]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[ |
7bd6c77e | 519 | |
769a8ef9 AD |
520 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
521 | do { \ | |
522 | if (yydebug) \ | |
523 | { \ | |
524 | YYFPRINTF (stderr, "%s ", Title); \ | |
525 | yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[); \ | |
526 | YYFPRINTF (stderr, "\n"); \ | |
527 | } \ | |
12ce2df6 | 528 | } while (YYID (0)) |
9c1e26bd | 529 | |
01241d47 PH |
530 | /* Nonzero means print parse trace. It is left uninitialized so that |
531 | multiple parsers can coexist. */ | |
532 | int yydebug; | |
7bd6c77e | 533 | |
5f108727 | 534 | #else /* !]b4_api_PREFIX[DEBUG */ |
7bd6c77e | 535 | |
ee16363f | 536 | # define YYDPRINTF(Args) |
284acc8b | 537 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
7bd6c77e | 538 | |
5f108727 | 539 | #endif /* !]b4_api_PREFIX[DEBUG */ |
01241d47 PH |
540 | |
541 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | |
7020e5f0 | 542 | #ifndef YYINITDEPTH |
66d30cd4 | 543 | # define YYINITDEPTH ]b4_stack_depth_init[ |
01241d47 PH |
544 | #endif |
545 | ||
546 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only | |
547 | if the built-in stack extension method is used). | |
548 | ||
549 | Do not make this value too large; the results are undefined if | |
fb8135fa | 550 | SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem) |
01241d47 PH |
551 | evaluated with infinite-precision integer arithmetic. */ |
552 | ||
01241d47 | 553 | #ifndef YYMAXDEPTH |
66d30cd4 | 554 | # define YYMAXDEPTH ]b4_stack_depth_max[ |
01241d47 PH |
555 | #endif |
556 | ||
557 | /* Minimum number of free items on the stack allowed after an | |
fb8135fa | 558 | allocation. This is to allow allocation and initialization |
63cb01d6 | 559 | to be completed by functions that call yyexpandGLRStack before the |
fb8135fa | 560 | stack is expanded, thus insuring that all necessary pointers get |
9d9b8b70 | 561 | properly redirected to new data. */ |
01241d47 PH |
562 | #define YYHEADROOM 2 |
563 | ||
e2688cd9 | 564 | #ifndef YYSTACKEXPANDABLE |
02650b7f | 565 | # if (! defined __cplusplus \ |
9104636b AD |
566 | || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \ |
567 | && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)) | |
e2688cd9 PE |
568 | # define YYSTACKEXPANDABLE 1 |
569 | # else | |
570 | # define YYSTACKEXPANDABLE 0 | |
571 | # endif | |
01241d47 PH |
572 | #endif |
573 | ||
02998094 | 574 | #if YYSTACKEXPANDABLE |
7020e5f0 AD |
575 | # define YY_RESERVE_GLRSTACK(Yystack) \ |
576 | do { \ | |
577 | if (Yystack->yyspaceLeft < YYHEADROOM) \ | |
578 | yyexpandGLRStack (Yystack); \ | |
12ce2df6 | 579 | } while (YYID (0)) |
02998094 | 580 | #else |
7020e5f0 AD |
581 | # define YY_RESERVE_GLRSTACK(Yystack) \ |
582 | do { \ | |
583 | if (Yystack->yyspaceLeft < YYHEADROOM) \ | |
584 | yyMemoryExhausted (Yystack); \ | |
12ce2df6 | 585 | } while (YYID (0)) |
02998094 AD |
586 | #endif |
587 | ||
588 | ||
63cb01d6 PE |
589 | #if YYERROR_VERBOSE |
590 | ||
591 | # ifndef yystpcpy | |
02650b7f | 592 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE |
63cb01d6 PE |
593 | # define yystpcpy stpcpy |
594 | # else | |
595 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | |
596 | YYDEST. */ | |
597 | static char * | |
598 | yystpcpy (char *yydest, const char *yysrc) | |
599 | { | |
600 | char *yyd = yydest; | |
601 | const char *yys = yysrc; | |
602 | ||
603 | while ((*yyd++ = *yys++) != '\0') | |
604 | continue; | |
605 | ||
606 | return yyd - 1; | |
607 | } | |
608 | # endif | |
609 | # endif | |
610 | ||
9e0876fb PE |
611 | # ifndef yytnamerr |
612 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary | |
613 | quotes and backslashes, so that it's suitable for yyerror. The | |
614 | heuristic is that double-quoting is unnecessary unless the string | |
615 | contains an apostrophe, a comma, or backslash (other than | |
616 | backslash-backslash). YYSTR is taken from yytname. If YYRES is | |
617 | null, do not copy; instead, return the length of what the result | |
618 | would have been. */ | |
619 | static size_t | |
620 | yytnamerr (char *yyres, const char *yystr) | |
621 | { | |
622 | if (*yystr == '"') | |
623 | { | |
624 | size_t yyn = 0; | |
625 | char const *yyp = yystr; | |
626 | ||
627 | for (;;) | |
7020e5f0 AD |
628 | switch (*++yyp) |
629 | { | |
630 | case '\'': | |
631 | case ',': | |
632 | goto do_not_strip_quotes; | |
633 | ||
634 | case '\\': | |
635 | if (*++yyp != '\\') | |
636 | goto do_not_strip_quotes; | |
637 | /* Fall through. */ | |
638 | default: | |
639 | if (yyres) | |
640 | yyres[yyn] = *yyp; | |
641 | yyn++; | |
642 | break; | |
643 | ||
644 | case '"': | |
645 | if (yyres) | |
646 | yyres[yyn] = '\0'; | |
647 | return yyn; | |
648 | } | |
9e0876fb PE |
649 | do_not_strip_quotes: ; |
650 | } | |
651 | ||
652 | if (! yyres) | |
653 | return strlen (yystr); | |
654 | ||
655 | return yystpcpy (yyres, yystr) - yyres; | |
656 | } | |
657 | # endif | |
658 | ||
63cb01d6 PE |
659 | #endif /* !YYERROR_VERBOSE */ |
660 | ||
01241d47 PH |
661 | /** State numbers, as in LALR(1) machine */ |
662 | typedef int yyStateNum; | |
663 | ||
664 | /** Rule numbers, as in LALR(1) machine */ | |
665 | typedef int yyRuleNum; | |
666 | ||
667 | /** Grammar symbol */ | |
779e7ceb | 668 | typedef short int yySymbol; |
01241d47 PH |
669 | |
670 | /** Item references, as in LALR(1) machine */ | |
779e7ceb | 671 | typedef short int yyItemNum; |
01241d47 PH |
672 | |
673 | typedef struct yyGLRState yyGLRState; | |
3e7a2cd9 | 674 | typedef struct yyGLRStateSet yyGLRStateSet; |
01241d47 PH |
675 | typedef struct yySemanticOption yySemanticOption; |
676 | typedef union yyGLRStackItem yyGLRStackItem; | |
677 | typedef struct yyGLRStack yyGLRStack; | |
01241d47 PH |
678 | |
679 | struct yyGLRState { | |
9d9b8b70 | 680 | /** Type tag: always true. */ |
f7c398aa | 681 | yybool yyisState; |
9d9b8b70 PE |
682 | /** Type tag for yysemantics. If true, yysval applies, otherwise |
683 | * yyfirstVal applies. */ | |
f7c398aa | 684 | yybool yyresolved; |
9d9b8b70 | 685 | /** Number of corresponding LALR(1) machine state. */ |
01241d47 | 686 | yyStateNum yylrState; |
5e6f62f2 | 687 | /** Preceding state in this stack */ |
01241d47 | 688 | yyGLRState* yypred; |
5e6f62f2 | 689 | /** Source position of the first token produced by my symbol */ |
01241d47 PH |
690 | size_t yyposn; |
691 | union { | |
5e6f62f2 | 692 | /** First in a chain of alternative reductions producing the |
010f91c3 | 693 | * non-terminal corresponding to this state, threaded through |
9d9b8b70 | 694 | * yynext. */ |
01241d47 | 695 | yySemanticOption* yyfirstVal; |
9d9b8b70 | 696 | /** Semantic value for this state. */ |
01241d47 | 697 | YYSTYPE yysval; |
d834eca0 | 698 | } yysemantics;]b4_locations_if([[ |
9d9b8b70 | 699 | /** Source location for this state. */ |
d834eca0 | 700 | YYLTYPE yyloc;]])[ |
01241d47 PH |
701 | }; |
702 | ||
703 | struct yyGLRStateSet { | |
704 | yyGLRState** yystates; | |
b7691f15 | 705 | /** During nondeterministic operation, yylookaheadNeeds tracks which |
bf70fa87 | 706 | * stacks have actually needed the current lookahead. During deterministic |
b7691f15 | 707 | * operation, yylookaheadNeeds[0] is not maintained since it would merely |
bf70fa87 | 708 | * duplicate yychar != YYEMPTY. */ |
b7691f15 | 709 | yybool* yylookaheadNeeds; |
01241d47 PH |
710 | size_t yysize, yycapacity; |
711 | }; | |
712 | ||
713 | struct yySemanticOption { | |
9d9b8b70 | 714 | /** Type tag: always false. */ |
f7c398aa | 715 | yybool yyisState; |
5e6f62f2 | 716 | /** Rule number for this reduction */ |
01241d47 | 717 | yyRuleNum yyrule; |
9d9b8b70 | 718 | /** The last RHS state in the list of states to be reduced. */ |
01241d47 | 719 | yyGLRState* yystate; |
bf70fa87 JD |
720 | /** The lookahead for this reduction. */ |
721 | int yyrawchar; | |
d834eca0 AD |
722 | YYSTYPE yyval;]b4_locations_if([[ |
723 | YYLTYPE yyloc;]])[ | |
9d9b8b70 PE |
724 | /** Next sibling in chain of options. To facilitate merging, |
725 | * options are chained in decreasing order by address. */ | |
01241d47 PH |
726 | yySemanticOption* yynext; |
727 | }; | |
728 | ||
9d9b8b70 PE |
729 | /** Type of the items in the GLR stack. The yyisState field |
730 | * indicates which item of the union is valid. */ | |
01241d47 PH |
731 | union yyGLRStackItem { |
732 | yyGLRState yystate; | |
733 | yySemanticOption yyoption; | |
734 | }; | |
735 | ||
736 | struct yyGLRStack { | |
01241d47 | 737 | int yyerrState; |
327afc7c | 738 | ]b4_locations_if([[ /* To compute the location of the error token. */ |
63d72da7 | 739 | yyGLRStackItem yyerror_range[3];]])[ |
01241d47 PH |
740 | ]b4_pure_if( |
741 | [ | |
742 | int yyerrcnt; | |
743 | int yyrawchar; | |
d834eca0 AD |
744 | YYSTYPE yyval;]b4_locations_if([[ |
745 | YYLTYPE yyloc;]])[ | |
01241d47 | 746 | ])[ |
c89b4c03 | 747 | YYJMP_BUF yyexception_buffer; |
01241d47 PH |
748 | yyGLRStackItem* yyitems; |
749 | yyGLRStackItem* yynextFree; | |
63cb01d6 | 750 | size_t yyspaceLeft; |
01241d47 PH |
751 | yyGLRState* yysplitPoint; |
752 | yyGLRState* yylastDeleted; | |
753 | yyGLRStateSet yytops; | |
754 | }; | |
755 | ||
b2741627 | 756 | #if YYSTACKEXPANDABLE |
3e7a2cd9 | 757 | static void yyexpandGLRStack (yyGLRStack* yystackp); |
b2741627 | 758 | #endif |
01241d47 | 759 | |
3e7a2cd9 | 760 | static void yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg) |
135bc829 | 761 | __attribute__ ((__noreturn__)); |
01241d47 | 762 | static void |
3e7a2cd9 | 763 | yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg) |
01241d47 | 764 | { |
ef51bfa7 | 765 | if (yymsg != YY_NULL) |
fd2df2ed | 766 | yyerror (]b4_yyerror_args[yymsg); |
3e7a2cd9 | 767 | YYLONGJMP (yystackp->yyexception_buffer, 1); |
01241d47 PH |
768 | } |
769 | ||
3e7a2cd9 | 770 | static void yyMemoryExhausted (yyGLRStack* yystackp) |
135bc829 | 771 | __attribute__ ((__noreturn__)); |
63cb01d6 | 772 | static void |
3e7a2cd9 | 773 | yyMemoryExhausted (yyGLRStack* yystackp) |
63cb01d6 | 774 | { |
3e7a2cd9 | 775 | YYLONGJMP (yystackp->yyexception_buffer, 2); |
63cb01d6 PE |
776 | } |
777 | ||
5f108727 | 778 | #if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE |
63cb01d6 | 779 | /** A printable representation of TOKEN. */ |
fb8135fa AD |
780 | static inline const char* |
781 | yytokenName (yySymbol yytoken) | |
01241d47 | 782 | { |
d0d5aa64 PE |
783 | if (yytoken == YYEMPTY) |
784 | return ""; | |
785 | ||
01241d47 PH |
786 | return yytname[yytoken]; |
787 | } | |
788 | #endif | |
789 | ||
f868dc04 PH |
790 | /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting |
791 | * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred | |
9d9b8b70 | 792 | * containing the pointer to the next state in the chain. */ |
135bc829 | 793 | static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__)); |
6a84279c PE |
794 | static void |
795 | yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1) | |
f868dc04 | 796 | { |
f868dc04 | 797 | int i; |
aebb55eb | 798 | yyGLRState *s = yyvsp[yylow0].yystate.yypred; |
f868dc04 PH |
799 | for (i = yylow0-1; i >= yylow1; i -= 1) |
800 | { | |
64c4fd52 | 801 | YYASSERT (s->yyresolved); |
f868dc04 | 802 | yyvsp[i].yystate.yyresolved = yytrue; |
d834eca0 AD |
803 | yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;]b4_locations_if([[ |
804 | yyvsp[i].yystate.yyloc = s->yyloc;]])[ | |
f868dc04 PH |
805 | s = yyvsp[i].yystate.yypred = s->yypred; |
806 | } | |
6a84279c PE |
807 | } |
808 | ||
809 | /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in | |
44e7ead1 PH |
810 | * YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1. |
811 | * For convenience, always return YYLOW1. */ | |
6a84279c | 812 | static inline int yyfill (yyGLRStackItem *, int *, int, yybool) |
135bc829 | 813 | __attribute__ ((__unused__)); |
6a84279c PE |
814 | static inline int |
815 | yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal) | |
816 | { | |
817 | if (!yynormal && yylow1 < *yylow) | |
818 | { | |
819 | yyfillin (yyvsp, *yylow, yylow1); | |
820 | *yylow = yylow1; | |
821 | } | |
f868dc04 PH |
822 | return yylow1; |
823 | } | |
824 | ||
01241d47 PH |
825 | /** Perform user action for rule number YYN, with RHS length YYRHSLEN, |
826 | * and top stack item YYVSP. YYLVALP points to place to put semantic | |
827 | * value ($$), and yylocp points to place for location information | |
9d9b8b70 PE |
828 | * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT, |
829 | * yyerr for YYERROR, yyabort for YYABORT. */ | |
12ce2df6 | 830 | /*ARGSUSED*/ static YYRESULTTAG |
fb8135fa | 831 | yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, |
7020e5f0 AD |
832 | yyGLRStack* yystackp, |
833 | YYSTYPE* yyvalp]b4_locuser_formals[) | |
01241d47 | 834 | { |
135bc829 | 835 | yybool yynormal __attribute__ ((__unused__)) = |
ef51bfa7 | 836 | (yystackp->yysplitPoint == YY_NULL); |
f868dc04 | 837 | int yylow; |
613d8952 AD |
838 | ]b4_parse_param_use[]dnl |
839 | [# undef yyerrok | |
3e7a2cd9 | 840 | # define yyerrok (yystackp->yyerrState = 0) |
01241d47 PH |
841 | # undef YYACCEPT |
842 | # define YYACCEPT return yyaccept | |
843 | # undef YYABORT | |
844 | # define YYABORT return yyabort | |
845 | # undef YYERROR | |
5cc16ecc | 846 | # define YYERROR return yyerrok, yyerr |
01241d47 | 847 | # undef YYRECOVERING |
02103984 | 848 | # define YYRECOVERING() (yystackp->yyerrState != 0) |
01241d47 | 849 | # undef yyclearin |
3f001415 | 850 | # define yyclearin (yychar = YYEMPTY) |
f868dc04 | 851 | # undef YYFILL |
6a84279c | 852 | # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal) |
01241d47 | 853 | # undef YYBACKUP |
7020e5f0 | 854 | # define YYBACKUP(Token, Value) \ |
30757c8c | 855 | return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \ |
7020e5f0 | 856 | yyerrok, yyerr |
01241d47 | 857 | |
25005f6a PH |
858 | yylow = 1; |
859 | if (yyrhslen == 0) | |
b4a20338 | 860 | *yyvalp = yyval_default; |
25005f6a | 861 | else |
769a8ef9 | 862 | *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;]b4_locations_if([[ |
401aace6 | 863 | YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen); |
769a8ef9 | 864 | yystackp->yyerror_range[1].yystate.yyloc = *yylocp; |
a85284cf | 865 | ]])[ |
25005f6a PH |
866 | switch (yyn) |
867 | { | |
8ec0a172 | 868 | ]b4_user_actions[ |
95f22ad2 | 869 | default: break; |
25005f6a | 870 | } |
01241d47 | 871 | |
25005f6a | 872 | return yyok; |
01241d47 PH |
873 | # undef yyerrok |
874 | # undef YYABORT | |
875 | # undef YYACCEPT | |
876 | # undef YYERROR | |
877 | # undef YYBACKUP | |
878 | # undef yyclearin | |
879 | # undef YYRECOVERING | |
01241d47 PH |
880 | } |
881 | \f | |
882 | ||
12ce2df6 | 883 | /*ARGSUSED*/ static void |
01241d47 PH |
884 | yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1) |
885 | { | |
2a4647a3 PE |
886 | YYUSE (yy0); |
887 | YYUSE (yy1); | |
1154cced | 888 | |
fb8135fa | 889 | switch (yyn) |
01241d47 | 890 | { |
a85284cf | 891 | ]b4_mergers[ |
e2688cd9 | 892 | default: break; |
01241d47 | 893 | } |
01241d47 | 894 | } |
a85284cf | 895 | |
7020e5f0 | 896 | /* Bison grammar-table manipulation. */ |
01241d47 | 897 | |
7bd6c77e AD |
898 | ]b4_yydestruct_generate([b4_c_ansi_function_def])[ |
899 | ||
42a6501d PE |
900 | /** Number of symbols composing the right hand side of rule #RULE. */ |
901 | static inline int | |
902 | yyrhsLength (yyRuleNum yyrule) | |
903 | { | |
904 | return yyr2[yyrule]; | |
905 | } | |
906 | ||
a4cf101a | 907 | static void |
4b367315 | 908 | yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[) |
a4cf101a PE |
909 | { |
910 | if (yys->yyresolved) | |
911 | yydestruct (yymsg, yystos[yys->yylrState], | |
7020e5f0 | 912 | &yys->yysemantics.yysval]b4_locuser_args([&yys->yyloc])[); |
a4cf101a PE |
913 | else |
914 | { | |
5f108727 | 915 | #if ]b4_api_PREFIX[DEBUG |
a4cf101a | 916 | if (yydebug) |
7020e5f0 AD |
917 | { |
918 | if (yys->yysemantics.yyfirstVal) | |
919 | YYFPRINTF (stderr, "%s unresolved ", yymsg); | |
920 | else | |
921 | YYFPRINTF (stderr, "%s incomplete ", yymsg); | |
922 | yy_symbol_print (stderr, yystos[yys->yylrState], | |
923 | YY_NULL]b4_locuser_args([&yys->yyloc])[); | |
924 | YYFPRINTF (stderr, "\n"); | |
925 | } | |
a4cf101a | 926 | #endif |
a4cf101a | 927 | |
42a6501d | 928 | if (yys->yysemantics.yyfirstVal) |
7020e5f0 AD |
929 | { |
930 | yySemanticOption *yyoption = yys->yysemantics.yyfirstVal; | |
931 | yyGLRState *yyrh; | |
932 | int yyn; | |
933 | for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule); | |
934 | yyn > 0; | |
935 | yyrh = yyrh->yypred, yyn -= 1) | |
936 | yydestroyGLRState (yymsg, yyrh]b4_user_args[); | |
937 | } | |
42a6501d | 938 | } |
01241d47 PH |
939 | } |
940 | ||
9d9b8b70 | 941 | /** Left-hand-side symbol for rule #RULE. */ |
01241d47 | 942 | static inline yySymbol |
fb8135fa | 943 | yylhsNonterm (yyRuleNum yyrule) |
01241d47 PH |
944 | { |
945 | return yyr1[yyrule]; | |
946 | } | |
947 | ||
39845e8e AD |
948 | #define yypact_value_is_default(Yystate) \ |
949 | ]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[ | |
944ed9f4 | 950 | |
01241d47 | 951 | /** True iff LR state STATE has only a default reduction (regardless |
9d9b8b70 | 952 | * of token). */ |
f7c398aa | 953 | static inline yybool |
01241d47 PH |
954 | yyisDefaultedState (yyStateNum yystate) |
955 | { | |
d5eb0826 | 956 | return yypact_value_is_default (yypact[yystate]); |
01241d47 | 957 | } |
fb8135fa | 958 | |
9d9b8b70 | 959 | /** The default reduction for STATE, assuming it has one. */ |
01241d47 PH |
960 | static inline yyRuleNum |
961 | yydefaultAction (yyStateNum yystate) | |
962 | { | |
963 | return yydefact[yystate]; | |
964 | } | |
965 | ||
39845e8e AD |
966 | #define yytable_value_is_error(Yytable_value) \ |
967 | ]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[ | |
944ed9f4 | 968 | |
2a1fe6ed | 969 | /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN. |
01241d47 PH |
970 | * Result R means |
971 | * R < 0: Reduce on rule -R. | |
972 | * R = 0: Error. | |
fb8135fa AD |
973 | * R > 0: Shift to state R. |
974 | * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of | |
01241d47 PH |
975 | * conflicting reductions. |
976 | */ | |
977 | static inline void | |
fb8135fa | 978 | yygetLRActions (yyStateNum yystate, int yytoken, |
7020e5f0 | 979 | int* yyaction, const short int** yyconflicts) |
01241d47 PH |
980 | { |
981 | int yyindex = yypact[yystate] + yytoken; | |
d5eb0826 JD |
982 | if (yypact_value_is_default (yypact[yystate]) |
983 | || yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken) | |
01241d47 PH |
984 | { |
985 | *yyaction = -yydefact[yystate]; | |
986 | *yyconflicts = yyconfl; | |
987 | } | |
d5eb0826 | 988 | else if (! yytable_value_is_error (yytable[yyindex])) |
01241d47 PH |
989 | { |
990 | *yyaction = yytable[yyindex]; | |
991 | *yyconflicts = yyconfl + yyconflp[yyindex]; | |
992 | } | |
f50adbbd AD |
993 | else |
994 | { | |
995 | *yyaction = 0; | |
996 | *yyconflicts = yyconfl + yyconflp[yyindex]; | |
997 | } | |
01241d47 PH |
998 | } |
999 | ||
1000 | static inline yyStateNum | |
1001 | yyLRgotoState (yyStateNum yystate, yySymbol yylhs) | |
1002 | { | |
1003 | int yyr; | |
1004 | yyr = yypgoto[yylhs - YYNTOKENS] + yystate; | |
34ec3579 | 1005 | if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate) |
01241d47 PH |
1006 | return yytable[yyr]; |
1007 | else | |
1008 | return yydefgoto[yylhs - YYNTOKENS]; | |
1009 | } | |
1010 | ||
f7c398aa | 1011 | static inline yybool |
fb8135fa | 1012 | yyisShiftAction (int yyaction) |
01241d47 | 1013 | { |
39912f52 | 1014 | return 0 < yyaction; |
01241d47 PH |
1015 | } |
1016 | ||
f7c398aa | 1017 | static inline yybool |
fb8135fa | 1018 | yyisErrorAction (int yyaction) |
01241d47 | 1019 | { |
f50adbbd | 1020 | return yyaction == 0; |
01241d47 PH |
1021 | } |
1022 | ||
7020e5f0 | 1023 | /* GLRStates */ |
01241d47 | 1024 | |
02998094 AD |
1025 | /** Return a fresh GLRStackItem. Callers should call |
1026 | * YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient | |
1027 | * headroom. */ | |
1028 | ||
1029 | static inline yyGLRStackItem* | |
3e7a2cd9 | 1030 | yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState) |
02998094 | 1031 | { |
3e7a2cd9 PE |
1032 | yyGLRStackItem* yynewItem = yystackp->yynextFree; |
1033 | yystackp->yyspaceLeft -= 1; | |
1034 | yystackp->yynextFree += 1; | |
02998094 AD |
1035 | yynewItem->yystate.yyisState = yyisState; |
1036 | return yynewItem; | |
1037 | } | |
1038 | ||
12f4614d PH |
1039 | /** Add a new semantic action that will execute the action for rule |
1040 | * RULENUM on the semantic values in RHS to the list of | |
c66dfadd | 1041 | * alternative actions for STATE. Assumes that RHS comes from |
12f4614d | 1042 | * stack #K of *STACKP. */ |
1154cced | 1043 | static void |
bf70fa87 | 1044 | yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate, |
7020e5f0 | 1045 | yyGLRState* rhs, yyRuleNum yyrule) |
01241d47 | 1046 | { |
02998094 | 1047 | yySemanticOption* yynewOption = |
3e7a2cd9 | 1048 | &yynewGLRStackItem (yystackp, yyfalse)->yyoption; |
02998094 AD |
1049 | yynewOption->yystate = rhs; |
1050 | yynewOption->yyrule = yyrule; | |
b7691f15 | 1051 | if (yystackp->yytops.yylookaheadNeeds[yyk]) |
bf70fa87 JD |
1052 | { |
1053 | yynewOption->yyrawchar = yychar; | |
769a8ef9 AD |
1054 | yynewOption->yyval = yylval;]b4_locations_if([ |
1055 | yynewOption->yyloc = yylloc;])[ | |
bf70fa87 JD |
1056 | } |
1057 | else | |
1058 | yynewOption->yyrawchar = YYEMPTY; | |
02998094 AD |
1059 | yynewOption->yynext = yystate->yysemantics.yyfirstVal; |
1060 | yystate->yysemantics.yyfirstVal = yynewOption; | |
1061 | ||
3e7a2cd9 | 1062 | YY_RESERVE_GLRSTACK (yystackp); |
01241d47 PH |
1063 | } |
1064 | ||
7020e5f0 | 1065 | /* GLRStacks */ |
01241d47 | 1066 | |
9d9b8b70 | 1067 | /** Initialize SET to a singleton set containing an empty stack. */ |
63cb01d6 | 1068 | static yybool |
01241d47 PH |
1069 | yyinitStateSet (yyGLRStateSet* yyset) |
1070 | { | |
1071 | yyset->yysize = 1; | |
1072 | yyset->yycapacity = 16; | |
be16239b | 1073 | yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]); |
63cb01d6 PE |
1074 | if (! yyset->yystates) |
1075 | return yyfalse; | |
ef51bfa7 | 1076 | yyset->yystates[0] = YY_NULL; |
b7691f15 JD |
1077 | yyset->yylookaheadNeeds = |
1078 | (yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]); | |
1079 | if (! yyset->yylookaheadNeeds) | |
bf70fa87 JD |
1080 | { |
1081 | YYFREE (yyset->yystates); | |
1082 | return yyfalse; | |
1083 | } | |
63cb01d6 | 1084 | return yytrue; |
01241d47 PH |
1085 | } |
1086 | ||
fb8135fa | 1087 | static void yyfreeStateSet (yyGLRStateSet* yyset) |
01241d47 | 1088 | { |
a525b568 | 1089 | YYFREE (yyset->yystates); |
b7691f15 | 1090 | YYFREE (yyset->yylookaheadNeeds); |
01241d47 PH |
1091 | } |
1092 | ||
1093 | /** Initialize STACK to a single empty stack, with total maximum | |
9d9b8b70 | 1094 | * capacity for all stacks of SIZE. */ |
63cb01d6 | 1095 | static yybool |
3e7a2cd9 | 1096 | yyinitGLRStack (yyGLRStack* yystackp, size_t yysize) |
01241d47 | 1097 | { |
3e7a2cd9 | 1098 | yystackp->yyerrState = 0; |
01241d47 | 1099 | yynerrs = 0; |
3e7a2cd9 PE |
1100 | yystackp->yyspaceLeft = yysize; |
1101 | yystackp->yyitems = | |
1102 | (yyGLRStackItem*) YYMALLOC (yysize * sizeof yystackp->yynextFree[0]); | |
1103 | if (!yystackp->yyitems) | |
3922956a | 1104 | return yyfalse; |
3e7a2cd9 | 1105 | yystackp->yynextFree = yystackp->yyitems; |
ef51bfa7 AD |
1106 | yystackp->yysplitPoint = YY_NULL; |
1107 | yystackp->yylastDeleted = YY_NULL; | |
3e7a2cd9 | 1108 | return yyinitStateSet (&yystackp->yytops); |
01241d47 PH |
1109 | } |
1110 | ||
02998094 AD |
1111 | |
1112 | #if YYSTACKEXPANDABLE | |
1113 | # define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \ | |
01241d47 PH |
1114 | &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE |
1115 | ||
1116 | /** If STACK is expandable, extend it. WARNING: Pointers into the | |
1117 | stack from outside should be considered invalid after this call. | |
1118 | We always expand when there are 1 or fewer items left AFTER an | |
1119 | allocation, so that we can avoid having external pointers exist | |
9d9b8b70 | 1120 | across an allocation. */ |
01241d47 | 1121 | static void |
3e7a2cd9 | 1122 | yyexpandGLRStack (yyGLRStack* yystackp) |
01241d47 | 1123 | { |
63cb01d6 | 1124 | yyGLRStackItem* yynewItems; |
01241d47 | 1125 | yyGLRStackItem* yyp0, *yyp1; |
aebb55eb | 1126 | size_t yynewSize; |
01241d47 | 1127 | size_t yyn; |
aebb55eb | 1128 | size_t yysize = yystackp->yynextFree - yystackp->yyitems; |
18d9185c | 1129 | if (YYMAXDEPTH - YYHEADROOM < yysize) |
3e7a2cd9 | 1130 | yyMemoryExhausted (yystackp); |
01241d47 | 1131 | yynewSize = 2*yysize; |
39912f52 | 1132 | if (YYMAXDEPTH < yynewSize) |
01241d47 | 1133 | yynewSize = YYMAXDEPTH; |
63cb01d6 PE |
1134 | yynewItems = (yyGLRStackItem*) YYMALLOC (yynewSize * sizeof yynewItems[0]); |
1135 | if (! yynewItems) | |
3e7a2cd9 PE |
1136 | yyMemoryExhausted (yystackp); |
1137 | for (yyp0 = yystackp->yyitems, yyp1 = yynewItems, yyn = yysize; | |
39912f52 | 1138 | 0 < yyn; |
fb8135fa | 1139 | yyn -= 1, yyp0 += 1, yyp1 += 1) |
01241d47 PH |
1140 | { |
1141 | *yyp1 = *yyp0; | |
f7c398aa | 1142 | if (*(yybool *) yyp0) |
7020e5f0 AD |
1143 | { |
1144 | yyGLRState* yys0 = &yyp0->yystate; | |
1145 | yyGLRState* yys1 = &yyp1->yystate; | |
1146 | if (yys0->yypred != YY_NULL) | |
1147 | yys1->yypred = | |
1148 | YYRELOC (yyp0, yyp1, yys0->yypred, yystate); | |
1149 | if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != YY_NULL) | |
1150 | yys1->yysemantics.yyfirstVal = | |
aebb55eb | 1151 | YYRELOC (yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption); |
7020e5f0 | 1152 | } |
fb8135fa | 1153 | else |
7020e5f0 AD |
1154 | { |
1155 | yySemanticOption* yyv0 = &yyp0->yyoption; | |
1156 | yySemanticOption* yyv1 = &yyp1->yyoption; | |
1157 | if (yyv0->yystate != YY_NULL) | |
1158 | yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate); | |
1159 | if (yyv0->yynext != YY_NULL) | |
1160 | yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption); | |
1161 | } | |
01241d47 | 1162 | } |
ef51bfa7 | 1163 | if (yystackp->yysplitPoint != YY_NULL) |
3e7a2cd9 | 1164 | yystackp->yysplitPoint = YYRELOC (yystackp->yyitems, yynewItems, |
7020e5f0 | 1165 | yystackp->yysplitPoint, yystate); |
3e7a2cd9 PE |
1166 | |
1167 | for (yyn = 0; yyn < yystackp->yytops.yysize; yyn += 1) | |
ef51bfa7 | 1168 | if (yystackp->yytops.yystates[yyn] != YY_NULL) |
3e7a2cd9 | 1169 | yystackp->yytops.yystates[yyn] = |
7020e5f0 AD |
1170 | YYRELOC (yystackp->yyitems, yynewItems, |
1171 | yystackp->yytops.yystates[yyn], yystate); | |
3e7a2cd9 PE |
1172 | YYFREE (yystackp->yyitems); |
1173 | yystackp->yyitems = yynewItems; | |
1174 | yystackp->yynextFree = yynewItems + yysize; | |
1175 | yystackp->yyspaceLeft = yynewSize - yysize; | |
01241d47 | 1176 | } |
02998094 | 1177 | #endif |
01241d47 PH |
1178 | |
1179 | static void | |
3e7a2cd9 | 1180 | yyfreeGLRStack (yyGLRStack* yystackp) |
01241d47 | 1181 | { |
3e7a2cd9 PE |
1182 | YYFREE (yystackp->yyitems); |
1183 | yyfreeStateSet (&yystackp->yytops); | |
01241d47 PH |
1184 | } |
1185 | ||
1186 | /** Assuming that S is a GLRState somewhere on STACK, update the | |
fb8135fa | 1187 | * splitpoint of STACK, if needed, so that it is at least as deep as |
9d9b8b70 | 1188 | * S. */ |
01241d47 | 1189 | static inline void |
3e7a2cd9 | 1190 | yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys) |
01241d47 | 1191 | { |
ef51bfa7 | 1192 | if (yystackp->yysplitPoint != YY_NULL && yystackp->yysplitPoint > yys) |
3e7a2cd9 | 1193 | yystackp->yysplitPoint = yys; |
01241d47 PH |
1194 | } |
1195 | ||
9d9b8b70 | 1196 | /** Invalidate stack #K in STACK. */ |
01241d47 | 1197 | static inline void |
3e7a2cd9 | 1198 | yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk) |
01241d47 | 1199 | { |
ef51bfa7 | 1200 | if (yystackp->yytops.yystates[yyk] != YY_NULL) |
3e7a2cd9 | 1201 | yystackp->yylastDeleted = yystackp->yytops.yystates[yyk]; |
ef51bfa7 | 1202 | yystackp->yytops.yystates[yyk] = YY_NULL; |
01241d47 PH |
1203 | } |
1204 | ||
fb8135fa | 1205 | /** Undelete the last stack that was marked as deleted. Can only be |
01241d47 | 1206 | done once after a deletion, and only when all other stacks have |
9d9b8b70 | 1207 | been deleted. */ |
01241d47 | 1208 | static void |
3e7a2cd9 | 1209 | yyundeleteLastStack (yyGLRStack* yystackp) |
01241d47 | 1210 | { |
ef51bfa7 | 1211 | if (yystackp->yylastDeleted == YY_NULL || yystackp->yytops.yysize != 0) |
01241d47 | 1212 | return; |
3e7a2cd9 PE |
1213 | yystackp->yytops.yystates[0] = yystackp->yylastDeleted; |
1214 | yystackp->yytops.yysize = 1; | |
2f4f028d | 1215 | YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n")); |
ef51bfa7 | 1216 | yystackp->yylastDeleted = YY_NULL; |
01241d47 PH |
1217 | } |
1218 | ||
1219 | static inline void | |
3e7a2cd9 | 1220 | yyremoveDeletes (yyGLRStack* yystackp) |
01241d47 | 1221 | { |
1154cced | 1222 | size_t yyi, yyj; |
01241d47 | 1223 | yyi = yyj = 0; |
3e7a2cd9 | 1224 | while (yyj < yystackp->yytops.yysize) |
01241d47 | 1225 | { |
ef51bfa7 | 1226 | if (yystackp->yytops.yystates[yyi] == YY_NULL) |
7020e5f0 AD |
1227 | { |
1228 | if (yyi == yyj) | |
1229 | { | |
1230 | YYDPRINTF ((stderr, "Removing dead stacks.\n")); | |
1231 | } | |
1232 | yystackp->yytops.yysize -= 1; | |
1233 | } | |
fb8135fa | 1234 | else |
7020e5f0 AD |
1235 | { |
1236 | yystackp->yytops.yystates[yyj] = yystackp->yytops.yystates[yyi]; | |
1237 | /* In the current implementation, it's unnecessary to copy | |
1238 | yystackp->yytops.yylookaheadNeeds[yyi] since, after | |
1239 | yyremoveDeletes returns, the parser immediately either enters | |
1240 | deterministic operation or shifts a token. However, it doesn't | |
1241 | hurt, and the code might evolve to need it. */ | |
1242 | yystackp->yytops.yylookaheadNeeds[yyj] = | |
1243 | yystackp->yytops.yylookaheadNeeds[yyi]; | |
1244 | if (yyj != yyi) | |
1245 | { | |
1246 | YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n", | |
1247 | (unsigned long int) yyi, (unsigned long int) yyj)); | |
1248 | } | |
1249 | yyj += 1; | |
1250 | } | |
01241d47 PH |
1251 | yyi += 1; |
1252 | } | |
1253 | } | |
1254 | ||
fb8135fa | 1255 | /** Shift to a new state on stack #K of STACK, corresponding to LR state |
9d9b8b70 | 1256 | * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */ |
01241d47 | 1257 | static inline void |
3e7a2cd9 | 1258 | yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, |
7020e5f0 AD |
1259 | size_t yyposn, |
1260 | YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[) | |
01241d47 | 1261 | { |
3e7a2cd9 | 1262 | yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate; |
01241d47 | 1263 | |
02998094 AD |
1264 | yynewState->yylrState = yylrState; |
1265 | yynewState->yyposn = yyposn; | |
1266 | yynewState->yyresolved = yytrue; | |
3e7a2cd9 | 1267 | yynewState->yypred = yystackp->yytops.yystates[yyk]; |
769a8ef9 AD |
1268 | yynewState->yysemantics.yysval = *yyvalp;]b4_locations_if([ |
1269 | yynewState->yyloc = *yylocp;])[ | |
3e7a2cd9 | 1270 | yystackp->yytops.yystates[yyk] = yynewState; |
02998094 | 1271 | |
3e7a2cd9 | 1272 | YY_RESERVE_GLRSTACK (yystackp); |
01241d47 PH |
1273 | } |
1274 | ||
f868dc04 | 1275 | /** Shift stack #K of YYSTACK, to a new state corresponding to LR |
c4749565 | 1276 | * state YYLRSTATE, at input position YYPOSN, with the (unresolved) |
9d9b8b70 | 1277 | * semantic value of YYRHS under the action for YYRULE. */ |
01241d47 | 1278 | static inline void |
3e7a2cd9 | 1279 | yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, |
7020e5f0 | 1280 | size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule) |
01241d47 | 1281 | { |
3e7a2cd9 | 1282 | yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate; |
02998094 AD |
1283 | |
1284 | yynewState->yylrState = yylrState; | |
1285 | yynewState->yyposn = yyposn; | |
1286 | yynewState->yyresolved = yyfalse; | |
3e7a2cd9 | 1287 | yynewState->yypred = yystackp->yytops.yystates[yyk]; |
ef51bfa7 | 1288 | yynewState->yysemantics.yyfirstVal = YY_NULL; |
3e7a2cd9 | 1289 | yystackp->yytops.yystates[yyk] = yynewState; |
02998094 | 1290 | |
9d9b8b70 | 1291 | /* Invokes YY_RESERVE_GLRSTACK. */ |
bf70fa87 | 1292 | yyaddDeferredAction (yystackp, yyk, yynewState, rhs, yyrule); |
01241d47 PH |
1293 | } |
1294 | ||
1295 | /** Pop the symbols consumed by reduction #RULE from the top of stack | |
fb8135fa AD |
1296 | * #K of STACK, and perform the appropriate semantic action on their |
1297 | * semantic values. Assumes that all ambiguities in semantic values | |
9d9b8b70 | 1298 | * have been previously resolved. Set *VALP to the resulting value, |
01241d47 | 1299 | * and *LOCP to the computed location (if any). Return value is as |
9d9b8b70 | 1300 | * for userAction. */ |
ff032592 | 1301 | static inline YYRESULTTAG |
3e7a2cd9 | 1302 | yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, |
7020e5f0 | 1303 | YYSTYPE* yyvalp]b4_locuser_formals[) |
01241d47 PH |
1304 | { |
1305 | int yynrhs = yyrhsLength (yyrule); | |
1306 | ||
ef51bfa7 | 1307 | if (yystackp->yysplitPoint == YY_NULL) |
01241d47 | 1308 | { |
9d9b8b70 | 1309 | /* Standard special case: single stack. */ |
3e7a2cd9 | 1310 | yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk]; |
64c4fd52 | 1311 | YYASSERT (yyk == 0); |
3e7a2cd9 PE |
1312 | yystackp->yynextFree -= yynrhs; |
1313 | yystackp->yyspaceLeft += yynrhs; | |
1314 | yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate; | |
769a8ef9 | 1315 | return yyuserAction (yyrule, yynrhs, rhs, yystackp, |
7020e5f0 | 1316 | yyvalp]b4_locuser_args[); |
01241d47 | 1317 | } |
fb8135fa | 1318 | else |
01241d47 | 1319 | { |
44e7ead1 PH |
1320 | /* At present, doAction is never called in nondeterministic |
1321 | * mode, so this branch is never taken. It is here in | |
1322 | * anticipation of a future feature that will allow immediate | |
9d9b8b70 | 1323 | * evaluation of selected actions in nondeterministic mode. */ |
01241d47 PH |
1324 | int yyi; |
1325 | yyGLRState* yys; | |
25005f6a | 1326 | yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1]; |
5cc16ecc | 1327 | yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred |
7020e5f0 | 1328 | = yystackp->yytops.yystates[yyk];]b4_locations_if([[ |
44e7ead1 | 1329 | if (yynrhs == 0) |
7020e5f0 AD |
1330 | /* Set default location. */ |
1331 | yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[ | |
f868dc04 | 1332 | for (yyi = 0; yyi < yynrhs; yyi += 1) |
7020e5f0 AD |
1333 | { |
1334 | yys = yys->yypred; | |
1335 | YYASSERT (yys); | |
1336 | } | |
3e7a2cd9 PE |
1337 | yyupdateSplit (yystackp, yys); |
1338 | yystackp->yytops.yystates[yyk] = yys; | |
25005f6a | 1339 | return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, |
7020e5f0 | 1340 | yystackp, yyvalp]b4_locuser_args[); |
01241d47 PH |
1341 | } |
1342 | } | |
1343 | ||
5f108727 | 1344 | #if !]b4_api_PREFIX[DEBUG |
62b08cfc | 1345 | # define YY_REDUCE_PRINT(Args) |
e7cb57c0 | 1346 | #else |
7020e5f0 AD |
1347 | # define YY_REDUCE_PRINT(Args) \ |
1348 | do { \ | |
1349 | if (yydebug) \ | |
1350 | yy_reduce_print Args; \ | |
12ce2df6 | 1351 | } while (YYID (0)) |
e7cb57c0 AD |
1352 | |
1353 | /*----------------------------------------------------------. | |
1354 | | Report that the RULE is going to be reduced on stack #K. | | |
1355 | `----------------------------------------------------------*/ | |
1356 | ||
12ce2df6 | 1357 | /*ARGSUSED*/ static inline void |
3e7a2cd9 | 1358 | yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, |
7020e5f0 | 1359 | YYSTYPE* yyvalp]b4_locuser_formals[) |
e7cb57c0 | 1360 | { |
62b08cfc AD |
1361 | int yynrhs = yyrhsLength (yyrule); |
1362 | yybool yynormal __attribute__ ((__unused__)) = | |
ef51bfa7 | 1363 | (yystackp->yysplitPoint == YY_NULL); |
3e7a2cd9 | 1364 | yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk]; |
62b08cfc | 1365 | int yylow = 1; |
e7cb57c0 | 1366 | int yyi; |
769a8ef9 AD |
1367 | YYUSE (yyvalp);]b4_locations_if([ |
1368 | YYUSE (yylocp);])[ | |
613d8952 AD |
1369 | ]b4_parse_param_use[]dnl |
1370 | [ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n", | |
7020e5f0 AD |
1371 | (unsigned long int) yyk, yyrule - 1, |
1372 | (unsigned long int) yyrline[yyrule]); | |
6de5398d | 1373 | /* The symbols being reduced. */ |
62b08cfc AD |
1374 | for (yyi = 0; yyi < yynrhs; yyi++) |
1375 | { | |
f57a7536 | 1376 | YYFPRINTF (stderr, " $%d = ", yyi + 1); |
a0af42fc | 1377 | yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], |
7020e5f0 AD |
1378 | &]b4_rhs_value(yynrhs, yyi + 1)[ |
1379 | ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl | |
1380 | b4_user_args[); | |
f57a7536 | 1381 | YYFPRINTF (stderr, "\n"); |
62b08cfc | 1382 | } |
e7cb57c0 AD |
1383 | } |
1384 | #endif | |
1385 | ||
01241d47 PH |
1386 | /** Pop items off stack #K of STACK according to grammar rule RULE, |
1387 | * and push back on the resulting nonterminal symbol. Perform the | |
fb8135fa | 1388 | * semantic action associated with RULE and store its value with the |
01241d47 PH |
1389 | * newly pushed state, if FORCEEVAL or if STACK is currently |
1390 | * unambiguous. Otherwise, store the deferred semantic action with | |
1391 | * the new state. If the new state would have an identical input | |
1392 | * position, LR state, and predecessor to an existing state on the stack, | |
fb8135fa | 1393 | * it is identified with that existing state, eliminating stack #K from |
9d9b8b70 | 1394 | * the STACK. In this case, the (necessarily deferred) semantic value is |
fb8135fa | 1395 | * added to the options for the existing state's semantic value. |
01241d47 PH |
1396 | */ |
1397 | static inline YYRESULTTAG | |
3e7a2cd9 | 1398 | yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, |
7020e5f0 | 1399 | yybool yyforceEval]b4_user_formals[) |
01241d47 | 1400 | { |
3e7a2cd9 | 1401 | size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn; |
01241d47 | 1402 | |
ef51bfa7 | 1403 | if (yyforceEval || yystackp->yysplitPoint == YY_NULL) |
01241d47 | 1404 | { |
769a8ef9 AD |
1405 | YYSTYPE yysval;]b4_locations_if([ |
1406 | YYLTYPE yyloc;])[ | |
fb8135fa | 1407 | |
769a8ef9 AD |
1408 | YY_REDUCE_PRINT ((yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[)); |
1409 | YYCHK (yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[)); | |
62b08cfc | 1410 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc); |
3e7a2cd9 | 1411 | yyglrShift (yystackp, yyk, |
7020e5f0 AD |
1412 | yyLRgotoState (yystackp->yytops.yystates[yyk]->yylrState, |
1413 | yylhsNonterm (yyrule)), | |
1414 | yyposn, &yysval]b4_locations_if([, &yyloc])[); | |
01241d47 | 1415 | } |
fb8135fa | 1416 | else |
01241d47 | 1417 | { |
1154cced AD |
1418 | size_t yyi; |
1419 | int yyn; | |
3e7a2cd9 | 1420 | yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk]; |
01241d47 PH |
1421 | yyStateNum yynewLRState; |
1422 | ||
3e7a2cd9 | 1423 | for (yys = yystackp->yytops.yystates[yyk], yyn = yyrhsLength (yyrule); |
7020e5f0 AD |
1424 | 0 < yyn; yyn -= 1) |
1425 | { | |
1426 | yys = yys->yypred; | |
1427 | YYASSERT (yys); | |
1428 | } | |
3e7a2cd9 | 1429 | yyupdateSplit (yystackp, yys); |
01241d47 | 1430 | yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule)); |
fb8135fa | 1431 | YYDPRINTF ((stderr, |
7020e5f0 AD |
1432 | "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n", |
1433 | (unsigned long int) yyk, yyrule - 1, yynewLRState)); | |
3e7a2cd9 | 1434 | for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1) |
7020e5f0 AD |
1435 | if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULL) |
1436 | { | |
aebb55eb AD |
1437 | yyGLRState *yysplit = yystackp->yysplitPoint; |
1438 | yyGLRState *yyp = yystackp->yytops.yystates[yyi]; | |
7020e5f0 AD |
1439 | while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn) |
1440 | { | |
1441 | if (yyp->yylrState == yynewLRState && yyp->yypred == yys) | |
1442 | { | |
1443 | yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule); | |
1444 | yymarkStackDeleted (yystackp, yyk); | |
1445 | YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n", | |
1446 | (unsigned long int) yyk, | |
1447 | (unsigned long int) yyi)); | |
1448 | return yyok; | |
1449 | } | |
1450 | yyp = yyp->yypred; | |
1451 | } | |
1452 | } | |
3e7a2cd9 PE |
1453 | yystackp->yytops.yystates[yyk] = yys; |
1454 | yyglrShiftDefer (yystackp, yyk, yynewLRState, yyposn, yys0, yyrule); | |
fb8135fa | 1455 | } |
ff032592 | 1456 | return yyok; |
01241d47 PH |
1457 | } |
1458 | ||
63cb01d6 | 1459 | static size_t |
3e7a2cd9 | 1460 | yysplitStack (yyGLRStack* yystackp, size_t yyk) |
01241d47 | 1461 | { |
ef51bfa7 | 1462 | if (yystackp->yysplitPoint == YY_NULL) |
01241d47 | 1463 | { |
64c4fd52 | 1464 | YYASSERT (yyk == 0); |
3e7a2cd9 | 1465 | yystackp->yysplitPoint = yystackp->yytops.yystates[yyk]; |
01241d47 | 1466 | } |
3e7a2cd9 | 1467 | if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity) |
01241d47 | 1468 | { |
63cb01d6 | 1469 | yyGLRState** yynewStates; |
b7691f15 | 1470 | yybool* yynewLookaheadNeeds; |
ddee1b06 | 1471 | |
ef51bfa7 | 1472 | yynewStates = YY_NULL; |
c66dfadd | 1473 | |
ddee1b06 | 1474 | if (yystackp->yytops.yycapacity |
7020e5f0 AD |
1475 | > (YYSIZEMAX / (2 * sizeof yynewStates[0]))) |
1476 | yyMemoryExhausted (yystackp); | |
ddee1b06 PH |
1477 | yystackp->yytops.yycapacity *= 2; |
1478 | ||
1479 | yynewStates = | |
7020e5f0 AD |
1480 | (yyGLRState**) YYREALLOC (yystackp->yytops.yystates, |
1481 | (yystackp->yytops.yycapacity | |
1482 | * sizeof yynewStates[0])); | |
ef51bfa7 | 1483 | if (yynewStates == YY_NULL) |
7020e5f0 | 1484 | yyMemoryExhausted (yystackp); |
3e7a2cd9 | 1485 | yystackp->yytops.yystates = yynewStates; |
ddee1b06 | 1486 | |
b7691f15 | 1487 | yynewLookaheadNeeds = |
7020e5f0 AD |
1488 | (yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds, |
1489 | (yystackp->yytops.yycapacity | |
1490 | * sizeof yynewLookaheadNeeds[0])); | |
ef51bfa7 | 1491 | if (yynewLookaheadNeeds == YY_NULL) |
7020e5f0 | 1492 | yyMemoryExhausted (yystackp); |
b7691f15 | 1493 | yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds; |
01241d47 | 1494 | } |
3e7a2cd9 PE |
1495 | yystackp->yytops.yystates[yystackp->yytops.yysize] |
1496 | = yystackp->yytops.yystates[yyk]; | |
b7691f15 JD |
1497 | yystackp->yytops.yylookaheadNeeds[yystackp->yytops.yysize] |
1498 | = yystackp->yytops.yylookaheadNeeds[yyk]; | |
3e7a2cd9 PE |
1499 | yystackp->yytops.yysize += 1; |
1500 | return yystackp->yytops.yysize-1; | |
01241d47 PH |
1501 | } |
1502 | ||
1503 | /** True iff Y0 and Y1 represent identical options at the top level. | |
1504 | * That is, they represent the same rule applied to RHS symbols | |
9d9b8b70 | 1505 | * that produce the same terminal symbols. */ |
f7c398aa | 1506 | static yybool |
01241d47 PH |
1507 | yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1) |
1508 | { | |
fb8135fa | 1509 | if (yyy0->yyrule == yyy1->yyrule) |
01241d47 PH |
1510 | { |
1511 | yyGLRState *yys0, *yys1; | |
1512 | int yyn; | |
fb8135fa | 1513 | for (yys0 = yyy0->yystate, yys1 = yyy1->yystate, |
7020e5f0 AD |
1514 | yyn = yyrhsLength (yyy0->yyrule); |
1515 | yyn > 0; | |
1516 | yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1) | |
1517 | if (yys0->yyposn != yys1->yyposn) | |
1518 | return yyfalse; | |
01241d47 PH |
1519 | return yytrue; |
1520 | } | |
1521 | else | |
1522 | return yyfalse; | |
1523 | } | |
1524 | ||
5e6f62f2 | 1525 | /** Assuming identicalOptions (Y0,Y1), destructively merge the |
9d9b8b70 | 1526 | * alternative semantic values for the RHS-symbols of Y1 and Y0. */ |
01241d47 PH |
1527 | static void |
1528 | yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) | |
1529 | { | |
1530 | yyGLRState *yys0, *yys1; | |
1531 | int yyn; | |
fb8135fa | 1532 | for (yys0 = yyy0->yystate, yys1 = yyy1->yystate, |
01241d47 PH |
1533 | yyn = yyrhsLength (yyy0->yyrule); |
1534 | yyn > 0; | |
1535 | yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1) | |
5e6f62f2 PH |
1536 | { |
1537 | if (yys0 == yys1) | |
7020e5f0 | 1538 | break; |
010f91c3 | 1539 | else if (yys0->yyresolved) |
7020e5f0 AD |
1540 | { |
1541 | yys1->yyresolved = yytrue; | |
1542 | yys1->yysemantics.yysval = yys0->yysemantics.yysval; | |
1543 | } | |
5e6f62f2 | 1544 | else if (yys1->yyresolved) |
7020e5f0 AD |
1545 | { |
1546 | yys0->yyresolved = yytrue; | |
1547 | yys0->yysemantics.yysval = yys1->yysemantics.yysval; | |
1548 | } | |
010f91c3 | 1549 | else |
7020e5f0 | 1550 | { |
aebb55eb AD |
1551 | yySemanticOption** yyz0p = &yys0->yysemantics.yyfirstVal; |
1552 | yySemanticOption* yyz1 = yys1->yysemantics.yyfirstVal; | |
7020e5f0 AD |
1553 | while (YYID (yytrue)) |
1554 | { | |
1555 | if (yyz1 == *yyz0p || yyz1 == YY_NULL) | |
1556 | break; | |
1557 | else if (*yyz0p == YY_NULL) | |
1558 | { | |
1559 | *yyz0p = yyz1; | |
1560 | break; | |
1561 | } | |
1562 | else if (*yyz0p < yyz1) | |
1563 | { | |
1564 | yySemanticOption* yyz = *yyz0p; | |
1565 | *yyz0p = yyz1; | |
1566 | yyz1 = yyz1->yynext; | |
1567 | (*yyz0p)->yynext = yyz; | |
1568 | } | |
1569 | yyz0p = &(*yyz0p)->yynext; | |
1570 | } | |
1571 | yys1->yysemantics.yyfirstVal = yys0->yysemantics.yyfirstVal; | |
1572 | } | |
5e6f62f2 | 1573 | } |
01241d47 PH |
1574 | } |
1575 | ||
1576 | /** Y0 and Y1 represent two possible actions to take in a given | |
1577 | * parsing state; return 0 if no combination is possible, | |
9d9b8b70 | 1578 | * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */ |
01241d47 | 1579 | static int |
1154cced | 1580 | yypreference (yySemanticOption* y0, yySemanticOption* y1) |
01241d47 | 1581 | { |
1154cced AD |
1582 | yyRuleNum r0 = y0->yyrule, r1 = y1->yyrule; |
1583 | int p0 = yydprec[r0], p1 = yydprec[r1]; | |
01241d47 | 1584 | |
1154cced | 1585 | if (p0 == p1) |
01241d47 | 1586 | { |
1154cced | 1587 | if (yymerger[r0] == 0 || yymerger[r0] != yymerger[r1]) |
7020e5f0 | 1588 | return 0; |
01241d47 | 1589 | else |
7020e5f0 | 1590 | return 1; |
01241d47 | 1591 | } |
1154cced | 1592 | if (p0 == 0 || p1 == 0) |
01241d47 | 1593 | return 0; |
1154cced | 1594 | if (p0 < p1) |
01241d47 | 1595 | return 3; |
39912f52 | 1596 | if (p1 < p0) |
01241d47 PH |
1597 | return 2; |
1598 | return 0; | |
1599 | } | |
1600 | ||
d659304d | 1601 | static YYRESULTTAG yyresolveValue (yyGLRState* yys, |
7020e5f0 | 1602 | yyGLRStack* yystackp]b4_user_formals[); |
520181ab | 1603 | |
01241d47 | 1604 | |
520181ab JD |
1605 | /** Resolve the previous N states starting at and including state S. If result |
1606 | * != yyok, some states may have been left unresolved possibly with empty | |
1607 | * semantic option chains. Regardless of whether result = yyok, each state | |
1608 | * has been left with consistent data so that yydestroyGLRState can be invoked | |
1609 | * if necessary. */ | |
01241d47 | 1610 | static YYRESULTTAG |
3e7a2cd9 | 1611 | yyresolveStates (yyGLRState* yys, int yyn, |
7020e5f0 | 1612 | yyGLRStack* yystackp]b4_user_formals[) |
01241d47 | 1613 | { |
39912f52 | 1614 | if (0 < yyn) |
01241d47 | 1615 | { |
64c4fd52 | 1616 | YYASSERT (yys->yypred); |
d659304d | 1617 | YYCHK (yyresolveStates (yys->yypred, yyn-1, yystackp]b4_user_args[)); |
fb8135fa | 1618 | if (! yys->yyresolved) |
7020e5f0 | 1619 | YYCHK (yyresolveValue (yys, yystackp]b4_user_args[)); |
01241d47 PH |
1620 | } |
1621 | return yyok; | |
1622 | } | |
1623 | ||
520181ab JD |
1624 | /** Resolve the states for the RHS of OPT, perform its user action, and return |
1625 | * the semantic value and location. Regardless of whether result = yyok, all | |
1626 | * RHS states have been destroyed (assuming the user action destroys all RHS | |
1627 | * semantic values if invoked). */ | |
01241d47 | 1628 | static YYRESULTTAG |
3e7a2cd9 | 1629 | yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp, |
7020e5f0 | 1630 | YYSTYPE* yyvalp]b4_locuser_formals[) |
01241d47 | 1631 | { |
25005f6a | 1632 | yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1]; |
aebb55eb AD |
1633 | int yynrhs = yyrhsLength (yyopt->yyrule); |
1634 | YYRESULTTAG yyflag = | |
1635 | yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[); | |
520181ab JD |
1636 | if (yyflag != yyok) |
1637 | { | |
1638 | yyGLRState *yys; | |
1639 | for (yys = yyopt->yystate; yynrhs > 0; yys = yys->yypred, yynrhs -= 1) | |
7020e5f0 | 1640 | yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[); |
520181ab JD |
1641 | return yyflag; |
1642 | } | |
1643 | ||
327afc7c | 1644 | yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_locations_if([[ |
44e7ead1 | 1645 | if (yynrhs == 0) |
9d9b8b70 | 1646 | /* Set default location. */ |
44e7ead1 | 1647 | yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[ |
aebb55eb AD |
1648 | { |
1649 | int yychar_current = yychar; | |
1650 | YYSTYPE yylval_current = yylval;]b4_locations_if([ | |
1651 | YYLTYPE yylloc_current = yylloc;])[ | |
1652 | yychar = yyopt->yyrawchar; | |
1653 | yylval = yyopt->yyval;]b4_locations_if([ | |
1654 | yylloc = yyopt->yyloc;])[ | |
1655 | yyflag = yyuserAction (yyopt->yyrule, yynrhs, | |
1656 | yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, | |
1657 | yystackp, yyvalp]b4_locuser_args[); | |
1658 | yychar = yychar_current; | |
1659 | yylval = yylval_current;]b4_locations_if([ | |
1660 | yylloc = yylloc_current;])[ | |
1661 | } | |
520181ab | 1662 | return yyflag; |
01241d47 PH |
1663 | } |
1664 | ||
5f108727 | 1665 | #if ]b4_api_PREFIX[DEBUG |
e7cb57c0 AD |
1666 | static void |
1667 | yyreportTree (yySemanticOption* yyx, int yyindent) | |
01241d47 PH |
1668 | { |
1669 | int yynrhs = yyrhsLength (yyx->yyrule); | |
1670 | int yyi; | |
1671 | yyGLRState* yys; | |
9138c575 | 1672 | yyGLRState* yystates[1 + YYMAXRHS]; |
782a05f9 | 1673 | yyGLRState yyleftmost_state; |
01241d47 | 1674 | |
39912f52 | 1675 | for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred) |
01241d47 | 1676 | yystates[yyi] = yys; |
ef51bfa7 | 1677 | if (yys == YY_NULL) |
782a05f9 PE |
1678 | { |
1679 | yyleftmost_state.yyposn = 0; | |
1680 | yystates[0] = &yyleftmost_state; | |
1681 | } | |
01241d47 PH |
1682 | else |
1683 | yystates[0] = yys; | |
1684 | ||
39912f52 | 1685 | if (yyx->yystate->yyposn < yys->yyposn + 1) |
01241d47 | 1686 | YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n", |
7020e5f0 AD |
1687 | yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)), |
1688 | yyx->yyrule - 1); | |
01241d47 | 1689 | else |
08fc98e5 | 1690 | YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n", |
7020e5f0 AD |
1691 | yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)), |
1692 | yyx->yyrule - 1, (unsigned long int) (yys->yyposn + 1), | |
1693 | (unsigned long int) yyx->yystate->yyposn); | |
fb8135fa | 1694 | for (yyi = 1; yyi <= yynrhs; yyi += 1) |
01241d47 | 1695 | { |
fb8135fa | 1696 | if (yystates[yyi]->yyresolved) |
7020e5f0 AD |
1697 | { |
1698 | if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn) | |
1699 | YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "", | |
1700 | yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1])); | |
1701 | else | |
1702 | YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "", | |
1703 | yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]), | |
1704 | (unsigned long int) (yystates[yyi - 1]->yyposn + 1), | |
1705 | (unsigned long int) yystates[yyi]->yyposn); | |
1706 | } | |
fb8135fa | 1707 | else |
7020e5f0 | 1708 | yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2); |
01241d47 PH |
1709 | } |
1710 | } | |
fb8135fa | 1711 | #endif |
01241d47 | 1712 | |
35ee866a JD |
1713 | /*ARGSUSED*/ static YYRESULTTAG |
1714 | yyreportAmbiguity (yySemanticOption* yyx0, | |
7020e5f0 | 1715 | yySemanticOption* yyx1]b4_pure_formals[) |
01241d47 | 1716 | { |
2a4647a3 PE |
1717 | YYUSE (yyx0); |
1718 | YYUSE (yyx1); | |
1154cced | 1719 | |
5f108727 | 1720 | #if ]b4_api_PREFIX[DEBUG |
2f4f028d PE |
1721 | YYFPRINTF (stderr, "Ambiguity detected.\n"); |
1722 | YYFPRINTF (stderr, "Option 1,\n"); | |
01241d47 | 1723 | yyreportTree (yyx0, 2); |
2f4f028d | 1724 | YYFPRINTF (stderr, "\nOption 2,\n"); |
01241d47 | 1725 | yyreportTree (yyx1, 2); |
2f4f028d | 1726 | YYFPRINTF (stderr, "\n"); |
01241d47 | 1727 | #endif |
35ee866a JD |
1728 | |
1729 | yyerror (]b4_yyerror_args[YY_("syntax is ambiguous")); | |
1730 | return yyabort; | |
55dd3563 | 1731 | }]b4_locations_if([[ |
01241d47 | 1732 | |
6d05403d PE |
1733 | /** Starting at and including state S1, resolve the location for each of the |
1734 | * previous N1 states that is unresolved. The first semantic option of a state | |
8710fc41 JD |
1735 | * is always chosen. */ |
1736 | static void | |
6d05403d | 1737 | yyresolveLocations (yyGLRState* yys1, int yyn1, |
7020e5f0 | 1738 | yyGLRStack *yystackp]b4_user_formals[) |
8710fc41 | 1739 | { |
6d05403d | 1740 | if (0 < yyn1) |
8710fc41 | 1741 | { |
6d05403d PE |
1742 | yyresolveLocations (yys1->yypred, yyn1 - 1, yystackp]b4_user_args[); |
1743 | if (!yys1->yyresolved) | |
7020e5f0 | 1744 | { |
7020e5f0 AD |
1745 | yyGLRStackItem yyrhsloc[1 + YYMAXRHS]; |
1746 | int yynrhs; | |
aebb55eb | 1747 | yySemanticOption *yyoption = yys1->yysemantics.yyfirstVal; |
7020e5f0 AD |
1748 | YYASSERT (yyoption != YY_NULL); |
1749 | yynrhs = yyrhsLength (yyoption->yyrule); | |
1750 | if (yynrhs > 0) | |
1751 | { | |
1752 | yyGLRState *yys; | |
1753 | int yyn; | |
1754 | yyresolveLocations (yyoption->yystate, yynrhs, | |
1755 | yystackp]b4_user_args[); | |
1756 | for (yys = yyoption->yystate, yyn = yynrhs; | |
1757 | yyn > 0; | |
1758 | yys = yys->yypred, yyn -= 1) | |
1759 | yyrhsloc[yyn].yystate.yyloc = yys->yyloc; | |
1760 | } | |
1761 | else | |
1762 | { | |
1763 | /* Both yyresolveAction and yyresolveLocations traverse the GSS | |
1764 | in reverse rightmost order. It is only necessary to invoke | |
1765 | yyresolveLocations on a subforest for which yyresolveAction | |
1766 | would have been invoked next had an ambiguity not been | |
1767 | detected. Thus the location of the previous state (but not | |
1768 | necessarily the previous state itself) is guaranteed to be | |
1769 | resolved already. */ | |
1770 | yyGLRState *yyprevious = yyoption->yystate; | |
1771 | yyrhsloc[0].yystate.yyloc = yyprevious->yyloc; | |
1772 | } | |
aebb55eb AD |
1773 | { |
1774 | int yychar_current = yychar; | |
1775 | YYSTYPE yylval_current = yylval; | |
1776 | YYLTYPE yylloc_current = yylloc; | |
1777 | yychar = yyoption->yyrawchar; | |
1778 | yylval = yyoption->yyval; | |
1779 | yylloc = yyoption->yyloc; | |
1780 | YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs); | |
1781 | yychar = yychar_current; | |
1782 | yylval = yylval_current; | |
1783 | yylloc = yylloc_current; | |
1784 | } | |
7020e5f0 | 1785 | } |
8710fc41 | 1786 | } |
55dd3563 | 1787 | }]])[ |
01241d47 | 1788 | |
d659304d | 1789 | /** Resolve the ambiguity represented in state S, perform the indicated |
520181ab JD |
1790 | * actions, and set the semantic value of S. If result != yyok, the chain of |
1791 | * semantic options in S has been cleared instead or it has been left | |
1792 | * unmodified except that redundant options may have been removed. Regardless | |
1793 | * of whether result = yyok, S has been left with consistent data so that | |
1794 | * yydestroyGLRState can be invoked if necessary. */ | |
01241d47 | 1795 | static YYRESULTTAG |
520181ab | 1796 | yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[) |
01241d47 | 1797 | { |
d659304d | 1798 | yySemanticOption* yyoptionList = yys->yysemantics.yyfirstVal; |
769a8ef9 | 1799 | yySemanticOption* yybest = yyoptionList; |
f9315de5 | 1800 | yySemanticOption** yypp; |
769a8ef9 | 1801 | yybool yymerge = yyfalse; |
520181ab | 1802 | YYSTYPE yysval; |
769a8ef9 AD |
1803 | YYRESULTTAG yyflag;]b4_locations_if([ |
1804 | YYLTYPE *yylocp = &yys->yyloc;])[ | |
01241d47 | 1805 | |
ef51bfa7 | 1806 | for (yypp = &yyoptionList->yynext; *yypp != YY_NULL; ) |
01241d47 | 1807 | { |
f9315de5 PE |
1808 | yySemanticOption* yyp = *yypp; |
1809 | ||
01241d47 | 1810 | if (yyidenticalOptions (yybest, yyp)) |
7020e5f0 AD |
1811 | { |
1812 | yymergeOptionSets (yybest, yyp); | |
1813 | *yypp = yyp->yynext; | |
1814 | } | |
01241d47 | 1815 | else |
7020e5f0 AD |
1816 | { |
1817 | switch (yypreference (yybest, yyp)) | |
1818 | { | |
1819 | case 0:]b4_locations_if([[ | |
1820 | yyresolveLocations (yys, 1, yystackp]b4_user_args[);]])[ | |
1821 | return yyreportAmbiguity (yybest, yyp]b4_pure_args[); | |
1822 | break; | |
1823 | case 1: | |
1824 | yymerge = yytrue; | |
1825 | break; | |
1826 | case 2: | |
1827 | break; | |
1828 | case 3: | |
1829 | yybest = yyp; | |
1830 | yymerge = yyfalse; | |
1831 | break; | |
1832 | default: | |
1833 | /* This cannot happen so it is not worth a YYASSERT (yyfalse), | |
1834 | but some compilers complain if the default case is | |
1835 | omitted. */ | |
1836 | break; | |
1837 | } | |
1838 | yypp = &yyp->yynext; | |
1839 | } | |
01241d47 PH |
1840 | } |
1841 | ||
fb8135fa | 1842 | if (yymerge) |
01241d47 | 1843 | { |
f9315de5 | 1844 | yySemanticOption* yyp; |
01241d47 | 1845 | int yyprec = yydprec[yybest->yyrule]; |
769a8ef9 | 1846 | yyflag = yyresolveAction (yybest, yystackp, &yysval]b4_locuser_args[); |
520181ab | 1847 | if (yyflag == yyok) |
7020e5f0 AD |
1848 | for (yyp = yybest->yynext; yyp != YY_NULL; yyp = yyp->yynext) |
1849 | { | |
1850 | if (yyprec == yydprec[yyp->yyrule]) | |
1851 | { | |
1852 | YYSTYPE yysval_other;]b4_locations_if([ | |
769a8ef9 AD |
1853 | YYLTYPE yydummy;])[ |
1854 | yyflag = yyresolveAction (yyp, yystackp, &yysval_other]b4_locuser_args([&yydummy])[); | |
7020e5f0 AD |
1855 | if (yyflag != yyok) |
1856 | { | |
1857 | yydestruct ("Cleanup: discarding incompletely merged value for", | |
1858 | yystos[yys->yylrState], | |
1859 | &yysval]b4_locuser_args[); | |
1860 | break; | |
1861 | } | |
1862 | yyuserMerge (yymerger[yyp->yyrule], &yysval, &yysval_other); | |
1863 | } | |
1864 | } | |
520181ab JD |
1865 | } |
1866 | else | |
769a8ef9 | 1867 | yyflag = yyresolveAction (yybest, yystackp, &yysval]b4_locuser_args([yylocp])[); |
520181ab JD |
1868 | |
1869 | if (yyflag == yyok) | |
1870 | { | |
1871 | yys->yyresolved = yytrue; | |
1872 | yys->yysemantics.yysval = yysval; | |
01241d47 PH |
1873 | } |
1874 | else | |
ef51bfa7 | 1875 | yys->yysemantics.yyfirstVal = YY_NULL; |
520181ab | 1876 | return yyflag; |
01241d47 PH |
1877 | } |
1878 | ||
1879 | static YYRESULTTAG | |
3e7a2cd9 | 1880 | yyresolveStack (yyGLRStack* yystackp]b4_user_formals[) |
01241d47 | 1881 | { |
ef51bfa7 | 1882 | if (yystackp->yysplitPoint != YY_NULL) |
01241d47 PH |
1883 | { |
1884 | yyGLRState* yys; | |
1885 | int yyn; | |
1886 | ||
3e7a2cd9 | 1887 | for (yyn = 0, yys = yystackp->yytops.yystates[0]; |
7020e5f0 AD |
1888 | yys != yystackp->yysplitPoint; |
1889 | yys = yys->yypred, yyn += 1) | |
1890 | continue; | |
3e7a2cd9 | 1891 | YYCHK (yyresolveStates (yystackp->yytops.yystates[0], yyn, yystackp |
7020e5f0 | 1892 | ]b4_user_args[)); |
01241d47 PH |
1893 | } |
1894 | return yyok; | |
1895 | } | |
1896 | ||
1897 | static void | |
3e7a2cd9 | 1898 | yycompressStack (yyGLRStack* yystackp) |
01241d47 PH |
1899 | { |
1900 | yyGLRState* yyp, *yyq, *yyr; | |
1901 | ||
ef51bfa7 | 1902 | if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == YY_NULL) |
01241d47 PH |
1903 | return; |
1904 | ||
ef51bfa7 | 1905 | for (yyp = yystackp->yytops.yystates[0], yyq = yyp->yypred, yyr = YY_NULL; |
3e7a2cd9 | 1906 | yyp != yystackp->yysplitPoint; |
01241d47 PH |
1907 | yyr = yyp, yyp = yyq, yyq = yyp->yypred) |
1908 | yyp->yypred = yyr; | |
fb8135fa | 1909 | |
3e7a2cd9 PE |
1910 | yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems; |
1911 | yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1; | |
1912 | yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems; | |
ef51bfa7 AD |
1913 | yystackp->yysplitPoint = YY_NULL; |
1914 | yystackp->yylastDeleted = YY_NULL; | |
fb8135fa | 1915 | |
ef51bfa7 | 1916 | while (yyr != YY_NULL) |
fb8135fa | 1917 | { |
3e7a2cd9 | 1918 | yystackp->yynextFree->yystate = *yyr; |
01241d47 | 1919 | yyr = yyr->yypred; |
3e7a2cd9 PE |
1920 | yystackp->yynextFree->yystate.yypred = &yystackp->yynextFree[-1].yystate; |
1921 | yystackp->yytops.yystates[0] = &yystackp->yynextFree->yystate; | |
1922 | yystackp->yynextFree += 1; | |
1923 | yystackp->yyspaceLeft -= 1; | |
01241d47 PH |
1924 | } |
1925 | } | |
1926 | ||
1927 | static YYRESULTTAG | |
3e7a2cd9 | 1928 | yyprocessOneStack (yyGLRStack* yystackp, size_t yyk, |
7020e5f0 | 1929 | size_t yyposn]b4_pure_formals[) |
01241d47 PH |
1930 | { |
1931 | int yyaction; | |
779e7ceb | 1932 | const short int* yyconflicts; |
01241d47 | 1933 | yyRuleNum yyrule; |
01241d47 | 1934 | |
ef51bfa7 | 1935 | while (yystackp->yytops.yystates[yyk] != YY_NULL) |
01241d47 | 1936 | { |
3e7a2cd9 | 1937 | yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState; |
63cb01d6 | 1938 | YYDPRINTF ((stderr, "Stack %lu Entering state %d\n", |
7020e5f0 | 1939 | (unsigned long int) yyk, yystate)); |
01241d47 | 1940 | |
64c4fd52 PE |
1941 | YYASSERT (yystate != YYFINAL); |
1942 | ||
fb8135fa | 1943 | if (yyisDefaultedState (yystate)) |
7020e5f0 AD |
1944 | { |
1945 | yyrule = yydefaultAction (yystate); | |
1946 | if (yyrule == 0) | |
1947 | { | |
1948 | YYDPRINTF ((stderr, "Stack %lu dies.\n", | |
1949 | (unsigned long int) yyk)); | |
1950 | yymarkStackDeleted (yystackp, yyk); | |
1951 | return yyok; | |
1952 | } | |
1953 | YYCHK (yyglrReduce (yystackp, yyk, yyrule, yyfalse]b4_user_args[)); | |
1954 | } | |
fb8135fa | 1955 | else |
7020e5f0 AD |
1956 | { |
1957 | yySymbol yytoken; | |
1958 | yystackp->yytops.yylookaheadNeeds[yyk] = yytrue; | |
1959 | if (yychar == YYEMPTY) | |
1960 | { | |
1961 | YYDPRINTF ((stderr, "Reading a token: ")); | |
1962 | yychar = YYLEX; | |
1963 | } | |
1964 | ||
1965 | if (yychar <= YYEOF) | |
1966 | { | |
1967 | yychar = yytoken = YYEOF; | |
1968 | YYDPRINTF ((stderr, "Now at end of input.\n")); | |
1969 | } | |
1970 | else | |
1971 | { | |
1972 | yytoken = YYTRANSLATE (yychar); | |
1973 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); | |
1974 | } | |
1975 | ||
1976 | yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts); | |
1977 | ||
1978 | while (*yyconflicts != 0) | |
1979 | { | |
1980 | size_t yynewStack = yysplitStack (yystackp, yyk); | |
1981 | YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n", | |
1982 | (unsigned long int) yynewStack, | |
1983 | (unsigned long int) yyk)); | |
1984 | YYCHK (yyglrReduce (yystackp, yynewStack, | |
1985 | *yyconflicts, yyfalse]b4_user_args[)); | |
1986 | YYCHK (yyprocessOneStack (yystackp, yynewStack, | |
1987 | yyposn]b4_pure_args[)); | |
1988 | yyconflicts += 1; | |
1989 | } | |
1990 | ||
1991 | if (yyisShiftAction (yyaction)) | |
1992 | break; | |
1993 | else if (yyisErrorAction (yyaction)) | |
1994 | { | |
1995 | YYDPRINTF ((stderr, "Stack %lu dies.\n", | |
1996 | (unsigned long int) yyk)); | |
1997 | yymarkStackDeleted (yystackp, yyk); | |
1998 | break; | |
1999 | } | |
2000 | else | |
2001 | YYCHK (yyglrReduce (yystackp, yyk, -yyaction, | |
2002 | yyfalse]b4_user_args[)); | |
2003 | } | |
01241d47 PH |
2004 | } |
2005 | return yyok; | |
2006 | } | |
2007 | ||
3e7a2cd9 | 2008 | /*ARGSUSED*/ static void |
d6cff4dc | 2009 | yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[) |
01241d47 | 2010 | { |
678094a2 JD |
2011 | if (yystackp->yyerrState != 0) |
2012 | return; | |
2013 | #if ! YYERROR_VERBOSE | |
2014 | yyerror (]b4_lyyerror_args[YY_("syntax error")); | |
2015 | #else | |
095a1d11 | 2016 | yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); |
ef51bfa7 | 2017 | size_t yysize0 = yytnamerr (YY_NULL, yytokenName (yytoken)); |
f953cb20 | 2018 | size_t yysize = yysize0; |
f953cb20 | 2019 | yybool yysize_overflow = yyfalse; |
ef51bfa7 | 2020 | char* yymsg = YY_NULL; |
f953cb20 JD |
2021 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; |
2022 | /* Internationalized format string. */ | |
ef51bfa7 | 2023 | const char *yyformat = YY_NULL; |
f953cb20 JD |
2024 | /* Arguments of yyformat. */ |
2025 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; | |
095a1d11 JD |
2026 | /* Number of reported tokens (one for the "unexpected", one per |
2027 | "expected"). */ | |
2028 | int yycount = 0; | |
f953cb20 | 2029 | |
095a1d11 JD |
2030 | /* There are many possibilities here to consider: |
2031 | - If this state is a consistent state with a default action, then | |
2032 | the only way this function was invoked is if the default action | |
2033 | is an error action. In that case, don't check for expected | |
2034 | tokens because there are none. | |
2035 | - The only way there can be no lookahead present (in yychar) is if | |
2036 | this state is a consistent state with a default action. Thus, | |
2037 | detecting the absence of a lookahead is sufficient to determine | |
2038 | that there is no unexpected or expected token to report. In that | |
2039 | case, just report a simple "syntax error". | |
2040 | - Don't assume there isn't a lookahead just because this state is a | |
2041 | consistent state with a default action. There might have been a | |
2042 | previous inconsistent state, consistent state with a non-default | |
2043 | action, or user semantic action that manipulated yychar. | |
2044 | - Of course, the expected token list depends on states to have | |
2045 | correct lookahead information, and it depends on the parser not | |
2046 | to perform extra reductions after fetching a lookahead from the | |
2047 | scanner and before detecting a syntax error. Thus, state merging | |
2048 | (from LALR or IELR) and default reductions corrupt the expected | |
2049 | token list. However, the list is correct for canonical LR with | |
2050 | one exception: it will still contain any token that will not be | |
2051 | accepted due to an error action in a later state. | |
2052 | */ | |
2053 | if (yytoken != YYEMPTY) | |
2054 | { | |
2055 | int yyn = yypact[yystackp->yytops.yystates[0]->yylrState]; | |
2056 | yyarg[yycount++] = yytokenName (yytoken); | |
2057 | if (!yypact_value_is_default (yyn)) | |
2058 | { | |
f953cb20 JD |
2059 | /* Start YYX at -YYN if negative to avoid negative indexes in |
2060 | YYCHECK. In other words, skip the first -YYN actions for this | |
2061 | state because they are default actions. */ | |
2062 | int yyxbegin = yyn < 0 ? -yyn : 0; | |
f953cb20 JD |
2063 | /* Stay within bounds of both yycheck and yytname. */ |
2064 | int yychecklim = YYLAST - yyn + 1; | |
2065 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; | |
bb57985c | 2066 | int yyx; |
f953cb20 JD |
2067 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
2068 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR | |
2069 | && !yytable_value_is_error (yytable[yyx + yyn])) | |
2070 | { | |
2071 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) | |
2072 | { | |
2073 | yycount = 1; | |
2074 | yysize = yysize0; | |
2075 | break; | |
2076 | } | |
2077 | yyarg[yycount++] = yytokenName (yyx); | |
fc28638e AD |
2078 | { |
2079 | size_t yysz = yysize + yytnamerr (YY_NULL, yytokenName (yyx)); | |
2080 | yysize_overflow |= yysz < yysize; | |
2081 | yysize = yysz; | |
2082 | } | |
f953cb20 | 2083 | } |
095a1d11 JD |
2084 | } |
2085 | } | |
f953cb20 JD |
2086 | |
2087 | switch (yycount) | |
2088 | { | |
2089 | #define YYCASE_(N, S) \ | |
2090 | case N: \ | |
2091 | yyformat = S; \ | |
2092 | break | |
095a1d11 | 2093 | YYCASE_(0, YY_("syntax error")); |
f953cb20 JD |
2094 | YYCASE_(1, YY_("syntax error, unexpected %s")); |
2095 | YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); | |
2096 | YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); | |
2097 | YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); | |
2098 | YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); | |
bb57985c | 2099 | #undef YYCASE_ |
f953cb20 | 2100 | } |
bb57985c | 2101 | |
fc28638e AD |
2102 | { |
2103 | size_t yysz = yysize + strlen (yyformat); | |
2104 | yysize_overflow |= yysz < yysize; | |
2105 | yysize = yysz; | |
2106 | } | |
63cb01d6 | 2107 | |
f953cb20 JD |
2108 | if (!yysize_overflow) |
2109 | yymsg = (char *) YYMALLOC (yysize); | |
63cb01d6 | 2110 | |
f953cb20 JD |
2111 | if (yymsg) |
2112 | { | |
2113 | char *yyp = yymsg; | |
2114 | int yyi = 0; | |
2115 | while ((*yyp = *yyformat)) | |
2116 | { | |
2117 | if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) | |
2118 | { | |
2119 | yyp += yytnamerr (yyp, yyarg[yyi++]); | |
2120 | yyformat += 2; | |
2121 | } | |
2122 | else | |
2123 | { | |
2124 | yyp++; | |
2125 | yyformat++; | |
2126 | } | |
2127 | } | |
2128 | yyerror (]b4_lyyerror_args[yymsg); | |
2129 | YYFREE (yymsg); | |
2130 | } | |
2131 | else | |
2132 | { | |
2133 | yyerror (]b4_lyyerror_args[YY_("syntax error")); | |
2134 | yyMemoryExhausted (yystackp); | |
01241d47 | 2135 | } |
678094a2 | 2136 | #endif /* YYERROR_VERBOSE */ |
f953cb20 JD |
2137 | yynerrs += 1; |
2138 | } | |
01241d47 | 2139 | |
d6cff4dc AD |
2140 | /* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP, |
2141 | yylval, and yylloc are the syntactic category, semantic value, and location | |
742e4900 | 2142 | of the lookahead. */ |
12ce2df6 | 2143 | /*ARGSUSED*/ static void |
d6cff4dc | 2144 | yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) |
01241d47 | 2145 | { |
1154cced AD |
2146 | size_t yyk; |
2147 | int yyj; | |
01241d47 | 2148 | |
3e7a2cd9 | 2149 | if (yystackp->yyerrState == 3) |
2a1fe6ed AD |
2150 | /* We just shifted the error token and (perhaps) took some |
2151 | reductions. Skip tokens until we can proceed. */ | |
3e7a2cd9 | 2152 | while (YYID (yytrue)) |
2a1fe6ed | 2153 | { |
7020e5f0 AD |
2154 | yySymbol yytoken; |
2155 | if (yychar == YYEOF) | |
2156 | yyFail (yystackp][]b4_lpure_args[, YY_NULL); | |
2157 | if (yychar != YYEMPTY) | |
2158 | {]b4_locations_if([[ | |
2159 | /* We throw away the lookahead, but the error range | |
2160 | of the shifted error token must take it into account. */ | |
2161 | yyGLRState *yys = yystackp->yytops.yystates[0]; | |
2162 | yyGLRStackItem yyerror_range[3]; | |
2163 | yyerror_range[1].yystate.yyloc = yys->yyloc; | |
2164 | yyerror_range[2].yystate.yyloc = yylloc; | |
2165 | YYLLOC_DEFAULT ((yys->yyloc), yyerror_range, 2);]])[ | |
2166 | yytoken = YYTRANSLATE (yychar); | |
2167 | yydestruct ("Error: discarding", | |
2168 | yytoken, &yylval]b4_locuser_args([&yylloc])[); | |
2169 | } | |
2170 | YYDPRINTF ((stderr, "Reading a token: ")); | |
2171 | yychar = YYLEX; | |
2172 | if (yychar <= YYEOF) | |
2173 | { | |
2174 | yychar = yytoken = YYEOF; | |
2175 | YYDPRINTF ((stderr, "Now at end of input.\n")); | |
2176 | } | |
2177 | else | |
2178 | { | |
2179 | yytoken = YYTRANSLATE (yychar); | |
2180 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); | |
2181 | } | |
2182 | yyj = yypact[yystackp->yytops.yystates[0]->yylrState]; | |
2183 | if (yypact_value_is_default (yyj)) | |
2184 | return; | |
2185 | yyj += yytoken; | |
2186 | if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != yytoken) | |
2187 | { | |
2188 | if (yydefact[yystackp->yytops.yystates[0]->yylrState] != 0) | |
2189 | return; | |
2190 | } | |
2191 | else if (! yytable_value_is_error (yytable[yyj])) | |
2192 | return; | |
2a1fe6ed | 2193 | } |
fb8135fa | 2194 | |
2a1fe6ed | 2195 | /* Reduce to one stack. */ |
3e7a2cd9 | 2196 | for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1) |
ef51bfa7 | 2197 | if (yystackp->yytops.yystates[yyk] != YY_NULL) |
01241d47 | 2198 | break; |
3e7a2cd9 | 2199 | if (yyk >= yystackp->yytops.yysize) |
ef51bfa7 | 2200 | yyFail (yystackp][]b4_lpure_args[, YY_NULL); |
3e7a2cd9 PE |
2201 | for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1) |
2202 | yymarkStackDeleted (yystackp, yyk); | |
2203 | yyremoveDeletes (yystackp); | |
2204 | yycompressStack (yystackp); | |
01241d47 | 2205 | |
9d9b8b70 | 2206 | /* Now pop stack until we find a state that shifts the error token. */ |
3e7a2cd9 | 2207 | yystackp->yyerrState = 3; |
ef51bfa7 | 2208 | while (yystackp->yytops.yystates[0] != YY_NULL) |
01241d47 | 2209 | { |
3e7a2cd9 | 2210 | yyGLRState *yys = yystackp->yytops.yystates[0]; |
7bd6c77e | 2211 | yyj = yypact[yys->yylrState]; |
d5eb0826 | 2212 | if (! yypact_value_is_default (yyj)) |
7020e5f0 AD |
2213 | { |
2214 | yyj += YYTERROR; | |
2215 | if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR | |
2216 | && yyisShiftAction (yytable[yyj])) | |
2217 | { | |
2218 | /* Shift the error token. */]b4_locations_if([[ | |
2219 | /* First adjust its location.*/ | |
769a8ef9 | 2220 | YYLTYPE yyerrloc; |
7020e5f0 AD |
2221 | yystackp->yyerror_range[2].yystate.yyloc = yylloc; |
2222 | YYLLOC_DEFAULT (yyerrloc, (yystackp->yyerror_range), 2);]])[ | |
2223 | YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]], | |
2224 | &yylval, &yyerrloc); | |
2225 | yyglrShift (yystackp, 0, yytable[yyj], | |
2226 | yys->yyposn, &yylval]b4_locations_if([, &yyerrloc])[); | |
2227 | yys = yystackp->yytops.yystates[0]; | |
2228 | break; | |
2229 | } | |
2230 | }]b4_locations_if([[ | |
769a8ef9 | 2231 | yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[ |
ef51bfa7 | 2232 | if (yys->yypred != YY_NULL) |
7020e5f0 | 2233 | yydestroyGLRState ("Error: popping", yys]b4_user_args[); |
3e7a2cd9 PE |
2234 | yystackp->yytops.yystates[0] = yys->yypred; |
2235 | yystackp->yynextFree -= 1; | |
2236 | yystackp->yyspaceLeft += 1; | |
01241d47 | 2237 | } |
ef51bfa7 AD |
2238 | if (yystackp->yytops.yystates[0] == YY_NULL) |
2239 | yyFail (yystackp][]b4_lpure_args[, YY_NULL); | |
fb8135fa AD |
2240 | } |
2241 | ||
7020e5f0 AD |
2242 | #define YYCHK1(YYE) \ |
2243 | do { \ | |
2244 | switch (YYE) { \ | |
2245 | case yyok: \ | |
2246 | break; \ | |
2247 | case yyabort: \ | |
2248 | goto yyabortlab; \ | |
2249 | case yyaccept: \ | |
2250 | goto yyacceptlab; \ | |
2251 | case yyerr: \ | |
2252 | goto yyuser_error; \ | |
2253 | default: \ | |
2254 | goto yybuglab; \ | |
2255 | } \ | |
12ce2df6 | 2256 | } while (YYID (0)) |
01241d47 | 2257 | |
0245f82d AD |
2258 | |
2259 | /*----------. | |
2260 | | yyparse. | | |
2261 | `----------*/ | |
2262 | ||
2263 | ]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[ | |
01241d47 | 2264 | { |
6100a9aa | 2265 | int yyresult; |
01241d47 | 2266 | yyGLRStack yystack; |
d6cff4dc | 2267 | yyGLRStack* const yystackp = &yystack; |
01241d47 | 2268 | size_t yyposn; |
fb8135fa | 2269 | |
2f4f028d | 2270 | YYDPRINTF ((stderr, "Starting parse\n")); |
2a1fe6ed | 2271 | |
bf70fa87 | 2272 | yychar = YYEMPTY; |
a68b1f23 AD |
2273 | yylval = yyval_default;]b4_locations_if([ |
2274 | yylloc = yyloc_default;])[ | |
2275 | ]m4_ifdef([b4_initial_action], [ | |
cd735a8c AD |
2276 | b4_dollar_pushdef([yylval], [], [yylloc])dnl |
2277 | /* User initialization code. */ | |
2278 | b4_user_initial_action | |
2279 | b4_dollar_popdef])[]dnl | |
b8458aa5 | 2280 | [ |
d6cff4dc | 2281 | if (! yyinitGLRStack (yystackp, YYINITDEPTH)) |
1a059451 | 2282 | goto yyexhaustedlab; |
c89b4c03 | 2283 | switch (YYSETJMP (yystack.yyexception_buffer)) |
6100a9aa | 2284 | { |
c89b4c03 | 2285 | case 0: break; |
6100a9aa | 2286 | case 1: goto yyabortlab; |
1a059451 | 2287 | case 2: goto yyexhaustedlab; |
c89b4c03 | 2288 | default: goto yybuglab; |
6100a9aa | 2289 | } |
769a8ef9 | 2290 | yyglrShift (&yystack, 0, 0, 0, &yylval]b4_locations_if([, &yylloc])[); |
01241d47 PH |
2291 | yyposn = 0; |
2292 | ||
3e7a2cd9 | 2293 | while (YYID (yytrue)) |
01241d47 | 2294 | { |
21964f43 | 2295 | /* For efficiency, we have two loops, the first of which is |
7020e5f0 AD |
2296 | specialized to deterministic operation (single stack, no |
2297 | potential ambiguity). */ | |
01241d47 | 2298 | /* Standard mode */ |
3e7a2cd9 | 2299 | while (YYID (yytrue)) |
7020e5f0 AD |
2300 | { |
2301 | yyRuleNum yyrule; | |
2302 | int yyaction; | |
2303 | const short int* yyconflicts; | |
2304 | ||
2305 | yyStateNum yystate = yystack.yytops.yystates[0]->yylrState; | |
2306 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); | |
2307 | if (yystate == YYFINAL) | |
2308 | goto yyacceptlab; | |
2309 | if (yyisDefaultedState (yystate)) | |
2310 | { | |
2311 | yyrule = yydefaultAction (yystate); | |
2312 | if (yyrule == 0) | |
2313 | { | |
2314 | ]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ | |
2315 | yyreportSyntaxError (&yystack]b4_user_args[); | |
2316 | goto yyuser_error; | |
2317 | } | |
2318 | YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue]b4_user_args[)); | |
2319 | } | |
2320 | else | |
2321 | { | |
2322 | yySymbol yytoken; | |
2323 | if (yychar == YYEMPTY) | |
2324 | { | |
2325 | YYDPRINTF ((stderr, "Reading a token: ")); | |
2326 | yychar = YYLEX; | |
2327 | } | |
2328 | ||
2329 | if (yychar <= YYEOF) | |
2330 | { | |
2331 | yychar = yytoken = YYEOF; | |
2332 | YYDPRINTF ((stderr, "Now at end of input.\n")); | |
2333 | } | |
2334 | else | |
2335 | { | |
2336 | yytoken = YYTRANSLATE (yychar); | |
2337 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); | |
2338 | } | |
2339 | ||
2340 | yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts); | |
2341 | if (*yyconflicts != 0) | |
2342 | break; | |
2343 | if (yyisShiftAction (yyaction)) | |
2344 | { | |
2345 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); | |
2346 | yychar = YYEMPTY; | |
2347 | yyposn += 1; | |
2348 | yyglrShift (&yystack, 0, yyaction, yyposn, &yylval]b4_locations_if([, &yylloc])[); | |
2349 | if (0 < yystack.yyerrState) | |
2350 | yystack.yyerrState -= 1; | |
2351 | } | |
2352 | else if (yyisErrorAction (yyaction)) | |
2353 | { | |
2354 | ]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ | |
2355 | yyreportSyntaxError (&yystack]b4_user_args[); | |
2356 | goto yyuser_error; | |
2357 | } | |
2358 | else | |
2359 | YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue]b4_user_args[)); | |
2360 | } | |
2361 | } | |
01241d47 | 2362 | |
3e7a2cd9 | 2363 | while (YYID (yytrue)) |
7020e5f0 AD |
2364 | { |
2365 | yySymbol yytoken_to_shift; | |
2366 | size_t yys; | |
2367 | ||
2368 | for (yys = 0; yys < yystack.yytops.yysize; yys += 1) | |
2369 | yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY; | |
2370 | ||
2371 | /* yyprocessOneStack returns one of three things: | |
2372 | ||
2373 | - An error flag. If the caller is yyprocessOneStack, it | |
2374 | immediately returns as well. When the caller is finally | |
2375 | yyparse, it jumps to an error label via YYCHK1. | |
2376 | ||
2377 | - yyok, but yyprocessOneStack has invoked yymarkStackDeleted | |
2378 | (&yystack, yys), which sets the top state of yys to NULL. Thus, | |
2379 | yyparse's following invocation of yyremoveDeletes will remove | |
2380 | the stack. | |
2381 | ||
2382 | - yyok, when ready to shift a token. | |
2383 | ||
2384 | Except in the first case, yyparse will invoke yyremoveDeletes and | |
2385 | then shift the next token onto all remaining stacks. This | |
2386 | synchronization of the shift (that is, after all preceding | |
2387 | reductions on all stacks) helps prevent double destructor calls | |
2388 | on yylval in the event of memory exhaustion. */ | |
2389 | ||
2390 | for (yys = 0; yys < yystack.yytops.yysize; yys += 1) | |
2391 | YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn]b4_lpure_args[)); | |
2392 | yyremoveDeletes (&yystack); | |
2393 | if (yystack.yytops.yysize == 0) | |
2394 | { | |
2395 | yyundeleteLastStack (&yystack); | |
2396 | if (yystack.yytops.yysize == 0) | |
2397 | yyFail (&yystack][]b4_lpure_args[, YY_("syntax error")); | |
2398 | YYCHK1 (yyresolveStack (&yystack]b4_user_args[)); | |
2399 | YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); | |
2400 | ]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ | |
2401 | yyreportSyntaxError (&yystack]b4_user_args[); | |
2402 | goto yyuser_error; | |
2403 | } | |
2404 | ||
2405 | /* If any yyglrShift call fails, it will fail after shifting. Thus, | |
2406 | a copy of yylval will already be on stack 0 in the event of a | |
2407 | failure in the following loop. Thus, yychar is set to YYEMPTY | |
2408 | before the loop to make sure the user destructor for yylval isn't | |
2409 | called twice. */ | |
2410 | yytoken_to_shift = YYTRANSLATE (yychar); | |
2411 | yychar = YYEMPTY; | |
2412 | yyposn += 1; | |
2413 | for (yys = 0; yys < yystack.yytops.yysize; yys += 1) | |
2414 | { | |
2415 | int yyaction; | |
2416 | const short int* yyconflicts; | |
2417 | yyStateNum yystate = yystack.yytops.yystates[yys]->yylrState; | |
2418 | yygetLRActions (yystate, yytoken_to_shift, &yyaction, | |
2419 | &yyconflicts); | |
2420 | /* Note that yyconflicts were handled by yyprocessOneStack. */ | |
2421 | YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long int) yys)); | |
2422 | YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc); | |
2423 | yyglrShift (&yystack, yys, yyaction, yyposn, | |
2424 | &yylval]b4_locations_if([, &yylloc])[); | |
2425 | YYDPRINTF ((stderr, "Stack %lu now in state #%d\n", | |
2426 | (unsigned long int) yys, | |
2427 | yystack.yytops.yystates[yys]->yylrState)); | |
2428 | } | |
2429 | ||
2430 | if (yystack.yytops.yysize == 1) | |
2431 | { | |
2432 | YYCHK1 (yyresolveStack (&yystack]b4_user_args[)); | |
2433 | YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); | |
2434 | yycompressStack (&yystack); | |
2435 | break; | |
2436 | } | |
2437 | } | |
01241d47 PH |
2438 | continue; |
2439 | yyuser_error: | |
d6cff4dc | 2440 | yyrecoverSyntaxError (&yystack]b4_user_args[); |
01241d47 PH |
2441 | yyposn = yystack.yytops.yystates[0]->yyposn; |
2442 | } | |
6100a9aa PE |
2443 | |
2444 | yyacceptlab: | |
2445 | yyresult = 0; | |
2446 | goto yyreturn; | |
2447 | ||
127287e9 PE |
2448 | yybuglab: |
2449 | YYASSERT (yyfalse); | |
a85284cf | 2450 | goto yyabortlab; |
127287e9 | 2451 | |
6100a9aa PE |
2452 | yyabortlab: |
2453 | yyresult = 1; | |
2454 | goto yyreturn; | |
2455 | ||
1a059451 PE |
2456 | yyexhaustedlab: |
2457 | yyerror (]b4_lyyerror_args[YY_("memory exhausted")); | |
6100a9aa | 2458 | yyresult = 2; |
a85284cf | 2459 | goto yyreturn; |
6100a9aa PE |
2460 | |
2461 | yyreturn: | |
868d2d96 | 2462 | if (yychar != YYEMPTY) |
dd5f2af2 | 2463 | yydestruct ("Cleanup: discarding lookahead", |
7020e5f0 | 2464 | YYTRANSLATE (yychar), &yylval]b4_locuser_args([&yylloc])[); |
01241d47 | 2465 | |
3922956a PE |
2466 | /* If the stack is well-formed, pop the stack until it is empty, |
2467 | destroying its entries as we go. But free the stack regardless | |
2468 | of whether it is well-formed. */ | |
2469 | if (yystack.yyitems) | |
2470 | { | |
2471 | yyGLRState** yystates = yystack.yytops.yystates; | |
2472 | if (yystates) | |
7020e5f0 AD |
2473 | { |
2474 | size_t yysize = yystack.yytops.yysize; | |
2475 | size_t yyk; | |
2476 | for (yyk = 0; yyk < yysize; yyk += 1) | |
2477 | if (yystates[yyk]) | |
2478 | { | |
2479 | while (yystates[yyk]) | |
2480 | { | |
2481 | yyGLRState *yys = yystates[yyk]; | |
2482 | ]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]] | |
2483 | )[ if (yys->yypred != YY_NULL) | |
2484 | yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[); | |
2485 | yystates[yyk] = yys->yypred; | |
2486 | yystack.yynextFree -= 1; | |
2487 | yystack.yyspaceLeft += 1; | |
2488 | } | |
2489 | break; | |
2490 | } | |
2491 | } | |
3922956a PE |
2492 | yyfreeGLRStack (&yystack); |
2493 | } | |
258b75ca | 2494 | |
7b5cdcbd JD |
2495 | /* Make sure YYID is used. */ |
2496 | return YYID (yyresult); | |
01241d47 PH |
2497 | } |
2498 | ||
2499 | /* DEBUGGING ONLY */ | |
5f108727 | 2500 | #if ]b4_api_PREFIX[DEBUG |
3e7a2cd9 | 2501 | static void yypstack (yyGLRStack* yystackp, size_t yyk) |
135bc829 | 2502 | __attribute__ ((__unused__)); |
3e7a2cd9 | 2503 | static void yypdumpstack (yyGLRStack* yystackp) __attribute__ ((__unused__)); |
01241d47 | 2504 | |
1154cced | 2505 | static void |
cf126971 | 2506 | yy_yypstack (yyGLRState* yys) |
01241d47 | 2507 | { |
cf126971 | 2508 | if (yys->yypred) |
01241d47 | 2509 | { |
cf126971 | 2510 | yy_yypstack (yys->yypred); |
8a86eef0 | 2511 | YYFPRINTF (stderr, " -> "); |
01241d47 | 2512 | } |
8a86eef0 JD |
2513 | YYFPRINTF (stderr, "%d@@%lu", yys->yylrState, |
2514 | (unsigned long int) yys->yyposn); | |
cf126971 | 2515 | } |
01241d47 | 2516 | |
cf126971 PE |
2517 | static void |
2518 | yypstates (yyGLRState* yyst) | |
2519 | { | |
ef51bfa7 | 2520 | if (yyst == YY_NULL) |
8a86eef0 | 2521 | YYFPRINTF (stderr, "<null>"); |
fb8135fa | 2522 | else |
01241d47 | 2523 | yy_yypstack (yyst); |
8a86eef0 | 2524 | YYFPRINTF (stderr, "\n"); |
01241d47 PH |
2525 | } |
2526 | ||
1154cced | 2527 | static void |
3e7a2cd9 | 2528 | yypstack (yyGLRStack* yystackp, size_t yyk) |
01241d47 | 2529 | { |
3e7a2cd9 | 2530 | yypstates (yystackp->yytops.yystates[yyk]); |
01241d47 PH |
2531 | } |
2532 | ||
7020e5f0 | 2533 | #define YYINDEX(YYX) \ |
ef51bfa7 | 2534 | ((YYX) == YY_NULL ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems) |
01241d47 PH |
2535 | |
2536 | ||
1154cced | 2537 | static void |
3e7a2cd9 | 2538 | yypdumpstack (yyGLRStack* yystackp) |
01241d47 PH |
2539 | { |
2540 | yyGLRStackItem* yyp; | |
1154cced | 2541 | size_t yyi; |
3e7a2cd9 | 2542 | for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1) |
01241d47 | 2543 | { |
8a86eef0 JD |
2544 | YYFPRINTF (stderr, "%3lu. ", |
2545 | (unsigned long int) (yyp - yystackp->yyitems)); | |
f7c398aa | 2546 | if (*(yybool *) yyp) |
7020e5f0 AD |
2547 | { |
2548 | YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld", | |
2549 | yyp->yystate.yyresolved, yyp->yystate.yylrState, | |
2550 | (unsigned long int) yyp->yystate.yyposn, | |
2551 | (long int) YYINDEX (yyp->yystate.yypred)); | |
2552 | if (! yyp->yystate.yyresolved) | |
2553 | YYFPRINTF (stderr, ", firstVal: %ld", | |
2554 | (long int) YYINDEX (yyp->yystate | |
8a86eef0 | 2555 | .yysemantics.yyfirstVal)); |
7020e5f0 | 2556 | } |
fb8135fa | 2557 | else |
7020e5f0 AD |
2558 | { |
2559 | YYFPRINTF (stderr, "Option. rule: %d, state: %ld, next: %ld", | |
2560 | yyp->yyoption.yyrule - 1, | |
2561 | (long int) YYINDEX (yyp->yyoption.yystate), | |
2562 | (long int) YYINDEX (yyp->yyoption.yynext)); | |
2563 | } | |
8a86eef0 | 2564 | YYFPRINTF (stderr, "\n"); |
01241d47 | 2565 | } |
8a86eef0 | 2566 | YYFPRINTF (stderr, "Tops:"); |
3e7a2cd9 | 2567 | for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1) |
8a86eef0 | 2568 | YYFPRINTF (stderr, "%lu: %ld; ", (unsigned long int) yyi, |
7020e5f0 | 2569 | (long int) YYINDEX (yystackp->yytops.yystates[yyi])); |
8a86eef0 | 2570 | YYFPRINTF (stderr, "\n"); |
01241d47 | 2571 | } |
417141dd | 2572 | #endif |
dcd5344d | 2573 | ]b4_epilogue[]dnl |
1c7ec959 AD |
2574 | b4_output_end() |
2575 | ||
2576 | # glr.cc produces its own header. | |
3f7ca628 JD |
2577 | m4_if(b4_skeleton, ["glr.c"], |
2578 | [b4_defines_if( | |
1c7ec959 | 2579 | [b4_output_begin([b4_spec_defines_file]) |
193d7c70 | 2580 | b4_copyright([Skeleton interface for Bison GLR parsers in C], |
c3e9f08f AD |
2581 | [2002-2012])[ |
2582 | ||
2583 | ]b4_cpp_guard_open([b4_spec_defines_file])[ | |
2584 | ]b4_shared_declarations[ | |
c3e9f08f | 2585 | ]b4_cpp_guard_close([b4_spec_defines_file])[ |
1c7ec959 AD |
2586 | ]b4_output_end() |
2587 | ])]) |