]> git.saurik.com Git - bison.git/blob - data/glr.c
(EXTRA_DIST): Add mbswidth.m4.
[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 void
1288 yyreportTree (yySemanticOption* yyx, int yyindent)
1289 {
1290 int yynrhs = yyrhsLength (yyx->yyrule);
1291 int yyi;
1292 yyGLRState* yys;
1293 yyGLRState* yystates[YYMAXRHS];
1294 yyGLRState yyleftmost_state;
1295
1296 for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred)
1297 yystates[yyi] = yys;
1298 if (yys == NULL)
1299 {
1300 yyleftmost_state.yyposn = 0;
1301 yystates[0] = &yyleftmost_state;
1302 }
1303 else
1304 yystates[0] = yys;
1305
1306 if (yyx->yystate->yyposn < yys->yyposn + 1)
1307 YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n",
1308 yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
1309 yyx->yyrule);
1310 else
1311 YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %d .. %d>\n",
1312 yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
1313 yyx->yyrule, yys->yyposn+1, yyx->yystate->yyposn);
1314 for (yyi = 1; yyi <= yynrhs; yyi += 1)
1315 {
1316 if (yystates[yyi]->yyresolved)
1317 {
1318 if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
1319 YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
1320 yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]));
1321 else
1322 YYFPRINTF (stderr, "%*s%s <tokens %d .. %d>\n", yyindent+2, "",
1323 yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]),
1324 yystates[yyi-1]->yyposn+1, yystates[yyi]->yyposn);
1325 }
1326 else
1327 yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
1328 }
1329 }
1330 #endif
1331
1332 static void
1333 yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,
1334 yyGLRStack* yystack)
1335 {
1336 /* `Unused' warnings. */
1337 (void) yyx0;
1338 (void) yyx1;
1339
1340 #if YYDEBUG
1341 YYFPRINTF (stderr, "Ambiguity detected.\n");
1342 YYFPRINTF (stderr, "Option 1,\n");
1343 yyreportTree (yyx0, 2);
1344 YYFPRINTF (stderr, "\nOption 2,\n");
1345 yyreportTree (yyx1, 2);
1346 YYFPRINTF (stderr, "\n");
1347 #endif
1348 yyFail (yystack, "ambiguity detected");
1349 }
1350
1351
1352 /** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
1353 * actions, and return the result. */
1354 static YYRESULTTAG
1355 yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack,
1356 YYSTYPE* yyvalp, YYLTYPE* yylocp YY_USER_FORMALS)
1357 {
1358 yySemanticOption* yybest;
1359 yySemanticOption* yyp;
1360 int yymerge;
1361
1362 yybest = yyoptionList;
1363 yymerge = 0;
1364 for (yyp = yyoptionList->yynext; yyp != NULL; yyp = yyp->yynext)
1365 {
1366 if (yyidenticalOptions (yybest, yyp))
1367 yymergeOptionSets (yybest, yyp);
1368 else
1369 switch (yypreference (yybest, yyp))
1370 {
1371 case 0:
1372 yyreportAmbiguity (yybest, yyp, yystack);
1373 break;
1374 case 1:
1375 yymerge = 1;
1376 break;
1377 case 2:
1378 break;
1379 case 3:
1380 yybest = yyp;
1381 yymerge = 0;
1382 break;
1383 }
1384 }
1385
1386 if (yymerge)
1387 {
1388 int yyprec = yydprec[yybest->yyrule];
1389 YYCHK (yyresolveAction (yybest, yystack, yyvalp, yylocp YY_USER_ARGS));
1390 for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext)
1391 {
1392 if (yyprec == yydprec[yyp->yyrule])
1393 {
1394 YYSTYPE yyval1;
1395 YYLTYPE yydummy;
1396 YYCHK (yyresolveAction (yyp, yystack, &yyval1, &yydummy YY_USER_ARGS));
1397 *yyvalp = yyuserMerge (yymerger[yyp->yyrule], yyvalp, &yyval1);
1398 }
1399 }
1400 return yyok;
1401 }
1402 else
1403 return yyresolveAction (yybest, yystack, yyvalp, yylocp YY_USER_ARGS);
1404 }
1405
1406 static YYRESULTTAG
1407 yyresolveStack (yyGLRStack* yystack YY_USER_FORMALS)
1408 {
1409 if (yystack->yysplitPoint != NULL)
1410 {
1411 yyGLRState* yys;
1412 int yyn;
1413
1414 for (yyn = 0, yys = yystack->yytops.yystates[0];
1415 yys != yystack->yysplitPoint;
1416 yys = yys->yypred, yyn += 1)
1417 ;
1418 YYCHK (yyresolveStates (yystack->yytops.yystates[0], yyn, yystack
1419 YY_USER_ARGS));
1420 }
1421 return yyok;
1422 }
1423
1424 static void
1425 yycompressStack (yyGLRStack* yystack)
1426 {
1427 yyGLRState* yyp, *yyq, *yyr;
1428
1429 if (yystack->yytops.yysize != 1 || yystack->yysplitPoint == NULL)
1430 return;
1431
1432 for (yyp = yystack->yytops.yystates[0], yyq = yyp->yypred, yyr = NULL;
1433 yyp != yystack->yysplitPoint;
1434 yyr = yyp, yyp = yyq, yyq = yyp->yypred)
1435 yyp->yypred = yyr;
1436
1437 yystack->yyspaceLeft += yystack->yynextFree - yystack->yyitems;
1438 yystack->yynextFree = ((yyGLRStackItem*) yystack->yysplitPoint) + 1;
1439 yystack->yyspaceLeft -= yystack->yynextFree - yystack->yyitems;
1440 yystack->yysplitPoint = NULL;
1441 yystack->yylastDeleted = NULL;
1442
1443 while (yyr != NULL)
1444 {
1445 yystack->yynextFree->yystate = *yyr;
1446 yyr = yyr->yypred;
1447 yystack->yynextFree->yystate.yypred = & yystack->yynextFree[-1].yystate;
1448 yystack->yytops.yystates[0] = &yystack->yynextFree->yystate;
1449 yystack->yynextFree += 1;
1450 yystack->yyspaceLeft -= 1;
1451 }
1452 }
1453
1454 static YYRESULTTAG
1455 yyprocessOneStack (yyGLRStack* yystack, int yyk,
1456 size_t yyposn, YYSTYPE* yylvalp, YYLTYPE* yyllocp
1457 YY_USER_FORMALS)
1458 {
1459 int yyaction;
1460 const short* yyconflicts;
1461 yyRuleNum yyrule;
1462 yySymbol* const yytokenp = yystack->yytokenp;
1463
1464 while (yystack->yytops.yystates[yyk] != NULL)
1465 {
1466 yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState;
1467
1468 assert (yystate != YYFINAL);
1469 if (yyisDefaultedState (yystate))
1470 {
1471 yyrule = yydefaultAction (yystate);
1472 if (yyrule == 0)
1473 {
1474 YYDPRINTF ((stderr, "Stack %d dies.\n", yyk));
1475 yymarkStackDeleted (yystack, yyk);
1476 return yyok;
1477 }
1478 YYCHK (yyglrReduce (yystack, yyk, yyrule, yyfalse YY_USER_ARGS));
1479 }
1480 else
1481 {
1482 if (*yytokenp == YYEMPTY)
1483 {
1484 YYDPRINTF ((stderr, "Reading a token: "));
1485 yychar = YYLEX;
1486 *yytokenp = YYTRANSLATE(yychar);
1487 YYDPRINTF ((stderr, "Next token is %s\n",
1488 yytokenName (*yytokenp)));
1489 }
1490 yygetLRActions (yystate, *yytokenp, &yyaction, &yyconflicts);
1491
1492 while (*yyconflicts != 0)
1493 {
1494 int yynewStack = yysplitStack (yystack, yyk);
1495 YYDPRINTF ((stderr, "Splitting off stack %d from %d.\n",
1496 yynewStack, yyk));
1497 YYCHK (yyglrReduce (yystack, yynewStack,
1498 *yyconflicts, yyfalse YY_USER_ARGS));
1499 YYCHK (yyprocessOneStack (yystack, yynewStack, yyposn,
1500 yylvalp, yyllocp YY_USER_ARGS));
1501 yyconflicts += 1;
1502 }
1503
1504 if (yyisShiftAction (yyaction))
1505 {
1506 YYDPRINTF ((stderr, "Shifting token %s on stack %d, ",
1507 yytokenName (*yytokenp), yyk));
1508 yyglrShift (yystack, yyk, yyaction, yyposn+1, *yylvalp, yyllocp);
1509 YYDPRINTF ((stderr, "which is now in state #%d\n",
1510 yystack->yytops.yystates[yyk]->yylrState));
1511 break;
1512 }
1513 else if (yyisErrorAction (yyaction))
1514 {
1515 YYDPRINTF ((stderr, "Stack %d dies.\n", yyk));
1516 yymarkStackDeleted (yystack, yyk);
1517 break;
1518 }
1519 else
1520 YYCHK (yyglrReduce (yystack, yyk, -yyaction, yyfalse YY_USER_ARGS));
1521 }
1522 }
1523 return yyok;
1524 }
1525
1526 static void
1527 yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
1528 {
1529 /* `Unused' warnings. */
1530 (void) yylvalp;
1531 (void) yyllocp;
1532
1533 if (yystack->yyerrState == 0)
1534 {
1535 #if YYERROR_VERBOSE
1536 yySymbol* const yytokenp = yystack->yytokenp;
1537 int yyn, yyx, yycount;
1538 size_t yysize;
1539 const char* yyprefix;
1540 char* yyp;
1541 char* yymsg;
1542 yyn = yypact[yystack->yytops.yystates[0]->yylrState];
1543 if (YYPACT_NINF < yyn && yyn < YYLAST)
1544 {
1545 yycount = 0;
1546 /* Start YYX at -YYN if negative to avoid negative indexes in
1547 YYCHECK. */
1548 yysize = sizeof ("parse error, unexpected ")
1549 + strlen (yytokenName (*yytokenp));
1550 yyprefix = ", expecting ";
1551 for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size && yycount <= 5;
1552 yyx += 1)
1553 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1554 yysize += strlen (yytokenName (yyx)) + strlen (yyprefix),
1555 yycount += 1, yyprefix = " or ";
1556 yymsg = yyp = (char*) malloc (yysize);
1557 sprintf (yyp, "parse error, unexpected %s",
1558 yytokenName (*yytokenp));
1559 yyp += strlen (yyp);
1560 if (yycount < 5)
1561 {
1562 yyprefix = ", expecting ";
1563 for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size; yyx += 1)
1564 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1565 {
1566 sprintf (yyp, "%s%s", yyprefix, yytokenName (yyx));
1567 yyp += strlen (yyp);
1568 yyprefix = " or ";
1569 }
1570 }
1571 yyerror (yymsg);
1572 free (yymsg);
1573 }
1574 else
1575 #endif
1576 yyerror ("parse error");
1577 yynerrs += 1;
1578 }
1579 }
1580
1581 /* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
1582 YYLVALP, and YYLLOCP point to the syntactic category, semantic
1583 value, and location of the lookahead. */
1584 static void
1585 yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
1586 {
1587 yySymbol* const yytokenp = yystack->yytokenp;
1588 size_t yyk;
1589 int yyj;
1590
1591 if (yystack->yyerrState == 0)
1592 yystack->yyerrState = 3;
1593 else if (yystack->yyerrState == 3)
1594 /* We just shifted the error token and (perhaps) took some
1595 reductions. Skip tokens until we can proceed. */
1596 while (yytrue)
1597 {
1598 if (*yytokenp == YYEOF)
1599 yyFail (yystack, NULL);
1600 if (*yytokenp != YYEMPTY)
1601 YYDPRINTF ((stderr, "Discarding token %s\n",
1602 yytokenName (*yytokenp)));
1603 YYDPRINTF ((stderr, "Reading a token: "));
1604 yychar = YYLEX;
1605 *yytokenp = YYTRANSLATE (yychar);
1606 YYDPRINTF ((stderr, "Next token is %s\n", yytokenName (*yytokenp)));
1607 yyj = yypact[yystack->yytops.yystates[0]->yylrState];
1608 if (yyj == YYPACT_NINF)
1609 /* Something's not right; we shouldn't be here. */
1610 yyFail (yystack, NULL);
1611 yyj += *yytokenp;
1612 if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != *yytokenp)
1613 {
1614 if (yydefact[yystack->yytops.yystates[0]->yylrState] != 0)
1615 return;
1616 }
1617 else if (yytable[yyj] != 0 && yytable[yyj] != YYTABLE_NINF)
1618 return;
1619 }
1620
1621 /* Reduce to one stack. */
1622 for (yyk = 0; yyk < yystack->yytops.yysize; yyk += 1)
1623 if (yystack->yytops.yystates[yyk] != NULL)
1624 break;
1625 if (yyk >= yystack->yytops.yysize)
1626 yyFail (yystack, NULL);
1627 for (yyk += 1; yyk < yystack->yytops.yysize; yyk += 1)
1628 yymarkStackDeleted (yystack, yyk);
1629 yyremoveDeletes (yystack);
1630 yycompressStack (yystack);
1631
1632 /* Now pop stack until we find a state that shifts the error token. */
1633 while (yystack->yytops.yystates[0] != NULL)
1634 {
1635 yyj = yypact[yystack->yytops.yystates[0]->yylrState] + YYTERROR;
1636 if (yyj != YYPACT_NINF + YYTERROR && yyj >= 0 && yyj <= YYLAST &&
1637 yycheck[yyj] == YYTERROR && yyisShiftAction (yytable[yyj]))
1638 {
1639 yyglrShift (yystack, 0, yytable[yyj],
1640 yystack->yytops.yystates[0]->yyposn, *yylvalp, yyllocp);
1641 break;
1642 }
1643 yystack->yytops.yystates[0] = yystack->yytops.yystates[0]->yypred;
1644 yystack->yynextFree -= 1;
1645 yystack->yyspaceLeft += 1;
1646 }
1647 if (yystack->yytops.yystates[0] == NULL)
1648 yyFail (yystack, NULL);
1649 }
1650
1651 #define YYCHK1(YYE) \
1652 do { \
1653 switch (YYE) { \
1654 default: \
1655 break; \
1656 case yyabort: \
1657 yystack.yyerrflag = 1; \
1658 goto yyDone; \
1659 case yyaccept: \
1660 yystack.yyerrflag = 0; \
1661 goto yyDone; \
1662 case yyerr: \
1663 goto yyuser_error; \
1664 } \
1665 } while (0)
1666
1667
1668 /*----------.
1669 | yyparse. |
1670 `----------*/
1671
1672 ]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[
1673 {
1674 yySymbol yytoken;
1675 yyGLRStack yystack;
1676 size_t yyposn;
1677 ]b4_pure_if(
1678 [
1679 YYSTYPE yylval;
1680 YYLTYPE yylloc;
1681 #undef yychar
1682 #define yychar (yystack.yyrawchar)
1683 ])[
1684
1685 YYSTYPE* const yylvalp = &yylval;
1686 YYLTYPE* const yyllocp = &yylloc;
1687
1688 yyinitGLRStack (&yystack, YYINITDEPTH);
1689 yystack.yytokenp = &yytoken;
1690
1691 YYDPRINTF ((stderr, "Starting parse\n"));
1692
1693 if (setjmp (yystack.yyexception_buffer) != 0)
1694 goto yyDone;
1695
1696 yyglrShift (&yystack, 0, 0, 0, yyval_default, &yyloc_default);
1697 yytoken = YYEMPTY;
1698 yyposn = 0;
1699
1700 while (yytrue)
1701 {
1702 /* For efficiency, we have two loops, the first of which is
1703 specialized to deterministic operation (single stack, no
1704 potential ambiguity). */
1705
1706 /* Standard mode */
1707 while (yytrue)
1708 {
1709 yyRuleNum yyrule;
1710 int yyaction;
1711 const short* yyconflicts;
1712
1713 yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
1714 if (yystate == YYFINAL)
1715 goto yyDone;
1716 if (yyisDefaultedState (yystate))
1717 {
1718 yyrule = yydefaultAction (yystate);
1719 if (yyrule == 0)
1720 {
1721 yyreportParseError (&yystack, yylvalp, yyllocp);
1722 goto yyuser_error;
1723 }
1724 YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue YY_USER_ARGS));
1725 }
1726 else
1727 {
1728 if (yytoken == YYEMPTY)
1729 {
1730 YYDPRINTF ((stderr, "Reading a token: "));
1731 yychar = YYLEX;
1732 yytoken = YYTRANSLATE (yychar);
1733 YYDPRINTF ((stderr, "Next token is %s\n",
1734 yytokenName (yytoken)));
1735 }
1736 yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
1737 if (*yyconflicts != 0)
1738 break;
1739 if (yyisShiftAction (yyaction))
1740 {
1741 YYDPRINTF ((stderr, "Shifting token %s, ",
1742 yytokenName (yytoken)));
1743 if (yytoken != YYEOF)
1744 yytoken = YYEMPTY;
1745 yyposn += 1;
1746 yyglrShift (&yystack, 0, yyaction, yyposn, yylval, yyllocp);
1747 if (0 < yystack.yyerrState)
1748 yystack.yyerrState -= 1;
1749 YYDPRINTF ((stderr, "Entering state %d\n",
1750 yystack.yytops.yystates[0]->yylrState));
1751 }
1752 else if (yyisErrorAction (yyaction))
1753 {
1754 yyreportParseError (&yystack, yylvalp, yyllocp);
1755 goto yyuser_error;
1756 }
1757 else
1758 YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue YY_USER_ARGS));
1759 }
1760 }
1761
1762 while (yytrue)
1763 {
1764 int yys;
1765 int yyn = yystack.yytops.yysize;
1766 for (yys = 0; yys < yyn; yys += 1)
1767 YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn,
1768 yylvalp, yyllocp YY_USER_ARGS));
1769 yytoken = YYEMPTY;
1770 yyposn += 1;
1771 yyremoveDeletes (&yystack);
1772 if (yystack.yytops.yysize == 0)
1773 {
1774 yyundeleteLastStack (&yystack);
1775 if (yystack.yytops.yysize == 0)
1776 yyFail (&yystack, "parse error");
1777 YYCHK1 (yyresolveStack (&yystack YY_USER_ARGS));
1778 YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
1779 yyreportParseError (&yystack, yylvalp, yyllocp);
1780 goto yyuser_error;
1781 }
1782 else if (yystack.yytops.yysize == 1)
1783 {
1784 YYCHK1 (yyresolveStack (&yystack YY_USER_ARGS));
1785 YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
1786 yycompressStack (&yystack);
1787 break;
1788 }
1789 }
1790 continue;
1791 yyuser_error:
1792 yyrecoverParseError (&yystack, yylvalp, yyllocp);
1793 yyposn = yystack.yytops.yystates[0]->yyposn;
1794 }
1795 yyDone:
1796 ;
1797
1798 yyfreeGLRStack (&yystack);
1799 return yystack.yyerrflag;
1800 }
1801
1802 /* DEBUGGING ONLY */
1803 static void yypstack (yyGLRStack* yystack, int yyk) ATTRIBUTE_UNUSED;
1804 static void yypdumpstack (yyGLRStack* yystack) ATTRIBUTE_UNUSED;
1805
1806 static void
1807 yy_yypstack (yyGLRState* yys)
1808 {
1809 if (yys->yypred)
1810 {
1811 yy_yypstack (yys->yypred);
1812 fprintf (stderr, " -> ");
1813 }
1814 fprintf (stderr, "%d@%lu", yys->yylrState, (unsigned long) yys->yyposn);
1815 }
1816
1817 static void
1818 yypstates (yyGLRState* yyst)
1819 {
1820 if (yyst == NULL)
1821 fprintf (stderr, "<null>");
1822 else
1823 yy_yypstack (yyst);
1824 fprintf (stderr, "\n");
1825 }
1826
1827 static void
1828 yypstack (yyGLRStack* yystack, int yyk)
1829 {
1830 yypstates (yystack->yytops.yystates[yyk]);
1831 }
1832
1833 #define YYINDEX(YYX) \
1834 ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
1835
1836
1837 static void
1838 yypdumpstack (yyGLRStack* yystack)
1839 {
1840 yyGLRStackItem* yyp;
1841 size_t yyi;
1842 for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1)
1843 {
1844 fprintf (stderr, "%3lu. ", (unsigned long) (yyp - yystack->yyitems));
1845 if (*(bool*) yyp)
1846 {
1847 fprintf (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
1848 yyp->yystate.yyresolved, yyp->yystate.yylrState,
1849 (unsigned long) yyp->yystate.yyposn,
1850 (long) YYINDEX (yyp->yystate.yypred));
1851 if (! yyp->yystate.yyresolved)
1852 fprintf (stderr, ", firstVal: %ld",
1853 (long) YYINDEX (yyp->yystate.yysemantics.yyfirstVal));
1854 }
1855 else
1856 {
1857 fprintf (stderr, "Option. rule: %d, state: %ld, next: %ld",
1858 yyp->yyoption.yyrule,
1859 (long) YYINDEX (yyp->yyoption.yystate),
1860 (long) YYINDEX (yyp->yyoption.yynext));
1861 }
1862 fprintf (stderr, "\n");
1863 }
1864 fprintf (stderr, "Tops:");
1865 for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1)
1866 fprintf (stderr, "%lu: %ld; ", (unsigned long) yyi,
1867 (long) YYINDEX (yystack->yytops.yystates[yyi]));
1868 fprintf (stderr, "\n");
1869 }
1870 ]
1871
1872 b4_epilogue
1873 m4_if(b4_defines_flag, 0, [],
1874 [#output "b4_output_header_name"
1875 b4_copyright([Skeleton parser for GLR parsing with Bison], [2002])
1876 #ifndef b4_header_guard
1877 # define b4_header_guard
1878
1879 b4_token_defines(b4_tokens)
1880
1881 #ifndef YYSTYPE
1882 m4_ifdef([b4_stype],
1883 [#line b4_stype_line "b4_filename"
1884 typedef union b4_stype yystype;
1885 /* Line __line__ of __file__. */
1886 #line __oline__ "__ofile__"],
1887 [typedef int yystype;])
1888 # define YYSTYPE yystype
1889 #endif
1890
1891 b4_pure_if([],
1892 [extern YYSTYPE b4_prefix[]lval;])
1893
1894 b4_location_if(
1895 [#ifndef YYLTYPE
1896 typedef struct yyltype
1897 {
1898 int first_line;
1899 int first_column;
1900 int last_line;
1901 int last_column;
1902 } yyltype;
1903 # define YYLTYPE yyltype
1904 #endif
1905
1906 m4_if(b4_pure, [0],
1907 [extern YYLTYPE b4_prefix[]lloc;])
1908 ])
1909 #endif /* not b4_header_guard */
1910 ])