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