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