]>
Commit | Line | Data |
---|---|---|
720623af PH |
1 | m4_divert(-1) -*- C -*- |
2 | m4_include([c.m4]) | |
01241d47 | 3 | |
fb8135fa AD |
4 | # GLR skeleton for Bison |
5 | # Copyright (C) 2002 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 2 of the License, or | |
10 | # (at your option) any later version. | |
11 | ||
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | ||
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program; if not, write to the Free Software | |
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
20 | # 02111-1307 USA | |
21 | ||
66d30cd4 AD |
22 | |
23 | ## ---------------- ## | |
24 | ## Default values. ## | |
25 | ## ---------------- ## | |
26 | ||
27 | # Stack parameters. | |
28 | m4_define_default([b4_stack_depth_max], [10000]) | |
29 | m4_define_default([b4_stack_depth_init], [200]) | |
30 | ||
31 | # Location type. | |
32 | m4_define_default([b4_location_type], [yyltype]) | |
33 | ||
21964f43 AD |
34 | # Accumule in b4_lex_param all the yylex arguments. |
35 | # Yes, this is quite ugly... | |
36 | m4_define([b4_lex_param], | |
37 | m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[yylvalp]]][]dnl | |
38 | b4_location_if([, [[YYLTYPE *], [yyllocp]]])])dnl | |
39 | m4_ifdef([b4_lex_param], [, ]b4_lex_param))) | |
40 | ||
0245f82d AD |
41 | # Yes, this is quite ugly... |
42 | m4_define_default([b4_parse_param]) | |
43 | m4_ifdef([b4_parse_param], | |
44 | [m4_define([b4_parse_param], | |
45 | b4_parse_param)]) | |
46 | ||
66d30cd4 AD |
47 | |
48 | ||
49 | ## ----------------- ## | |
50 | ## Semantic Values. ## | |
51 | ## ----------------- ## | |
52 | ||
53 | ||
01241d47 PH |
54 | # b4_lhs_value([TYPE]) |
55 | # -------------------- | |
56 | # Expansion of $<TYPE>$. | |
57 | m4_define([b4_lhs_value], | |
58 | [(*yyvalp)[]m4_ifval([$1], [.$1])]) | |
59 | ||
60 | ||
61 | # b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) | |
62 | # -------------------------------------- | |
63 | # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH | |
64 | # symbols on RHS. | |
65 | m4_define([b4_rhs_value], | |
66 | [yyvsp@<:@m4_eval([$2 - $1])@:>@.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3])]) | |
67 | ||
68 | ||
69 | ||
70 | ## ----------- ## | |
71 | ## Locations. ## | |
72 | ## ----------- ## | |
73 | ||
01241d47 PH |
74 | # b4_lhs_location() |
75 | # ----------------- | |
76 | # Expansion of @$. | |
77 | m4_define([b4_lhs_location], | |
78 | [(*yylocp)]) | |
79 | ||
80 | ||
81 | # b4_rhs_location(RULE-LENGTH, NUM) | |
82 | # --------------------------------- | |
83 | # Expansion of @NUM, where the current rule has RULE-LENGTH symbols | |
84 | # on RHS. | |
85 | m4_define([b4_rhs_location], | |
86 | [yyvsp@<:@m4_eval([$2 - $1])@:>@.yystate.yyloc]) | |
87 | ||
88 | ||
89 | ||
01241d47 PH |
90 | ## ------------------- ## |
91 | ## Output file names. ## | |
92 | ## ------------------- ## | |
93 | ||
94 | m4_define_default([b4_input_suffix], [.y]) | |
95 | ||
96 | m4_define_default([b4_output_parser_suffix], | |
97 | [m4_translit(b4_input_suffix, [yY], [cC])]) | |
98 | ||
99 | m4_define_default([b4_output_parser_name], | |
100 | [b4_output_prefix[]b4_output_infix[]b4_output_parser_suffix[]]) | |
101 | ||
102 | ||
103 | m4_define_default([b4_output_header_suffix], | |
104 | [m4_translit(b4_input_suffix, [yY], [hH])]) | |
105 | ||
106 | m4_define_default([b4_output_header_name], | |
107 | [b4_output_prefix[]b4_output_infix[]b4_output_header_suffix[]]) | |
108 | ||
109 | m4_define_default([b4_header_guard], | |
110 | [m4_bpatsubst(m4_toupper([BISON_]b4_output_header_name), | |
111 | [[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]], [_])]) | |
112 | ||
113 | ||
b526ee61 AD |
114 | # We do want M4 expansion after # for CPP macros. |
115 | m4_changecom() | |
01241d47 PH |
116 | m4_divert(0)dnl |
117 | #output "b4_output_parser_name" | |
fb8135fa AD |
118 | b4_copyright([Skeleton parser for GLR parsing with Bison], [2002]) |
119 | [ | |
01241d47 PH |
120 | /* This is the parser code for GLR (Generalized LR) parser. */ |
121 | ||
122 | /* FIXME: minimize these */ | |
cf126971 | 123 | #include <assert.h> |
01241d47 | 124 | #include <setjmp.h> |
01241d47 | 125 | #include <stdarg.h> |
cf126971 PE |
126 | #include <stdio.h> |
127 | #include <stdlib.h> | |
128 | #include <string.h> | |
01241d47 PH |
129 | |
130 | /* Identify Bison output. */ | |
131 | #define YYBISON 1 | |
132 | ||
133 | /* Pure parsers. */ | |
134 | #define YYPURE ]b4_pure[ | |
135 | ||
136 | /* Using locations. */ | |
137 | #define YYLSP_NEEDED ]b4_locations_flag[ | |
138 | ||
139 | ]m4_if(b4_prefix[], [yy], [], | |
140 | [/* If NAME_PREFIX is specified substitute the variables and functions | |
141 | names. */ | |
142 | #define yyparse b4_prefix[]parse | |
143 | #define yylex b4_prefix[]lex | |
144 | #define yyerror b4_prefix[]error | |
145 | #define yylval b4_prefix[]lval | |
146 | #define yychar b4_prefix[]char | |
147 | #define yydebug b4_prefix[]debug | |
148 | #define yynerrs b4_prefix[]nerrs | |
149 | b4_location_if([#define yylloc b4_prefix[]lloc])]) | |
150 | ||
17acead5 | 151 | b4_token_defines(b4_tokens) |
01241d47 | 152 | |
17acead5 PE |
153 | /* Copy the first part of user declarations. */ |
154 | b4_pre_prologue[ | |
01241d47 PH |
155 | |
156 | /* Enabling traces. */ | |
157 | #ifndef YYDEBUG | |
158 | # define YYDEBUG ]b4_debug[ | |
159 | #endif | |
160 | ||
161 | /* Enabling verbose error messages. */ | |
162 | #ifdef YYERROR_VERBOSE | |
163 | # undef YYERROR_VERBOSE | |
164 | # define YYERROR_VERBOSE 1 | |
165 | #else | |
166 | # define YYERROR_VERBOSE ]b4_error_verbose[ | |
167 | #endif | |
168 | ||
169 | #ifndef YYSTYPE | |
170 | ]m4_ifdef([b4_stype], | |
171 | [#line b4_stype_line "b4_filename" | |
172 | typedef union b4_stype yystype; | |
173 | /* Line __line__ of __file__. */ | |
174 | #line __oline__ "__ofile__"], | |
175 | [typedef int yystype;])[ | |
176 | # define YYSTYPE yystype | |
177 | # define YYSTYPE_IS_TRIVIAL 1 | |
178 | #endif | |
179 | ||
180 | #ifndef YYLTYPE | |
181 | typedef struct yyltype | |
182 | { | |
f50adbbd AD |
183 | int first_line; |
184 | int first_column; | |
185 | int last_line; | |
ffa4c58a | 186 | int last_column; |
01241d47 | 187 | } yyltype; |
66d30cd4 | 188 | # define YYLTYPE ]b4_location_type[ |
01241d47 PH |
189 | # define YYLTYPE_IS_TRIVIAL 1 |
190 | #endif | |
191 | ||
192 | /* Default (constant) values used for initialization for null | |
fb8135fa | 193 | right-hand sides. Unlike the standard bison.simple template, |
01241d47 PH |
194 | here we set the default values of the $$ and $@ to zeroed-out |
195 | values. Since the default value of these quantities is undefined, | |
196 | this behavior is technically correct. */ | |
197 | static YYSTYPE yyval_default; | |
198 | static YYLTYPE yyloc_default; | |
199 | ||
200 | /* Copy the second part of user declarations. */ | |
201 | ]b4_post_prologue[ | |
202 | ||
203 | ]/* Line __line__ of __file__. */ | |
204 | #line __oline__ "__ofile__" | |
205 | [ | |
206 | #if ! defined (__cplusplus) | |
207 | typedef char bool; | |
208 | # define yytrue 1 | |
209 | # define yyfalse 0 | |
210 | #endif | |
211 | ||
1154cced AD |
212 | /*-----------------. |
213 | | GCC extensions. | | |
214 | `-----------------*/ | |
215 | ||
216 | #ifndef __attribute__ | |
217 | /* This feature is available in gcc versions 2.5 and later. */ | |
218 | # if !defined (__GNUC__) || __GNUC__ < 2 || \ | |
219 | (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ | |
220 | # define __attribute__(Spec) /* empty */ | |
221 | # endif | |
222 | #endif | |
223 | ||
224 | #ifndef ATTRIBUTE_UNUSED | |
225 | # define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) | |
226 | #endif | |
227 | ||
228 | #if ! defined (__GNUC__) | |
229 | # define inline | |
01241d47 PH |
230 | #endif |
231 | ||
232 | /* YYFINAL -- State number of the termination state. */ | |
7db2ed2d | 233 | #define YYFINAL ]b4_final_state_number[ |
39912f52 | 234 | /* YYLAST -- Last index in YYTABLE. */ |
01241d47 PH |
235 | #define YYLAST ]b4_last[ |
236 | ||
237 | /* YYNTOKENS -- Number of terminals. */ | |
7db2ed2d | 238 | #define YYNTOKENS ]b4_tokens_number[ |
01241d47 | 239 | /* YYNNTS -- Number of nonterminals. */ |
7db2ed2d | 240 | #define YYNNTS ]b4_nterms_number[ |
01241d47 | 241 | /* YYNRULES -- Number of rules. */ |
7db2ed2d | 242 | #define YYNRULES ]b4_rules_number[ |
01241d47 | 243 | /* YYNRULES -- Number of states. */ |
7db2ed2d | 244 | #define YYNSTATES ]b4_states_number[ |
01241d47 PH |
245 | /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */ |
246 | #define YYMAXRHS ]b4_r2_max[ | |
247 | ||
248 | /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */ | |
249 | #define YYUNDEFTOK ]b4_undef_token_number[ | |
250 | #define YYMAXUTOK ]b4_user_token_number_max[ | |
251 | ||
252 | #define YYTRANSLATE(YYX) \ | |
253 | ((unsigned)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) | |
254 | ||
255 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ | |
a762e609 | 256 | static const ]b4_int_type_for([b4_translate])[ yytranslate[] = |
01241d47 PH |
257 | { |
258 | ]b4_translate[ | |
259 | }; | |
260 | ||
261 | #if YYDEBUG | |
262 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in | |
263 | YYRHS. */ | |
a762e609 | 264 | static const ]b4_int_type_for([b4_prhs])[ yyprhs[] = |
01241d47 PH |
265 | { |
266 | ]b4_prhs[ | |
267 | }; | |
268 | ||
269 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ | |
a762e609 | 270 | static const ]b4_int_type_for([b4_rhs])[ yyrhs[] = |
01241d47 PH |
271 | { |
272 | ]b4_rhs[ | |
273 | }; | |
274 | ||
275 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ | |
a762e609 | 276 | static const ]b4_int_type_for([b4_rline])[ yyrline[] = |
01241d47 PH |
277 | { |
278 | ]b4_rline[ | |
279 | }; | |
280 | #endif | |
281 | ||
282 | #if (YYDEBUG) || YYERROR_VERBOSE | |
283 | /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. | |
284 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | |
285 | static const char *const yytname[] = | |
286 | { | |
287 | ]b4_tname[ | |
288 | }; | |
289 | ||
1154cced | 290 | #define yytname_size ((int) (sizeof (yytname) / sizeof (yytname[0]))) |
01241d47 PH |
291 | #endif |
292 | ||
293 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | |
a762e609 | 294 | static const ]b4_int_type_for([b4_r1])[ yyr1[] = |
01241d47 PH |
295 | { |
296 | ]b4_r1[ | |
297 | }; | |
298 | ||
299 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ | |
a762e609 | 300 | static const ]b4_int_type_for([b4_r2])[ yyr2[] = |
01241d47 PH |
301 | { |
302 | ]b4_r2[ | |
303 | }; | |
304 | ||
305 | /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */ | |
a762e609 | 306 | static const ]b4_int_type_for([b4_dprec])[ yydprec[] = |
01241d47 PH |
307 | { |
308 | ]b4_dprec[ | |
309 | }; | |
310 | ||
311 | /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */ | |
a762e609 | 312 | static const ]b4_int_type_for([b4_merger])[ yymerger[] = |
01241d47 PH |
313 | { |
314 | ]b4_merger[ | |
315 | }; | |
316 | ||
317 | /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE | |
318 | doesn't specify something else to do. Zero means the default is an | |
319 | error. */ | |
a762e609 | 320 | static const ]b4_int_type_for([b4_defact])[ yydefact[] = |
01241d47 PH |
321 | { |
322 | ]b4_defact[ | |
323 | }; | |
324 | ||
12b0043a | 325 | /* YYPDEFGOTO[NTERM-NUM]. */ |
a762e609 | 326 | static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] = |
01241d47 PH |
327 | { |
328 | ]b4_defgoto[ | |
329 | }; | |
330 | ||
331 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | |
332 | STATE-NUM. */ | |
12b0043a | 333 | #define YYPACT_NINF ]b4_pact_ninf[ |
a762e609 | 334 | static const ]b4_int_type_for([b4_pact])[ yypact[] = |
01241d47 PH |
335 | { |
336 | ]b4_pact[ | |
337 | }; | |
338 | ||
339 | /* YYPGOTO[NTERM-NUM]. */ | |
a762e609 | 340 | static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] = |
01241d47 PH |
341 | { |
342 | ]b4_pgoto[ | |
343 | }; | |
344 | ||
345 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | |
346 | positive, shift that token. If negative, reduce the rule which | |
f50adbbd AD |
347 | number is the opposite. If zero, do what YYDEFACT says. |
348 | If YYTABLE_NINF, parse error. */ | |
12b0043a | 349 | #define YYTABLE_NINF ]b4_table_ninf[ |
a762e609 | 350 | static const ]b4_int_type_for([b4_table])[ yytable[] = |
01241d47 PH |
351 | { |
352 | ]b4_table[ | |
353 | }; | |
354 | ||
ea99527d AD |
355 | /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of |
356 | list of conflicting reductions corresponding to action entry for | |
357 | state STATE-NUM in yytable. 0 means no conflicts. The list in | |
358 | yyconfl is terminated by a rule number of 0. */ | |
a762e609 | 359 | static const ]b4_int_type_for([b4_conflict_list_heads])[ yyconflp[] = |
01241d47 PH |
360 | { |
361 | ]b4_conflict_list_heads[ | |
362 | }; | |
363 | ||
ea99527d AD |
364 | /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by |
365 | 0, pointed into by YYCONFLP. */ | |
a762e609 AD |
366 | ]dnl Do not use b4_int_type_for here, since there are places where |
367 | dnl pointers onto yyconfl are taken, which type is "short *". | |
368 | dnl We probably ought to introduce a type for confl. | |
369 | [static const short yyconfl[] = | |
01241d47 PH |
370 | { |
371 | ]b4_conflicting_rules[ | |
372 | }; | |
373 | ||
a762e609 | 374 | static const ]b4_int_type_for([b4_check])[ yycheck[] = |
01241d47 PH |
375 | { |
376 | ]b4_check[ | |
377 | }; | |
378 | ||
379 | \f | |
0245f82d | 380 | /* Prevent warning if -Wmissing-prototypes. */ |
e7cb57c0 | 381 | ]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param) |
01241d47 | 382 | |
e7cb57c0 AD |
383 | m4_ifset([b4_parse_param], |
384 | [#define YY_USER_FORMALS , b4_c_ansi_formals(b4_parse_param) | |
385 | #define YY_USER_ARGS , b4_c_args(b4_parse_param)], | |
386 | [#define YY_USER_FORMALS | |
387 | #define YY_USER_ARGS]) | |
388 | ||
389 | ||
390 | [/* Error token number */ | |
01241d47 PH |
391 | #define YYTERROR 1 |
392 | ||
393 | /* YYLLOC_DEFAULT -- Compute the default location (before the actions | |
394 | are run). */ | |
395 | ||
396 | #define YYRHSLOC(yyRhs,YYK) (yyRhs[YYK].yystate.yyloc) | |
397 | ||
398 | #ifndef YYLLOC_DEFAULT | |
12b0043a | 399 | # define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN) \ |
f50adbbd AD |
400 | yyCurrent.first_line = YYRHSLOC(yyRhs,1).first_line; \ |
401 | yyCurrent.first_column = YYRHSLOC(yyRhs,1).first_column; \ | |
402 | yyCurrent.last_line = YYRHSLOC(yyRhs,YYN).last_line; \ | |
403 | yyCurrent.last_column = YYRHSLOC(yyRhs,YYN).last_column; | |
01241d47 PH |
404 | #endif |
405 | ||
406 | /* YYLEX -- calling `yylex' with the right arguments. */ | |
21964f43 | 407 | #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[ |
01241d47 PH |
408 | |
409 | ]b4_pure_if( | |
410 | [ | |
01241d47 PH |
411 | #undef yynerrs |
412 | #define yynerrs (yystack->yyerrcnt) | |
413 | #undef yychar | |
414 | #define yychar (yystack->yyrawchar)], | |
415 | [YYSTYPE yylval; | |
416 | ||
417 | YYLTYPE yylloc; | |
418 | ||
419 | int yynerrs; | |
420 | int yychar;])[ | |
421 | ||
422 | static const int YYEOF = 0; | |
423 | static const int YYEMPTY = -2; | |
424 | ||
425 | typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG; | |
426 | ||
427 | #define YYCHK(YYE) \ | |
428 | do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \ | |
429 | while (0) | |
430 | ||
431 | #if YYDEBUG | |
432 | ||
433 | #if ! defined (YYFPRINTF) | |
434 | # define YYFPRINTF fprintf | |
435 | #endif | |
436 | ||
437 | # define YYDPRINTF(Args) \ | |
438 | do { \ | |
439 | if (yydebug) \ | |
440 | YYFPRINTF Args; \ | |
441 | } while (0) | |
442 | /* Nonzero means print parse trace. It is left uninitialized so that | |
443 | multiple parsers can coexist. */ | |
444 | int yydebug; | |
445 | #else /* !YYDEBUG */ | |
1154cced AD |
446 | /* Avoid empty `if' bodies. */ |
447 | # define YYDPRINTF(Args) {} | |
01241d47 PH |
448 | #endif /* !YYDEBUG */ |
449 | ||
450 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | |
451 | #ifndef YYINITDEPTH | |
66d30cd4 | 452 | # define YYINITDEPTH ]b4_stack_depth_init[ |
01241d47 PH |
453 | #endif |
454 | ||
455 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only | |
456 | if the built-in stack extension method is used). | |
457 | ||
458 | Do not make this value too large; the results are undefined if | |
fb8135fa | 459 | SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem) |
01241d47 PH |
460 | evaluated with infinite-precision integer arithmetic. */ |
461 | ||
462 | #if YYMAXDEPTH == 0 | |
463 | # undef YYMAXDEPTH | |
464 | #endif | |
465 | ||
466 | #ifndef YYMAXDEPTH | |
66d30cd4 | 467 | # define YYMAXDEPTH ]b4_stack_depth_max[ |
01241d47 PH |
468 | #endif |
469 | ||
470 | /* Minimum number of free items on the stack allowed after an | |
fb8135fa AD |
471 | allocation. This is to allow allocation and initialization |
472 | to be completed by functions that call expandGLRStack before the | |
473 | stack is expanded, thus insuring that all necessary pointers get | |
01241d47 PH |
474 | properly redirected to new data. */ |
475 | #define YYHEADROOM 2 | |
476 | ||
477 | #if ! defined (YYSTACKEXPANDABLE) \ | |
478 | && (! defined (__cplusplus) || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)) | |
479 | #define YYSTACKEXPANDABLE 1 | |
480 | #else | |
481 | #define YYSTACKEXPANDABLE 0 | |
482 | #endif | |
483 | ||
484 | /** State numbers, as in LALR(1) machine */ | |
485 | typedef int yyStateNum; | |
486 | ||
487 | /** Rule numbers, as in LALR(1) machine */ | |
488 | typedef int yyRuleNum; | |
489 | ||
490 | /** Grammar symbol */ | |
491 | typedef short yySymbol; | |
492 | ||
493 | /** Item references, as in LALR(1) machine */ | |
494 | typedef short yyItemNum; | |
495 | ||
496 | typedef struct yyGLRState yyGLRState; | |
497 | typedef struct yySemanticOption yySemanticOption; | |
498 | typedef union yyGLRStackItem yyGLRStackItem; | |
499 | typedef struct yyGLRStack yyGLRStack; | |
500 | typedef struct yyGLRStateSet yyGLRStateSet; | |
501 | ||
502 | struct yyGLRState { | |
fb8135fa | 503 | bool yyisState; |
01241d47 PH |
504 | bool yyresolved; |
505 | yyStateNum yylrState; | |
506 | yyGLRState* yypred; | |
507 | size_t yyposn; | |
508 | union { | |
509 | yySemanticOption* yyfirstVal; | |
510 | YYSTYPE yysval; | |
511 | } yysemantics; | |
512 | YYLTYPE yyloc; | |
513 | }; | |
514 | ||
515 | struct yyGLRStateSet { | |
516 | yyGLRState** yystates; | |
517 | size_t yysize, yycapacity; | |
518 | }; | |
519 | ||
520 | struct yySemanticOption { | |
521 | bool yyisState; | |
522 | yyRuleNum yyrule; | |
523 | yyGLRState* yystate; | |
524 | yySemanticOption* yynext; | |
525 | }; | |
526 | ||
527 | union yyGLRStackItem { | |
528 | yyGLRState yystate; | |
529 | yySemanticOption yyoption; | |
530 | }; | |
531 | ||
532 | struct yyGLRStack { | |
533 | int yyerrflag; | |
534 | int yyerrState; | |
535 | ]b4_pure_if( | |
536 | [ | |
537 | int yyerrcnt; | |
538 | int yyrawchar; | |
539 | ])[ | |
540 | yySymbol* yytokenp; | |
541 | jmp_buf yyexception_buffer; | |
542 | yyGLRStackItem* yyitems; | |
543 | yyGLRStackItem* yynextFree; | |
544 | int yyspaceLeft; | |
545 | yyGLRState* yysplitPoint; | |
546 | yyGLRState* yylastDeleted; | |
547 | yyGLRStateSet yytops; | |
548 | }; | |
549 | ||
550 | static void yyinitGLRStack (yyGLRStack* yystack, size_t yysize); | |
551 | static void yyexpandGLRStack (yyGLRStack* yystack); | |
552 | static void yyfreeGLRStack (yyGLRStack* yystack); | |
553 | ||
554 | static void | |
fb8135fa | 555 | yyFail (yyGLRStack* yystack, const char* yyformat, ...) |
01241d47 PH |
556 | { |
557 | if (yyformat != NULL) | |
558 | { | |
559 | char yymsg[256]; | |
560 | va_list yyap; | |
561 | va_start (yyap, yyformat); | |
562 | yystack->yyerrflag = 1; | |
563 | vsprintf (yymsg, yyformat, yyap); | |
564 | yyerror (yymsg); | |
565 | } | |
566 | longjmp (yystack->yyexception_buffer, 1); | |
567 | } | |
568 | ||
569 | #if YYDEBUG || YYERROR_VERBOSE | |
570 | /** A printable representation of TOKEN. Valid until next call to | |
571 | * tokenName. */ | |
fb8135fa AD |
572 | static inline const char* |
573 | yytokenName (yySymbol yytoken) | |
01241d47 PH |
574 | { |
575 | return yytname[yytoken]; | |
576 | } | |
577 | #endif | |
578 | ||
579 | /** Perform user action for rule number YYN, with RHS length YYRHSLEN, | |
580 | * and top stack item YYVSP. YYLVALP points to place to put semantic | |
581 | * value ($$), and yylocp points to place for location information | |
582 | * (@$). Returns yyok for normal return, yyaccept for YYACCEPT, | |
583 | * yyerr for YYERROR, yyabort for YYABORT. */ | |
584 | static YYRESULTTAG | |
fb8135fa | 585 | yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, |
e7cb57c0 AD |
586 | YYSTYPE* yyvalp, YYLTYPE* yylocp, yyGLRStack* yystack |
587 | YY_USER_FORMALS) | |
01241d47 | 588 | { |
1154cced AD |
589 | /* Avoid `unused' warnings in there are no $n. */ |
590 | (void) yystack; | |
591 | ||
fb8135fa | 592 | if (yyrhslen == 0) |
01241d47 PH |
593 | { |
594 | *yyvalp = yyval_default; | |
595 | *yylocp = yyloc_default; | |
596 | } | |
fb8135fa | 597 | else |
01241d47 PH |
598 | { |
599 | *yyvalp = yyvsp[1-yyrhslen].yystate.yysemantics.yysval; | |
600 | *yylocp = yyvsp[1-yyrhslen].yystate.yyloc; | |
601 | } | |
602 | # undef yyval | |
603 | # define yyval (*yyvalp) | |
604 | # undef yyerrok | |
605 | # define yyerrok (yystack->yyerrState = 0) | |
606 | # undef YYACCEPT | |
607 | # define YYACCEPT return yyaccept | |
608 | # undef YYABORT | |
609 | # define YYABORT return yyabort | |
610 | # undef YYERROR | |
611 | # define YYERROR return yyerr | |
612 | # undef YYRECOVERING | |
613 | # define YYRECOVERING (yystack->yyerrState != 0) | |
614 | # undef yyclearin | |
615 | # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY) | |
616 | # undef YYBACKUP | |
617 | # define YYBACKUP(Token, Value) \ | |
618 | do { \ | |
619 | yyerror ("syntax error: cannot back up"); \ | |
620 | YYERROR; \ | |
621 | } while (0) | |
622 | ||
623 | ] | |
fb8135fa | 624 | switch (yyn) |
01241d47 PH |
625 | { |
626 | b4_actions | |
627 | } | |
628 | ||
629 | return yyok; | |
630 | # undef yyval | |
631 | # undef yyerrok | |
632 | # undef YYABORT | |
633 | # undef YYACCEPT | |
634 | # undef YYERROR | |
635 | # undef YYBACKUP | |
636 | # undef yyclearin | |
637 | # undef YYRECOVERING | |
638 | /* Line __line__ of __file__. */ | |
639 | #line __oline__ "__ofile__" | |
640 | } | |
641 | \f | |
642 | ||
643 | static YYSTYPE | |
644 | yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1) | |
645 | { | |
646 | YYSTYPE yyval = *yy0; | |
1154cced AD |
647 | /* `Use' the arguments. */ |
648 | (void) yy0; | |
649 | (void) yy1; | |
650 | ||
fb8135fa | 651 | switch (yyn) |
01241d47 PH |
652 | { |
653 | b4_mergers | |
654 | } | |
655 | return yyval; | |
656 | } | |
657 | [ | |
658 | /* Bison grammar-table manipulation */ | |
659 | ||
660 | /** Number of symbols composing the right hand side of rule #RULE. */ | |
661 | static inline int | |
fb8135fa | 662 | yyrhsLength (yyRuleNum yyrule) |
01241d47 PH |
663 | { |
664 | return yyr2[yyrule]; | |
665 | } | |
666 | ||
667 | /** Left-hand-side symbol for rule #RULE. */ | |
668 | static inline yySymbol | |
fb8135fa | 669 | yylhsNonterm (yyRuleNum yyrule) |
01241d47 PH |
670 | { |
671 | return yyr1[yyrule]; | |
672 | } | |
673 | ||
674 | /** True iff LR state STATE has only a default reduction (regardless | |
675 | * of token). */ | |
676 | static inline bool | |
677 | yyisDefaultedState (yyStateNum yystate) | |
678 | { | |
12b0043a | 679 | return yypact[yystate] == YYPACT_NINF; |
01241d47 | 680 | } |
fb8135fa | 681 | |
01241d47 PH |
682 | /** The default reduction for STATE, assuming it has one. */ |
683 | static inline yyRuleNum | |
684 | yydefaultAction (yyStateNum yystate) | |
685 | { | |
686 | return yydefact[yystate]; | |
687 | } | |
688 | ||
2a1fe6ed | 689 | /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN. |
01241d47 PH |
690 | * Result R means |
691 | * R < 0: Reduce on rule -R. | |
692 | * R = 0: Error. | |
fb8135fa AD |
693 | * R > 0: Shift to state R. |
694 | * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of | |
01241d47 PH |
695 | * conflicting reductions. |
696 | */ | |
697 | static inline void | |
fb8135fa | 698 | yygetLRActions (yyStateNum yystate, int yytoken, |
01241d47 PH |
699 | int* yyaction, const short** yyconflicts) |
700 | { | |
701 | int yyindex = yypact[yystate] + yytoken; | |
f50adbbd | 702 | if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken) |
01241d47 PH |
703 | { |
704 | *yyaction = -yydefact[yystate]; | |
705 | *yyconflicts = yyconfl; | |
706 | } | |
f50adbbd | 707 | else if (yytable[yyindex] != YYTABLE_NINF) |
01241d47 PH |
708 | { |
709 | *yyaction = yytable[yyindex]; | |
710 | *yyconflicts = yyconfl + yyconflp[yyindex]; | |
711 | } | |
f50adbbd AD |
712 | else |
713 | { | |
714 | *yyaction = 0; | |
715 | *yyconflicts = yyconfl + yyconflp[yyindex]; | |
716 | } | |
01241d47 PH |
717 | } |
718 | ||
719 | static inline yyStateNum | |
720 | yyLRgotoState (yyStateNum yystate, yySymbol yylhs) | |
721 | { | |
722 | int yyr; | |
723 | yyr = yypgoto[yylhs - YYNTOKENS] + yystate; | |
f50adbbd | 724 | if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate) |
01241d47 PH |
725 | return yytable[yyr]; |
726 | else | |
727 | return yydefgoto[yylhs - YYNTOKENS]; | |
728 | } | |
729 | ||
730 | static inline bool | |
fb8135fa | 731 | yyisShiftAction (int yyaction) |
01241d47 | 732 | { |
39912f52 | 733 | return 0 < yyaction; |
01241d47 PH |
734 | } |
735 | ||
736 | static inline bool | |
fb8135fa | 737 | yyisErrorAction (int yyaction) |
01241d47 | 738 | { |
f50adbbd | 739 | return yyaction == 0; |
01241d47 PH |
740 | } |
741 | ||
742 | /* GLRStates */ | |
743 | ||
744 | /** True iff the semantic value of the edge leading to STATE is | |
745 | * resolved. */ | |
746 | static inline bool | |
fb8135fa | 747 | yyhasResolvedValue (yyGLRState* yystate) |
01241d47 PH |
748 | { |
749 | return yystate->yyresolved; | |
750 | } | |
751 | ||
1154cced AD |
752 | static void |
753 | yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate, | |
6fed0802 | 754 | yyGLRState* rhs, yyRuleNum yyrule) |
01241d47 PH |
755 | { |
756 | yySemanticOption* yynewItem; | |
757 | yynewItem = &yystack->yynextFree->yyoption; | |
758 | yystack->yyspaceLeft -= 1; | |
759 | yystack->yynextFree += 1; | |
760 | yynewItem->yyisState = yyfalse; | |
6fed0802 | 761 | yynewItem->yystate = rhs; |
fb8135fa | 762 | yynewItem->yyrule = yyrule; |
01241d47 PH |
763 | yynewItem->yynext = yystate->yysemantics.yyfirstVal; |
764 | yystate->yysemantics.yyfirstVal = yynewItem; | |
765 | if (yystack->yyspaceLeft < YYHEADROOM) | |
766 | yyexpandGLRStack (yystack); | |
767 | } | |
768 | ||
769 | /* GLRStacks */ | |
770 | ||
771 | /** Initialize SET to a singleton set containing an empty stack. */ | |
772 | static void | |
773 | yyinitStateSet (yyGLRStateSet* yyset) | |
774 | { | |
775 | yyset->yysize = 1; | |
776 | yyset->yycapacity = 16; | |
777 | yyset->yystates = (yyGLRState**) malloc (16 * sizeof (yyset->yystates[0])); | |
778 | yyset->yystates[0] = NULL; | |
779 | } | |
780 | ||
fb8135fa | 781 | static void yyfreeStateSet (yyGLRStateSet* yyset) |
01241d47 PH |
782 | { |
783 | free (yyset->yystates); | |
784 | } | |
785 | ||
786 | /** Initialize STACK to a single empty stack, with total maximum | |
787 | * capacity for all stacks of SIZE. */ | |
788 | static void | |
789 | yyinitGLRStack (yyGLRStack* yystack, size_t yysize) | |
790 | { | |
791 | yystack->yyerrflag = 0; | |
792 | yystack->yyerrState = 0; | |
793 | yynerrs = 0; | |
794 | yystack->yyspaceLeft = yysize; | |
fb8135fa | 795 | yystack->yynextFree = yystack->yyitems = |
01241d47 PH |
796 | (yyGLRStackItem*) malloc (yysize * sizeof (yystack->yynextFree[0])); |
797 | yystack->yysplitPoint = NULL; | |
798 | yystack->yylastDeleted = NULL; | |
799 | yyinitStateSet (&yystack->yytops); | |
800 | } | |
801 | ||
802 | #define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \ | |
803 | &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE | |
804 | ||
805 | /** If STACK is expandable, extend it. WARNING: Pointers into the | |
806 | stack from outside should be considered invalid after this call. | |
807 | We always expand when there are 1 or fewer items left AFTER an | |
808 | allocation, so that we can avoid having external pointers exist | |
809 | across an allocation. */ | |
810 | static void | |
fb8135fa | 811 | yyexpandGLRStack (yyGLRStack* yystack) |
01241d47 PH |
812 | { |
813 | #if YYSTACKEXPANDABLE | |
814 | yyGLRStack yynewStack; | |
815 | yyGLRStackItem* yyp0, *yyp1; | |
816 | size_t yysize, yynewSize; | |
817 | size_t yyn; | |
818 | yysize = yystack->yynextFree - yystack->yyitems; | |
39912f52 | 819 | if (YYMAXDEPTH <= yysize) |
01241d47 PH |
820 | yyFail (yystack, "parsing stack overflow (%d items)", yysize); |
821 | yynewSize = 2*yysize; | |
39912f52 | 822 | if (YYMAXDEPTH < yynewSize) |
01241d47 PH |
823 | yynewSize = YYMAXDEPTH; |
824 | yyinitGLRStack (&yynewStack, yynewSize); | |
fb8135fa | 825 | for (yyp0 = yystack->yyitems, yyp1 = yynewStack.yyitems, yyn = yysize; |
39912f52 | 826 | 0 < yyn; |
fb8135fa | 827 | yyn -= 1, yyp0 += 1, yyp1 += 1) |
01241d47 PH |
828 | { |
829 | *yyp1 = *yyp0; | |
fb8135fa AD |
830 | if (*(bool*) yyp0) |
831 | { | |
01241d47 PH |
832 | yyGLRState* yys0 = &yyp0->yystate; |
833 | yyGLRState* yys1 = &yyp1->yystate; | |
fb8135fa AD |
834 | if (yys0->yypred != NULL) |
835 | yys1->yypred = | |
01241d47 PH |
836 | YYRELOC (yyp0, yyp1, yys0->yypred, yystate); |
837 | if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != NULL) | |
fb8135fa | 838 | yys1->yysemantics.yyfirstVal = |
01241d47 PH |
839 | YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption); |
840 | } | |
fb8135fa | 841 | else |
01241d47 PH |
842 | { |
843 | yySemanticOption* yyv0 = &yyp0->yyoption; | |
844 | yySemanticOption* yyv1 = &yyp1->yyoption; | |
845 | if (yyv0->yystate != NULL) | |
846 | yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate); | |
847 | if (yyv0->yynext != NULL) | |
848 | yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption); | |
849 | } | |
850 | } | |
851 | if (yystack->yysplitPoint != NULL) | |
fb8135fa | 852 | yystack->yysplitPoint = YYRELOC (yystack->yyitems, yynewStack.yyitems, |
01241d47 | 853 | yystack->yysplitPoint, yystate); |
fb8135fa AD |
854 | |
855 | for (yyn = 0; yyn < yystack->yytops.yysize; yyn += 1) | |
01241d47 | 856 | if (yystack->yytops.yystates[yyn] != NULL) |
fb8135fa AD |
857 | yystack->yytops.yystates[yyn] = |
858 | YYRELOC (yystack->yyitems, yynewStack.yyitems, | |
01241d47 PH |
859 | yystack->yytops.yystates[yyn], yystate); |
860 | free (yystack->yyitems); | |
861 | yystack->yyitems = yynewStack.yyitems; | |
862 | yystack->yynextFree = yynewStack.yynextFree + yysize; | |
863 | yystack->yyspaceLeft = yynewStack.yyspaceLeft - yysize; | |
864 | ||
865 | #else | |
fb8135fa | 866 | |
01241d47 PH |
867 | yyFail (yystack, "parsing stack overflow (%d items)", yysize); |
868 | ||
fb8135fa | 869 | #endif |
01241d47 PH |
870 | } |
871 | ||
872 | static void | |
fb8135fa | 873 | yyfreeGLRStack (yyGLRStack* yystack) |
01241d47 PH |
874 | { |
875 | free (yystack->yyitems); | |
876 | yyfreeStateSet (&yystack->yytops); | |
877 | } | |
878 | ||
879 | /** Assuming that S is a GLRState somewhere on STACK, update the | |
fb8135fa | 880 | * splitpoint of STACK, if needed, so that it is at least as deep as |
01241d47 PH |
881 | * S. */ |
882 | static inline void | |
fb8135fa | 883 | yyupdateSplit (yyGLRStack* yystack, yyGLRState* yys) |
01241d47 | 884 | { |
fb8135fa | 885 | if (yystack->yysplitPoint != NULL && yystack->yysplitPoint > yys) |
01241d47 PH |
886 | yystack->yysplitPoint = yys; |
887 | } | |
888 | ||
889 | /** Invalidate stack #K in STACK. */ | |
890 | static inline void | |
fb8135fa | 891 | yymarkStackDeleted (yyGLRStack* yystack, int yyk) |
01241d47 PH |
892 | { |
893 | if (yystack->yytops.yystates[yyk] != NULL) | |
894 | yystack->yylastDeleted = yystack->yytops.yystates[yyk]; | |
895 | yystack->yytops.yystates[yyk] = NULL; | |
896 | } | |
897 | ||
fb8135fa | 898 | /** Undelete the last stack that was marked as deleted. Can only be |
01241d47 PH |
899 | done once after a deletion, and only when all other stacks have |
900 | been deleted. */ | |
901 | static void | |
902 | yyundeleteLastStack (yyGLRStack* yystack) | |
903 | { | |
904 | if (yystack->yylastDeleted == NULL || yystack->yytops.yysize != 0) | |
905 | return; | |
fb8135fa | 906 | yystack->yytops.yystates[0] = yystack->yylastDeleted; |
01241d47 PH |
907 | yystack->yytops.yysize = 1; |
908 | YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n")); | |
909 | yystack->yylastDeleted = NULL; | |
910 | } | |
911 | ||
912 | static inline void | |
913 | yyremoveDeletes (yyGLRStack* yystack) | |
914 | { | |
1154cced | 915 | size_t yyi, yyj; |
01241d47 | 916 | yyi = yyj = 0; |
fb8135fa | 917 | while (yyj < yystack->yytops.yysize) |
01241d47 PH |
918 | { |
919 | if (yystack->yytops.yystates[yyi] == NULL) | |
920 | { | |
1154cced | 921 | if (yyi == yyj) |
01241d47 PH |
922 | YYDPRINTF ((stderr, "Removing dead stacks.\n")); |
923 | yystack->yytops.yysize -= 1; | |
924 | } | |
fb8135fa | 925 | else |
01241d47 PH |
926 | { |
927 | yystack->yytops.yystates[yyj] = yystack->yytops.yystates[yyi]; | |
928 | if (yyj != yyi) | |
929 | YYDPRINTF ((stderr, "Rename stack %d -> %d.\n", yyi, yyj)); | |
930 | yyj += 1; | |
931 | } | |
932 | yyi += 1; | |
933 | } | |
934 | } | |
935 | ||
fb8135fa | 936 | /** Shift to a new state on stack #K of STACK, corresponding to LR state |
01241d47 PH |
937 | * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */ |
938 | static inline void | |
fb8135fa AD |
939 | yyglrShift (yyGLRStack* yystack, int yyk, yyStateNum yylrState, size_t yyposn, |
940 | YYSTYPE yysval, YYLTYPE* yylocp) | |
01241d47 PH |
941 | { |
942 | yyGLRStackItem* yynewItem; | |
943 | ||
944 | yynewItem = yystack->yynextFree; | |
945 | yystack->yynextFree += 1; | |
946 | yystack->yyspaceLeft -= 1; | |
947 | yynewItem->yystate.yyisState = yytrue; | |
948 | yynewItem->yystate.yylrState = yylrState; | |
949 | yynewItem->yystate.yyposn = yyposn; | |
950 | yynewItem->yystate.yyresolved = yytrue; | |
951 | yynewItem->yystate.yypred = yystack->yytops.yystates[yyk]; | |
952 | yystack->yytops.yystates[yyk] = &yynewItem->yystate; | |
953 | yynewItem->yystate.yysemantics.yysval = yysval; | |
954 | yynewItem->yystate.yyloc = *yylocp; | |
955 | if (yystack->yyspaceLeft < YYHEADROOM) | |
956 | yyexpandGLRStack (yystack); | |
957 | } | |
958 | ||
959 | /** Shift to a new state on stack #K of STACK, to a new state | |
960 | * corresponding to LR state LRSTATE, at input position POSN, with | |
961 | * the (unresolved) semantic value of RHS under the action for RULE. */ | |
962 | static inline void | |
fb8135fa | 963 | yyglrShiftDefer (yyGLRStack* yystack, int yyk, yyStateNum yylrState, |
6fed0802 | 964 | size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule) |
01241d47 PH |
965 | { |
966 | yyGLRStackItem* yynewItem; | |
967 | ||
968 | yynewItem = yystack->yynextFree; | |
969 | yynewItem->yystate.yyisState = yytrue; | |
970 | yynewItem->yystate.yylrState = yylrState; | |
971 | yynewItem->yystate.yyposn = yyposn; | |
972 | yynewItem->yystate.yyresolved = yyfalse; | |
973 | yynewItem->yystate.yypred = yystack->yytops.yystates[yyk]; | |
974 | yynewItem->yystate.yysemantics.yyfirstVal = NULL; | |
975 | yystack->yytops.yystates[yyk] = &yynewItem->yystate; | |
976 | yystack->yynextFree += 1; | |
977 | yystack->yyspaceLeft -= 1; | |
6fed0802 | 978 | yyaddDeferredAction (yystack, &yynewItem->yystate, rhs, yyrule); |
01241d47 PH |
979 | } |
980 | ||
981 | /** Pop the symbols consumed by reduction #RULE from the top of stack | |
fb8135fa AD |
982 | * #K of STACK, and perform the appropriate semantic action on their |
983 | * semantic values. Assumes that all ambiguities in semantic values | |
01241d47 PH |
984 | * have been previously resolved. Set *VALP to the resulting value, |
985 | * and *LOCP to the computed location (if any). Return value is as | |
986 | * for userAction. */ | |
987 | static inline int | |
988 | yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule, | |
e7cb57c0 | 989 | YYSTYPE* yyvalp, YYLTYPE* yylocp YY_USER_FORMALS) |
01241d47 PH |
990 | { |
991 | int yynrhs = yyrhsLength (yyrule); | |
992 | ||
fb8135fa | 993 | if (yystack->yysplitPoint == NULL) |
01241d47 PH |
994 | { |
995 | /* Standard special case: single stack. */ | |
6fed0802 | 996 | yyGLRStackItem* rhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk]; |
01241d47 PH |
997 | assert (yyk == 0); |
998 | yystack->yynextFree -= yynrhs; | |
999 | yystack->yyspaceLeft += yynrhs; | |
1000 | yystack->yytops.yystates[0] = & yystack->yynextFree[-1].yystate; | |
fb8135fa | 1001 | if (yynrhs == 0) |
01241d47 PH |
1002 | { |
1003 | *yyvalp = yyval_default; | |
1004 | *yylocp = yyloc_default; | |
1005 | } | |
fb8135fa | 1006 | else |
01241d47 | 1007 | { |
6fed0802 AD |
1008 | *yyvalp = rhs[1-yynrhs].yystate.yysemantics.yysval; |
1009 | *yylocp = rhs[1-yynrhs].yystate.yyloc; | |
01241d47 | 1010 | } |
e7cb57c0 AD |
1011 | return yyuserAction (yyrule, yynrhs, rhs, |
1012 | yyvalp, yylocp, yystack YY_USER_ARGS); | |
01241d47 | 1013 | } |
fb8135fa | 1014 | else |
01241d47 PH |
1015 | { |
1016 | int yyi; | |
1017 | yyGLRState* yys; | |
1018 | yyGLRStackItem yyrhsVals[YYMAXRHS]; | |
39912f52 | 1019 | for (yyi = yynrhs-1, yys = yystack->yytops.yystates[yyk]; 0 <= yyi; |
fb8135fa | 1020 | yyi -= 1, yys = yys->yypred) |
01241d47 PH |
1021 | { |
1022 | assert (yys->yypred != NULL); | |
1023 | yyrhsVals[yyi].yystate.yyresolved = yytrue; | |
1024 | yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval; | |
1025 | yyrhsVals[yyi].yystate.yyloc = yys->yyloc; | |
1026 | } | |
1027 | yyupdateSplit (yystack, yys); | |
1028 | yystack->yytops.yystates[yyk] = yys; | |
fb8135fa | 1029 | if (yynrhs == 0) |
01241d47 PH |
1030 | { |
1031 | *yyvalp = yyval_default; | |
1032 | *yylocp = yyloc_default; | |
1033 | } | |
fb8135fa | 1034 | else |
01241d47 PH |
1035 | { |
1036 | *yyvalp = yyrhsVals[0].yystate.yysemantics.yysval; | |
1037 | *yylocp = yyrhsVals[0].yystate.yyloc; | |
1038 | } | |
fb8135fa | 1039 | return yyuserAction (yyrule, yynrhs, yyrhsVals + (yynrhs-1), |
e7cb57c0 | 1040 | yyvalp, yylocp, yystack YY_USER_ARGS); |
01241d47 PH |
1041 | } |
1042 | } | |
1043 | ||
e7cb57c0 AD |
1044 | #if !YYDEBUG |
1045 | # define YY_REDUCE_PRINT(K, Rule) | |
1046 | #else | |
1047 | # define YY_REDUCE_PRINT(K, Rule) \ | |
1048 | do { \ | |
1049 | if (yydebug) \ | |
1050 | yy_reduce_print (K, Rule); \ | |
1051 | } while (0) | |
1052 | ||
1053 | /*----------------------------------------------------------. | |
1054 | | Report that the RULE is going to be reduced on stack #K. | | |
1055 | `----------------------------------------------------------*/ | |
1056 | ||
1057 | static inline void | |
1058 | yy_reduce_print (size_t yyk, yyRuleNum yyrule) | |
1059 | { | |
1060 | int yyi; | |
1061 | YYDPRINTF ((stderr, "Reducing stack %d by rule %d (line %d),", | |
1062 | yyk, yyrule - 1, yyrline[yyrule])); | |
1063 | /* Print the symbols being reduced, and their result. */ | |
1064 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) | |
1065 | YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi])); | |
1066 | YYFPRINTF (stderr, " -> %s\n", yytokenName (yyr1[yyrule])); | |
1067 | } | |
1068 | #endif | |
1069 | ||
01241d47 PH |
1070 | /** Pop items off stack #K of STACK according to grammar rule RULE, |
1071 | * and push back on the resulting nonterminal symbol. Perform the | |
fb8135fa | 1072 | * semantic action associated with RULE and store its value with the |
01241d47 PH |
1073 | * newly pushed state, if FORCEEVAL or if STACK is currently |
1074 | * unambiguous. Otherwise, store the deferred semantic action with | |
1075 | * the new state. If the new state would have an identical input | |
1076 | * position, LR state, and predecessor to an existing state on the stack, | |
fb8135fa AD |
1077 | * it is identified with that existing state, eliminating stack #K from |
1078 | * the STACK. In this case, the (necessarily deferred) semantic value is | |
1079 | * added to the options for the existing state's semantic value. | |
01241d47 PH |
1080 | */ |
1081 | static inline YYRESULTTAG | |
1154cced | 1082 | yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule, |
e7cb57c0 | 1083 | bool yyforceEval YY_USER_FORMALS) |
01241d47 | 1084 | { |
1154cced | 1085 | size_t yyposn = yystack->yytops.yystates[yyk]->yyposn; |
01241d47 | 1086 | |
fb8135fa | 1087 | if (yyforceEval || yystack->yysplitPoint == NULL) |
01241d47 PH |
1088 | { |
1089 | YYSTYPE yysval; | |
1090 | YYLTYPE yyloc; | |
fb8135fa | 1091 | |
e7cb57c0 AD |
1092 | YY_REDUCE_PRINT (yyk, yyrule); |
1093 | YYCHK (yydoAction (yystack, yyk, yyrule, &yysval, &yyloc YY_USER_ARGS)); | |
fb8135fa AD |
1094 | yyglrShift (yystack, yyk, |
1095 | yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState, | |
01241d47 PH |
1096 | yylhsNonterm (yyrule)), |
1097 | yyposn, yysval, &yyloc); | |
2a1fe6ed AD |
1098 | YYDPRINTF ((stderr, "Stack %d entering state %d\n", |
1099 | yyk, yystack->yytops.yystates[yyk]->yylrState)); | |
01241d47 | 1100 | } |
fb8135fa | 1101 | else |
01241d47 | 1102 | { |
1154cced AD |
1103 | size_t yyi; |
1104 | int yyn; | |
01241d47 PH |
1105 | yyGLRState* yys, *yys0 = yystack->yytops.yystates[yyk]; |
1106 | yyStateNum yynewLRState; | |
1107 | ||
fb8135fa | 1108 | for (yys = yystack->yytops.yystates[yyk], yyn = yyrhsLength (yyrule); |
39912f52 | 1109 | 0 < yyn; yyn -= 1) |
01241d47 PH |
1110 | { |
1111 | yys = yys->yypred; | |
1112 | assert (yys != NULL); | |
1113 | } | |
1114 | yyupdateSplit (yystack, yys); | |
1115 | yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule)); | |
fb8135fa | 1116 | YYDPRINTF ((stderr, |
01241d47 PH |
1117 | "Reduced stack %d by rule #%d; action deferred. " |
1118 | "Now in state %d.\n", | |
1119 | yyk, yyrule-1, yynewLRState)); | |
1120 | for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1) | |
fb8135fa | 1121 | if (yyi != yyk && yystack->yytops.yystates[yyi] != NULL) |
01241d47 PH |
1122 | { |
1123 | yyGLRState* yyp, *yysplit = yystack->yysplitPoint; | |
1124 | yyp = yystack->yytops.yystates[yyi]; | |
fb8135fa | 1125 | while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn) |
01241d47 | 1126 | { |
fb8135fa | 1127 | if (yyp->yylrState == yynewLRState && yyp->yypred == yys) |
01241d47 PH |
1128 | { |
1129 | yyaddDeferredAction (yystack, yyp, yys0, yyrule); | |
1130 | yymarkStackDeleted (yystack, yyk); | |
1131 | YYDPRINTF ((stderr, "Merging stack %d into stack %d.\n", | |
1132 | yyk, yyi)); | |
1133 | return 0; | |
1134 | } | |
1135 | yyp = yyp->yypred; | |
1136 | } | |
1137 | } | |
1138 | yystack->yytops.yystates[yyk] = yys; | |
1139 | yyglrShiftDefer (yystack, yyk, yynewLRState, yyposn, yys0, yyrule); | |
fb8135fa | 1140 | } |
01241d47 PH |
1141 | return 0; |
1142 | } | |
1143 | ||
1144 | static int | |
1145 | yysplitStack (yyGLRStack* yystack, int yyk) | |
1146 | { | |
fb8135fa | 1147 | if (yystack->yysplitPoint == NULL) |
01241d47 PH |
1148 | { |
1149 | assert (yyk == 0); | |
1150 | yystack->yysplitPoint = yystack->yytops.yystates[yyk]; | |
1151 | } | |
fb8135fa | 1152 | if (yystack->yytops.yysize >= yystack->yytops.yycapacity) |
01241d47 PH |
1153 | { |
1154 | yystack->yytops.yycapacity *= 2; | |
fb8135fa AD |
1155 | yystack->yytops.yystates = |
1156 | (yyGLRState**) realloc (yystack->yytops.yystates, | |
1157 | yystack->yytops.yycapacity | |
01241d47 PH |
1158 | * sizeof (yyGLRState*)); |
1159 | } | |
fb8135fa | 1160 | yystack->yytops.yystates[yystack->yytops.yysize] |
01241d47 PH |
1161 | = yystack->yytops.yystates[yyk]; |
1162 | yystack->yytops.yysize += 1; | |
1163 | return yystack->yytops.yysize-1; | |
1164 | } | |
1165 | ||
1166 | /** True iff Y0 and Y1 represent identical options at the top level. | |
1167 | * That is, they represent the same rule applied to RHS symbols | |
1168 | * that produce the same terminal symbols. */ | |
1169 | static bool | |
1170 | yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1) | |
1171 | { | |
fb8135fa | 1172 | if (yyy0->yyrule == yyy1->yyrule) |
01241d47 PH |
1173 | { |
1174 | yyGLRState *yys0, *yys1; | |
1175 | int yyn; | |
fb8135fa | 1176 | for (yys0 = yyy0->yystate, yys1 = yyy1->yystate, |
01241d47 PH |
1177 | yyn = yyrhsLength (yyy0->yyrule); |
1178 | yyn > 0; | |
1179 | yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1) | |
1180 | if (yys0->yyposn != yys1->yyposn) | |
1181 | return yyfalse; | |
1182 | return yytrue; | |
1183 | } | |
1184 | else | |
1185 | return yyfalse; | |
1186 | } | |
1187 | ||
1188 | /** Assuming identicalOptions (Y0,Y1), (destructively) merge the | |
fb8135fa | 1189 | * alternative semantic values for the RHS-symbols of Y1 into the |
01241d47 PH |
1190 | * corresponding semantic value sets of the symbols of Y0. */ |
1191 | static void | |
1192 | yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) | |
1193 | { | |
1194 | yyGLRState *yys0, *yys1; | |
1195 | int yyn; | |
fb8135fa | 1196 | for (yys0 = yyy0->yystate, yys1 = yyy1->yystate, |
01241d47 PH |
1197 | yyn = yyrhsLength (yyy0->yyrule); |
1198 | yyn > 0; | |
1199 | yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1) | |
1200 | if (yys0 == yys1) | |
1201 | break; | |
fb8135fa | 1202 | else if (! yys0->yyresolved && ! yys1->yyresolved) |
01241d47 PH |
1203 | { |
1204 | yySemanticOption* yyz; | |
fb8135fa | 1205 | for (yyz = yys0->yysemantics.yyfirstVal; yyz->yynext != NULL; |
01241d47 PH |
1206 | yyz = yyz->yynext) |
1207 | ; | |
1208 | yyz->yynext = yys1->yysemantics.yyfirstVal; | |
1209 | } | |
1210 | } | |
1211 | ||
1212 | /** Y0 and Y1 represent two possible actions to take in a given | |
1213 | * parsing state; return 0 if no combination is possible, | |
1214 | * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */ | |
1215 | static int | |
1154cced | 1216 | yypreference (yySemanticOption* y0, yySemanticOption* y1) |
01241d47 | 1217 | { |
1154cced AD |
1218 | yyRuleNum r0 = y0->yyrule, r1 = y1->yyrule; |
1219 | int p0 = yydprec[r0], p1 = yydprec[r1]; | |
01241d47 | 1220 | |
1154cced | 1221 | if (p0 == p1) |
01241d47 | 1222 | { |
1154cced | 1223 | if (yymerger[r0] == 0 || yymerger[r0] != yymerger[r1]) |
01241d47 PH |
1224 | return 0; |
1225 | else | |
1226 | return 1; | |
1227 | } | |
1154cced | 1228 | if (p0 == 0 || p1 == 0) |
01241d47 | 1229 | return 0; |
1154cced | 1230 | if (p0 < p1) |
01241d47 | 1231 | return 3; |
39912f52 | 1232 | if (p1 < p0) |
01241d47 PH |
1233 | return 2; |
1234 | return 0; | |
1235 | } | |
1236 | ||
fb8135fa AD |
1237 | static YYRESULTTAG yyresolveValue (yySemanticOption* yyoptionList, |
1238 | yyGLRStack* yystack, YYSTYPE* yyvalp, | |
e7cb57c0 | 1239 | YYLTYPE* yylocp YY_USER_FORMALS); |
01241d47 PH |
1240 | |
1241 | static YYRESULTTAG | |
e7cb57c0 | 1242 | yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack YY_USER_FORMALS) |
01241d47 PH |
1243 | { |
1244 | YYRESULTTAG yyflag; | |
39912f52 | 1245 | if (0 < yyn) |
01241d47 PH |
1246 | { |
1247 | assert (yys->yypred != NULL); | |
e7cb57c0 | 1248 | yyflag = yyresolveStates (yys->yypred, yyn-1, yystack YY_USER_ARGS); |
01241d47 PH |
1249 | if (yyflag != yyok) |
1250 | return yyflag; | |
fb8135fa | 1251 | if (! yys->yyresolved) |
01241d47 PH |
1252 | { |
1253 | yyflag = yyresolveValue (yys->yysemantics.yyfirstVal, yystack, | |
e7cb57c0 AD |
1254 | &yys->yysemantics.yysval, &yys->yyloc |
1255 | YY_USER_ARGS); | |
01241d47 PH |
1256 | if (yyflag != yyok) |
1257 | return yyflag; | |
1258 | yys->yyresolved = yytrue; | |
1259 | } | |
1260 | } | |
1261 | return yyok; | |
1262 | } | |
1263 | ||
1264 | static YYRESULTTAG | |
fb8135fa | 1265 | yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack, |
e7cb57c0 | 1266 | YYSTYPE* yyvalp, YYLTYPE* yylocp YY_USER_FORMALS) |
01241d47 PH |
1267 | { |
1268 | yyGLRStackItem yyrhsVals[YYMAXRHS]; | |
1269 | int yynrhs, yyi; | |
1270 | yyGLRState* yys; | |
1271 | ||
1272 | yynrhs = yyrhsLength (yyopt->yyrule); | |
e7cb57c0 | 1273 | YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack YY_USER_ARGS)); |
39912f52 | 1274 | for (yyi = yynrhs-1, yys = yyopt->yystate; 0 <= yyi; |
01241d47 PH |
1275 | yyi -= 1, yys = yys->yypred) |
1276 | { | |
1277 | assert (yys->yypred != NULL); | |
1278 | yyrhsVals[yyi].yystate.yyresolved = yytrue; | |
1279 | yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval; | |
1280 | yyrhsVals[yyi].yystate.yyloc = yys->yyloc; | |
fb8135fa AD |
1281 | } |
1282 | return yyuserAction (yyopt->yyrule, yynrhs, yyrhsVals + (yynrhs-1), | |
e7cb57c0 | 1283 | yyvalp, yylocp, yystack YY_USER_ARGS); |
01241d47 PH |
1284 | } |
1285 | ||
1286 | #if YYDEBUG | |
7ebc83e3 AD |
1287 | static yyGLRState YYLEFTMOST_STATE = |
1288 | { | |
1289 | 0, 0, -1, NULL, 0, { NULL }, | |
1290 | /* yyloc. */ | |
1291 | { | |
1292 | #if YYLTYPE_IS_TRIVIAL | |
1293 | ]b4_location_if([ 0, 0, 0, 0])[ | |
1294 | #endif | |
1295 | } | |
1296 | }; | |
01241d47 | 1297 | |
e7cb57c0 AD |
1298 | static void |
1299 | yyreportTree (yySemanticOption* yyx, int yyindent) | |
01241d47 PH |
1300 | { |
1301 | int yynrhs = yyrhsLength (yyx->yyrule); | |
1302 | int yyi; | |
1303 | yyGLRState* yys; | |
1304 | yyGLRState* yystates[YYMAXRHS]; | |
1305 | ||
39912f52 | 1306 | for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred) |
01241d47 PH |
1307 | yystates[yyi] = yys; |
1308 | if (yys == NULL) | |
1309 | yystates[0] = &YYLEFTMOST_STATE; | |
1310 | else | |
1311 | yystates[0] = yys; | |
1312 | ||
39912f52 | 1313 | if (yyx->yystate->yyposn < yys->yyposn + 1) |
01241d47 | 1314 | YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n", |
fb8135fa | 1315 | yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)), |
01241d47 PH |
1316 | yyx->yyrule); |
1317 | else | |
fb8135fa | 1318 | YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %d .. %d>\n", |
01241d47 PH |
1319 | yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)), |
1320 | yyx->yyrule, yys->yyposn+1, yyx->yystate->yyposn); | |
fb8135fa | 1321 | for (yyi = 1; yyi <= yynrhs; yyi += 1) |
01241d47 | 1322 | { |
fb8135fa | 1323 | if (yystates[yyi]->yyresolved) |
01241d47 PH |
1324 | { |
1325 | if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn) | |
1326 | YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "", | |
1327 | yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1])); | |
1328 | else | |
1329 | YYFPRINTF (stderr, "%*s%s <tokens %d .. %d>\n", yyindent+2, "", | |
1330 | yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]), | |
1331 | yystates[yyi-1]->yyposn+1, yystates[yyi]->yyposn); | |
1332 | } | |
fb8135fa | 1333 | else |
01241d47 PH |
1334 | yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2); |
1335 | } | |
1336 | } | |
fb8135fa | 1337 | #endif |
01241d47 PH |
1338 | |
1339 | static void | |
1340 | yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1, | |
1341 | yyGLRStack* yystack) | |
1342 | { | |
1154cced AD |
1343 | /* `Unused' warnings. */ |
1344 | (void) yyx0; | |
1345 | (void) yyx1; | |
1346 | ||
01241d47 PH |
1347 | #if YYDEBUG |
1348 | YYFPRINTF (stderr, "Ambiguity detected.\n"); | |
1349 | YYFPRINTF (stderr, "Option 1,\n"); | |
1350 | yyreportTree (yyx0, 2); | |
1351 | YYFPRINTF (stderr, "\nOption 2,\n"); | |
1352 | yyreportTree (yyx1, 2); | |
1353 | YYFPRINTF (stderr, "\n"); | |
1354 | #endif | |
1355 | yyFail (yystack, "ambiguity detected"); | |
1356 | } | |
1357 | ||
1358 | ||
1359 | /** Resolve the ambiguity represented by OPTIONLIST, perform the indicated | |
1360 | * actions, and return the result. */ | |
1361 | static YYRESULTTAG | |
fb8135fa | 1362 | yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack, |
e7cb57c0 | 1363 | YYSTYPE* yyvalp, YYLTYPE* yylocp YY_USER_FORMALS) |
01241d47 PH |
1364 | { |
1365 | yySemanticOption* yybest; | |
1366 | yySemanticOption* yyp; | |
1367 | int yymerge; | |
1368 | ||
fb8135fa | 1369 | yybest = yyoptionList; |
01241d47 | 1370 | yymerge = 0; |
fb8135fa | 1371 | for (yyp = yyoptionList->yynext; yyp != NULL; yyp = yyp->yynext) |
01241d47 PH |
1372 | { |
1373 | if (yyidenticalOptions (yybest, yyp)) | |
1374 | yymergeOptionSets (yybest, yyp); | |
1375 | else | |
fb8135fa | 1376 | switch (yypreference (yybest, yyp)) |
01241d47 PH |
1377 | { |
1378 | case 0: | |
1379 | yyreportAmbiguity (yybest, yyp, yystack); | |
1380 | break; | |
1381 | case 1: | |
1382 | yymerge = 1; | |
1383 | break; | |
1384 | case 2: | |
1385 | break; | |
1386 | case 3: | |
1387 | yybest = yyp; | |
1388 | yymerge = 0; | |
1389 | break; | |
1390 | } | |
1391 | } | |
1392 | ||
fb8135fa | 1393 | if (yymerge) |
01241d47 PH |
1394 | { |
1395 | int yyprec = yydprec[yybest->yyrule]; | |
e7cb57c0 | 1396 | YYCHK (yyresolveAction (yybest, yystack, yyvalp, yylocp YY_USER_ARGS)); |
fb8135fa | 1397 | for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext) |
01241d47 | 1398 | { |
fb8135fa | 1399 | if (yyprec == yydprec[yyp->yyrule]) |
01241d47 PH |
1400 | { |
1401 | YYSTYPE yyval1; | |
1402 | YYLTYPE yydummy; | |
e7cb57c0 | 1403 | YYCHK (yyresolveAction (yyp, yystack, &yyval1, &yydummy YY_USER_ARGS)); |
01241d47 PH |
1404 | *yyvalp = yyuserMerge (yymerger[yyp->yyrule], yyvalp, &yyval1); |
1405 | } | |
1406 | } | |
1407 | return yyok; | |
1408 | } | |
1409 | else | |
e7cb57c0 | 1410 | return yyresolveAction (yybest, yystack, yyvalp, yylocp YY_USER_ARGS); |
01241d47 PH |
1411 | } |
1412 | ||
1413 | static YYRESULTTAG | |
e7cb57c0 | 1414 | yyresolveStack (yyGLRStack* yystack YY_USER_FORMALS) |
01241d47 | 1415 | { |
fb8135fa | 1416 | if (yystack->yysplitPoint != NULL) |
01241d47 PH |
1417 | { |
1418 | yyGLRState* yys; | |
1419 | int yyn; | |
1420 | ||
fb8135fa AD |
1421 | for (yyn = 0, yys = yystack->yytops.yystates[0]; |
1422 | yys != yystack->yysplitPoint; | |
01241d47 PH |
1423 | yys = yys->yypred, yyn += 1) |
1424 | ; | |
e7cb57c0 AD |
1425 | YYCHK (yyresolveStates (yystack->yytops.yystates[0], yyn, yystack |
1426 | YY_USER_ARGS)); | |
01241d47 PH |
1427 | } |
1428 | return yyok; | |
1429 | } | |
1430 | ||
1431 | static void | |
fb8135fa | 1432 | yycompressStack (yyGLRStack* yystack) |
01241d47 PH |
1433 | { |
1434 | yyGLRState* yyp, *yyq, *yyr; | |
1435 | ||
1436 | if (yystack->yytops.yysize != 1 || yystack->yysplitPoint == NULL) | |
1437 | return; | |
1438 | ||
fb8135fa AD |
1439 | for (yyp = yystack->yytops.yystates[0], yyq = yyp->yypred, yyr = NULL; |
1440 | yyp != yystack->yysplitPoint; | |
01241d47 PH |
1441 | yyr = yyp, yyp = yyq, yyq = yyp->yypred) |
1442 | yyp->yypred = yyr; | |
fb8135fa | 1443 | |
01241d47 PH |
1444 | yystack->yyspaceLeft += yystack->yynextFree - yystack->yyitems; |
1445 | yystack->yynextFree = ((yyGLRStackItem*) yystack->yysplitPoint) + 1; | |
1446 | yystack->yyspaceLeft -= yystack->yynextFree - yystack->yyitems; | |
1447 | yystack->yysplitPoint = NULL; | |
1448 | yystack->yylastDeleted = NULL; | |
fb8135fa AD |
1449 | |
1450 | while (yyr != NULL) | |
1451 | { | |
01241d47 PH |
1452 | yystack->yynextFree->yystate = *yyr; |
1453 | yyr = yyr->yypred; | |
1454 | yystack->yynextFree->yystate.yypred = & yystack->yynextFree[-1].yystate; | |
1455 | yystack->yytops.yystates[0] = &yystack->yynextFree->yystate; | |
1456 | yystack->yynextFree += 1; | |
1457 | yystack->yyspaceLeft -= 1; | |
1458 | } | |
1459 | } | |
1460 | ||
1461 | static YYRESULTTAG | |
fb8135fa | 1462 | yyprocessOneStack (yyGLRStack* yystack, int yyk, |
e7cb57c0 AD |
1463 | size_t yyposn, YYSTYPE* yylvalp, YYLTYPE* yyllocp |
1464 | YY_USER_FORMALS) | |
01241d47 PH |
1465 | { |
1466 | int yyaction; | |
1467 | const short* yyconflicts; | |
1468 | yyRuleNum yyrule; | |
1469 | yySymbol* const yytokenp = yystack->yytokenp; | |
1470 | ||
fb8135fa | 1471 | while (yystack->yytops.yystates[yyk] != NULL) |
01241d47 PH |
1472 | { |
1473 | yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState; | |
1474 | ||
1475 | assert (yystate != YYFINAL); | |
fb8135fa | 1476 | if (yyisDefaultedState (yystate)) |
01241d47 PH |
1477 | { |
1478 | yyrule = yydefaultAction (yystate); | |
fb8135fa | 1479 | if (yyrule == 0) |
01241d47 PH |
1480 | { |
1481 | YYDPRINTF ((stderr, "Stack %d dies.\n", yyk)); | |
1482 | yymarkStackDeleted (yystack, yyk); | |
1483 | return yyok; | |
1484 | } | |
e7cb57c0 | 1485 | YYCHK (yyglrReduce (yystack, yyk, yyrule, yyfalse YY_USER_ARGS)); |
01241d47 | 1486 | } |
fb8135fa | 1487 | else |
01241d47 | 1488 | { |
fb8135fa | 1489 | if (*yytokenp == YYEMPTY) |
01241d47 | 1490 | { |
2a1fe6ed | 1491 | YYDPRINTF ((stderr, "Reading a token: ")); |
01241d47 PH |
1492 | yychar = YYLEX; |
1493 | *yytokenp = YYTRANSLATE(yychar); | |
2a1fe6ed AD |
1494 | YYDPRINTF ((stderr, "Next token is %s\n", |
1495 | yytokenName (*yytokenp))); | |
01241d47 PH |
1496 | } |
1497 | yygetLRActions (yystate, *yytokenp, &yyaction, &yyconflicts); | |
1498 | ||
fb8135fa | 1499 | while (*yyconflicts != 0) |
01241d47 PH |
1500 | { |
1501 | int yynewStack = yysplitStack (yystack, yyk); | |
1502 | YYDPRINTF ((stderr, "Splitting off stack %d from %d.\n", | |
1503 | yynewStack, yyk)); | |
e7cb57c0 AD |
1504 | YYCHK (yyglrReduce (yystack, yynewStack, |
1505 | *yyconflicts, yyfalse YY_USER_ARGS)); | |
fb8135fa | 1506 | YYCHK (yyprocessOneStack (yystack, yynewStack, yyposn, |
e7cb57c0 | 1507 | yylvalp, yyllocp YY_USER_ARGS)); |
01241d47 PH |
1508 | yyconflicts += 1; |
1509 | } | |
fb8135fa AD |
1510 | |
1511 | if (yyisShiftAction (yyaction)) | |
01241d47 | 1512 | { |
2a1fe6ed | 1513 | YYDPRINTF ((stderr, "Shifting token %s on stack %d, ", |
01241d47 PH |
1514 | yytokenName (*yytokenp), yyk)); |
1515 | yyglrShift (yystack, yyk, yyaction, yyposn+1, *yylvalp, yyllocp); | |
fb8135fa | 1516 | YYDPRINTF ((stderr, "which is now in state #%d\n", |
01241d47 PH |
1517 | yystack->yytops.yystates[yyk]->yylrState)); |
1518 | break; | |
1519 | } | |
fb8135fa | 1520 | else if (yyisErrorAction (yyaction)) |
01241d47 PH |
1521 | { |
1522 | YYDPRINTF ((stderr, "Stack %d dies.\n", yyk)); | |
1523 | yymarkStackDeleted (yystack, yyk); | |
1524 | break; | |
1525 | } | |
1526 | else | |
e7cb57c0 | 1527 | YYCHK (yyglrReduce (yystack, yyk, -yyaction, yyfalse YY_USER_ARGS)); |
01241d47 PH |
1528 | } |
1529 | } | |
1530 | return yyok; | |
1531 | } | |
1532 | ||
1533 | static void | |
1534 | yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp) | |
1535 | { | |
1154cced AD |
1536 | /* `Unused' warnings. */ |
1537 | (void) yylvalp; | |
1538 | (void) yyllocp; | |
01241d47 PH |
1539 | |
1540 | if (yystack->yyerrState == 0) | |
1541 | { | |
fb8135fa | 1542 | #if YYERROR_VERBOSE |
1154cced | 1543 | yySymbol* const yytokenp = yystack->yytokenp; |
cf126971 PE |
1544 | int yyn, yyx, yycount; |
1545 | size_t yysize; | |
1154cced | 1546 | const char* yyprefix; |
01241d47 PH |
1547 | char* yyp; |
1548 | char* yymsg; | |
1549 | yyn = yypact[yystack->yytops.yystates[0]->yylrState]; | |
12b0043a | 1550 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
01241d47 PH |
1551 | { |
1552 | yycount = 0; | |
1553 | /* Start YYX at -YYN if negative to avoid negative indexes in | |
1554 | YYCHECK. */ | |
fb8135fa | 1555 | yysize = sizeof ("parse error, unexpected ") |
01241d47 PH |
1556 | + strlen (yytokenName (*yytokenp)); |
1557 | yyprefix = ", expecting "; | |
fb8135fa | 1558 | for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size && yycount <= 5; |
01241d47 | 1559 | yyx += 1) |
217598da | 1560 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
01241d47 PH |
1561 | yysize += strlen (yytokenName (yyx)) + strlen (yyprefix), |
1562 | yycount += 1, yyprefix = " or "; | |
1563 | yymsg = yyp = (char*) malloc (yysize); | |
3eb49163 PE |
1564 | sprintf (yyp, "parse error, unexpected %s", |
1565 | yytokenName (*yytokenp)); | |
1566 | yyp += strlen (yyp); | |
01241d47 PH |
1567 | if (yycount < 5) |
1568 | { | |
1569 | yyprefix = ", expecting "; | |
1570 | for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size; yyx += 1) | |
f50adbbd | 1571 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
01241d47 | 1572 | { |
3eb49163 PE |
1573 | sprintf (yyp, "%s%s", yyprefix, yytokenName (yyx)); |
1574 | yyp += strlen (yyp); | |
01241d47 PH |
1575 | yyprefix = " or "; |
1576 | } | |
1577 | } | |
1578 | yyerror (yymsg); | |
1579 | free (yymsg); | |
1580 | } | |
1581 | else | |
1582 | #endif | |
1583 | yyerror ("parse error"); | |
1584 | yynerrs += 1; | |
1585 | } | |
1586 | } | |
1587 | ||
f50adbbd | 1588 | /* Recover from a syntax error on YYSTACK, assuming that YYTOKENP, |
01241d47 | 1589 | YYLVALP, and YYLLOCP point to the syntactic category, semantic |
f50adbbd | 1590 | value, and location of the lookahead. */ |
fb8135fa | 1591 | static void |
01241d47 PH |
1592 | yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp) |
1593 | { | |
1594 | yySymbol* const yytokenp = yystack->yytokenp; | |
1154cced AD |
1595 | size_t yyk; |
1596 | int yyj; | |
01241d47 | 1597 | |
fb8135fa | 1598 | if (yystack->yyerrState == 0) |
01241d47 | 1599 | yystack->yyerrState = 3; |
fb8135fa | 1600 | else if (yystack->yyerrState == 3) |
2a1fe6ed AD |
1601 | /* We just shifted the error token and (perhaps) took some |
1602 | reductions. Skip tokens until we can proceed. */ | |
1603 | while (yytrue) | |
1604 | { | |
01241d47 PH |
1605 | if (*yytokenp == YYEOF) |
1606 | yyFail (yystack, NULL); | |
1607 | if (*yytokenp != YYEMPTY) | |
fb8135fa | 1608 | YYDPRINTF ((stderr, "Discarding token %s\n", |
01241d47 | 1609 | yytokenName (*yytokenp))); |
2a1fe6ed | 1610 | YYDPRINTF ((stderr, "Reading a token: ")); |
01241d47 PH |
1611 | yychar = YYLEX; |
1612 | *yytokenp = YYTRANSLATE (yychar); | |
2a1fe6ed | 1613 | YYDPRINTF ((stderr, "Next token is %s\n", yytokenName (*yytokenp))); |
01241d47 | 1614 | yyj = yypact[yystack->yytops.yystates[0]->yylrState]; |
12b0043a | 1615 | if (yyj == YYPACT_NINF) |
2a1fe6ed | 1616 | /* Something's not right; we shouldn't be here. */ |
01241d47 PH |
1617 | yyFail (yystack, NULL); |
1618 | yyj += *yytokenp; | |
ea99527d | 1619 | if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != *yytokenp) |
01241d47 PH |
1620 | { |
1621 | if (yydefact[yystack->yytops.yystates[0]->yylrState] != 0) | |
1622 | return; | |
1623 | } | |
12b0043a | 1624 | else if (yytable[yyj] != 0 && yytable[yyj] != YYTABLE_NINF) |
01241d47 | 1625 | return; |
2a1fe6ed | 1626 | } |
fb8135fa | 1627 | |
2a1fe6ed | 1628 | /* Reduce to one stack. */ |
01241d47 PH |
1629 | for (yyk = 0; yyk < yystack->yytops.yysize; yyk += 1) |
1630 | if (yystack->yytops.yystates[yyk] != NULL) | |
1631 | break; | |
1632 | if (yyk >= yystack->yytops.yysize) | |
1633 | yyFail (yystack, NULL); | |
1634 | for (yyk += 1; yyk < yystack->yytops.yysize; yyk += 1) | |
1635 | yymarkStackDeleted (yystack, yyk); | |
1636 | yyremoveDeletes (yystack); | |
1637 | yycompressStack (yystack); | |
1638 | ||
1639 | /* Now pop stack until we find a state that shifts the error token. */ | |
fb8135fa | 1640 | while (yystack->yytops.yystates[0] != NULL) |
01241d47 PH |
1641 | { |
1642 | yyj = yypact[yystack->yytops.yystates[0]->yylrState] + YYTERROR; | |
12b0043a | 1643 | if (yyj != YYPACT_NINF + YYTERROR && yyj >= 0 && yyj <= YYLAST && |
01241d47 PH |
1644 | yycheck[yyj] == YYTERROR && yyisShiftAction (yytable[yyj])) |
1645 | { | |
fb8135fa | 1646 | yyglrShift (yystack, 0, yytable[yyj], |
01241d47 PH |
1647 | yystack->yytops.yystates[0]->yyposn, *yylvalp, yyllocp); |
1648 | break; | |
1649 | } | |
1650 | yystack->yytops.yystates[0] = yystack->yytops.yystates[0]->yypred; | |
1651 | yystack->yynextFree -= 1; | |
1652 | yystack->yyspaceLeft += 1; | |
1653 | } | |
1654 | if (yystack->yytops.yystates[0] == NULL) | |
1655 | yyFail (yystack, NULL); | |
fb8135fa AD |
1656 | } |
1657 | ||
01241d47 PH |
1658 | #define YYCHK1(YYE) \ |
1659 | do { \ | |
1660 | switch (YYE) { \ | |
1661 | default: \ | |
1662 | break; \ | |
1663 | case yyabort: \ | |
1664 | yystack.yyerrflag = 1; \ | |
1665 | goto yyDone; \ | |
1666 | case yyaccept: \ | |
1667 | yystack.yyerrflag = 0; \ | |
1668 | goto yyDone; \ | |
1669 | case yyerr: \ | |
1670 | goto yyuser_error; \ | |
1671 | } \ | |
fb8135fa | 1672 | } while (0) |
01241d47 | 1673 | |
0245f82d AD |
1674 | |
1675 | /*----------. | |
1676 | | yyparse. | | |
1677 | `----------*/ | |
1678 | ||
1679 | ]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[ | |
01241d47 PH |
1680 | { |
1681 | yySymbol yytoken; | |
1682 | yyGLRStack yystack; | |
1683 | size_t yyposn; | |
1684 | ]b4_pure_if( | |
1685 | [ | |
1686 | YYSTYPE yylval; | |
1687 | YYLTYPE yylloc; | |
1688 | #undef yychar | |
1689 | #define yychar (yystack.yyrawchar) | |
1690 | ])[ | |
1691 | ||
1692 | YYSTYPE* const yylvalp = &yylval; | |
1693 | YYLTYPE* const yyllocp = &yylloc; | |
fb8135fa | 1694 | |
01241d47 PH |
1695 | yyinitGLRStack (&yystack, YYINITDEPTH); |
1696 | yystack.yytokenp = &yytoken; | |
1697 | ||
2a1fe6ed AD |
1698 | YYDPRINTF ((stderr, "Starting parse\n")); |
1699 | ||
01241d47 PH |
1700 | if (setjmp (yystack.yyexception_buffer) != 0) |
1701 | goto yyDone; | |
1702 | ||
1703 | yyglrShift (&yystack, 0, 0, 0, yyval_default, &yyloc_default); | |
1704 | yytoken = YYEMPTY; | |
1705 | yyposn = 0; | |
1706 | ||
fb8135fa | 1707 | while (yytrue) |
01241d47 | 1708 | { |
21964f43 AD |
1709 | /* For efficiency, we have two loops, the first of which is |
1710 | specialized to deterministic operation (single stack, no | |
1711 | potential ambiguity). */ | |
fb8135fa | 1712 | |
01241d47 | 1713 | /* Standard mode */ |
fb8135fa | 1714 | while (yytrue) |
01241d47 PH |
1715 | { |
1716 | yyRuleNum yyrule; | |
1717 | int yyaction; | |
1718 | const short* yyconflicts; | |
1719 | ||
1720 | yyStateNum yystate = yystack.yytops.yystates[0]->yylrState; | |
1721 | if (yystate == YYFINAL) | |
1722 | goto yyDone; | |
fb8135fa | 1723 | if (yyisDefaultedState (yystate)) |
01241d47 PH |
1724 | { |
1725 | yyrule = yydefaultAction (yystate); | |
fb8135fa | 1726 | if (yyrule == 0) |
01241d47 PH |
1727 | { |
1728 | yyreportParseError (&yystack, yylvalp, yyllocp); | |
1729 | goto yyuser_error; | |
1730 | } | |
e7cb57c0 | 1731 | YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue YY_USER_ARGS)); |
01241d47 | 1732 | } |
fb8135fa | 1733 | else |
01241d47 | 1734 | { |
fb8135fa | 1735 | if (yytoken == YYEMPTY) |
01241d47 | 1736 | { |
2a1fe6ed | 1737 | YYDPRINTF ((stderr, "Reading a token: ")); |
01241d47 PH |
1738 | yychar = YYLEX; |
1739 | yytoken = YYTRANSLATE (yychar); | |
2a1fe6ed | 1740 | YYDPRINTF ((stderr, "Next token is %s\n", |
01241d47 PH |
1741 | yytokenName (yytoken))); |
1742 | } | |
1743 | yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts); | |
1744 | if (*yyconflicts != 0) | |
1745 | break; | |
fb8135fa | 1746 | if (yyisShiftAction (yyaction)) |
01241d47 | 1747 | { |
2a1fe6ed | 1748 | YYDPRINTF ((stderr, "Shifting token %s, ", |
01241d47 PH |
1749 | yytokenName (yytoken))); |
1750 | if (yytoken != YYEOF) | |
1751 | yytoken = YYEMPTY; | |
1752 | yyposn += 1; | |
1753 | yyglrShift (&yystack, 0, yyaction, yyposn, yylval, yyllocp); | |
39912f52 | 1754 | if (0 < yystack.yyerrState) |
01241d47 | 1755 | yystack.yyerrState -= 1; |
2a1fe6ed | 1756 | YYDPRINTF ((stderr, "Entering state %d\n", |
01241d47 PH |
1757 | yystack.yytops.yystates[0]->yylrState)); |
1758 | } | |
1759 | else if (yyisErrorAction (yyaction)) | |
1760 | { | |
1761 | yyreportParseError (&yystack, yylvalp, yyllocp); | |
1762 | goto yyuser_error; | |
1763 | } | |
1764 | else | |
e7cb57c0 | 1765 | YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue YY_USER_ARGS)); |
01241d47 PH |
1766 | } |
1767 | } | |
1768 | ||
fb8135fa | 1769 | while (yytrue) |
01241d47 PH |
1770 | { |
1771 | int yys; | |
1772 | int yyn = yystack.yytops.yysize; | |
1773 | for (yys = 0; yys < yyn; yys += 1) | |
1774 | YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn, | |
e7cb57c0 | 1775 | yylvalp, yyllocp YY_USER_ARGS)); |
01241d47 PH |
1776 | yytoken = YYEMPTY; |
1777 | yyposn += 1; | |
1778 | yyremoveDeletes (&yystack); | |
1779 | if (yystack.yytops.yysize == 0) | |
1780 | { | |
1781 | yyundeleteLastStack (&yystack); | |
1782 | if (yystack.yytops.yysize == 0) | |
1783 | yyFail (&yystack, "parse error"); | |
e7cb57c0 | 1784 | YYCHK1 (yyresolveStack (&yystack YY_USER_ARGS)); |
01241d47 PH |
1785 | YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); |
1786 | yyreportParseError (&yystack, yylvalp, yyllocp); | |
1787 | goto yyuser_error; | |
1788 | } | |
fb8135fa | 1789 | else if (yystack.yytops.yysize == 1) |
01241d47 | 1790 | { |
e7cb57c0 | 1791 | YYCHK1 (yyresolveStack (&yystack YY_USER_ARGS)); |
01241d47 PH |
1792 | YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); |
1793 | yycompressStack (&yystack); | |
1794 | break; | |
1795 | } | |
1796 | } | |
1797 | continue; | |
1798 | yyuser_error: | |
1799 | yyrecoverParseError (&yystack, yylvalp, yyllocp); | |
1800 | yyposn = yystack.yytops.yystates[0]->yyposn; | |
1801 | } | |
1802 | yyDone: | |
1803 | ; | |
1804 | ||
1805 | yyfreeGLRStack (&yystack); | |
1806 | return yystack.yyerrflag; | |
1807 | } | |
1808 | ||
1809 | /* DEBUGGING ONLY */ | |
1154cced AD |
1810 | static void yypstack (yyGLRStack* yystack, int yyk) ATTRIBUTE_UNUSED; |
1811 | static void yypdumpstack (yyGLRStack* yystack) ATTRIBUTE_UNUSED; | |
01241d47 | 1812 | |
1154cced | 1813 | static void |
cf126971 | 1814 | yy_yypstack (yyGLRState* yys) |
01241d47 | 1815 | { |
cf126971 | 1816 | if (yys->yypred) |
01241d47 | 1817 | { |
cf126971 PE |
1818 | yy_yypstack (yys->yypred); |
1819 | fprintf (stderr, " -> "); | |
01241d47 | 1820 | } |
cf126971 PE |
1821 | fprintf (stderr, "%d@%lu", yys->yylrState, (unsigned long) yys->yyposn); |
1822 | } | |
01241d47 | 1823 | |
cf126971 PE |
1824 | static void |
1825 | yypstates (yyGLRState* yyst) | |
1826 | { | |
fb8135fa | 1827 | if (yyst == NULL) |
01241d47 | 1828 | fprintf (stderr, "<null>"); |
fb8135fa | 1829 | else |
01241d47 PH |
1830 | yy_yypstack (yyst); |
1831 | fprintf (stderr, "\n"); | |
1832 | } | |
1833 | ||
1154cced | 1834 | static void |
fb8135fa | 1835 | yypstack (yyGLRStack* yystack, int yyk) |
01241d47 PH |
1836 | { |
1837 | yypstates (yystack->yytops.yystates[yyk]); | |
1838 | } | |
1839 | ||
1840 | #define YYINDEX(YYX) \ | |
1841 | ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems) | |
1842 | ||
1843 | ||
1154cced | 1844 | static void |
fb8135fa | 1845 | yypdumpstack (yyGLRStack* yystack) |
01241d47 PH |
1846 | { |
1847 | yyGLRStackItem* yyp; | |
1154cced | 1848 | size_t yyi; |
fb8135fa | 1849 | for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1) |
01241d47 | 1850 | { |
cf126971 | 1851 | fprintf (stderr, "%3lu. ", (unsigned long) (yyp - yystack->yyitems)); |
fb8135fa | 1852 | if (*(bool*) yyp) |
01241d47 | 1853 | { |
cf126971 | 1854 | fprintf (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld", |
fb8135fa | 1855 | yyp->yystate.yyresolved, yyp->yystate.yylrState, |
cf126971 PE |
1856 | (unsigned long) yyp->yystate.yyposn, |
1857 | (long) YYINDEX (yyp->yystate.yypred)); | |
fb8135fa | 1858 | if (! yyp->yystate.yyresolved) |
cf126971 PE |
1859 | fprintf (stderr, ", firstVal: %ld", |
1860 | (long) YYINDEX (yyp->yystate.yysemantics.yyfirstVal)); | |
01241d47 | 1861 | } |
fb8135fa | 1862 | else |
01241d47 | 1863 | { |
cf126971 PE |
1864 | fprintf (stderr, "Option. rule: %d, state: %ld, next: %ld", |
1865 | yyp->yyoption.yyrule, | |
1866 | (long) YYINDEX (yyp->yyoption.yystate), | |
1867 | (long) YYINDEX (yyp->yyoption.yynext)); | |
01241d47 PH |
1868 | } |
1869 | fprintf (stderr, "\n"); | |
1870 | } | |
1871 | fprintf (stderr, "Tops:"); | |
1872 | for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1) | |
cf126971 PE |
1873 | fprintf (stderr, "%lu: %ld; ", (unsigned long) yyi, |
1874 | (long) YYINDEX (yystack->yytops.yystates[yyi])); | |
01241d47 PH |
1875 | fprintf (stderr, "\n"); |
1876 | } | |
01241d47 PH |
1877 | ] |
1878 | ||
1879 | b4_epilogue | |
1880 | m4_if(b4_defines_flag, 0, [], | |
1881 | [#output "b4_output_header_name" | |
fb8135fa | 1882 | b4_copyright([Skeleton parser for GLR parsing with Bison], [2002]) |
01241d47 PH |
1883 | #ifndef b4_header_guard |
1884 | # define b4_header_guard | |
1885 | ||
1886 | b4_token_defines(b4_tokens) | |
1887 | ||
1888 | #ifndef YYSTYPE | |
1889 | m4_ifdef([b4_stype], | |
1890 | [#line b4_stype_line "b4_filename" | |
1891 | typedef union b4_stype yystype; | |
1892 | /* Line __line__ of __file__. */ | |
1893 | #line __oline__ "__ofile__"], | |
1894 | [typedef int yystype;]) | |
1895 | # define YYSTYPE yystype | |
1896 | #endif | |
1897 | ||
1898 | b4_pure_if([], | |
1899 | [extern YYSTYPE b4_prefix[]lval;]) | |
1900 | ||
1901 | b4_location_if( | |
1902 | [#ifndef YYLTYPE | |
1903 | typedef struct yyltype | |
1904 | { | |
f50adbbd AD |
1905 | int first_line; |
1906 | int first_column; | |
1907 | int last_line; | |
1908 | int last_column; | |
01241d47 PH |
1909 | } yyltype; |
1910 | # define YYLTYPE yyltype | |
1911 | #endif | |
1912 | ||
1913 | m4_if(b4_pure, [0], | |
1914 | [extern YYLTYPE b4_prefix[]lloc;]) | |
1915 | ]) | |
1916 | #endif /* not b4_header_guard */ | |
1917 | ]) |