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