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