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