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