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