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