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