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