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