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