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