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