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