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