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