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