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