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