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