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