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