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