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