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