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