]>
git.saurik.com Git - bison.git/blob - src/output.c
f4b3c3fd7f8fd8600d01c4c0f428f6f27388fe5f
1 /* Output the generated parsing program for bison,
2 Copyright 1984, 1986, 1989, 1992, 2000 Free Software Foundation, Inc.
4 This file is part of Bison, the GNU Compiler Compiler.
6 Bison is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 Bison is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Bison; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 /* The parser tables consist of these tables.
23 Starred ones needed only for the semantic parser.
24 Double starred are output only if switches are set.
26 yytranslate = vector mapping yylex's token numbers into bison's token
29 ** yytname = vector of string-names indexed by bison token number
31 ** yytoknum = vector of yylex token numbers corresponding to entries
34 yyrline = vector of line-numbers of all rules. For yydebug printouts.
36 yyrhs = vector of items of all rules.
37 This is exactly what ritems contains. For yydebug and for semantic
40 yyprhs[r] = index in yyrhs of first item for rule r.
42 yyr1[r] = symbol number of symbol that rule r derives.
44 yyr2[r] = number of symbols composing right hand side of rule r.
46 * yystos[s] = the symbol number of the symbol that leads to state s.
48 yydefact[s] = default rule to reduce with in state s,
49 when yytable doesn't specify something else to do.
50 Zero means the default is an error.
52 yydefgoto[i] = default state to go to after a reduction of a rule that
53 generates variable ntokens + i, except when yytable
54 specifies something else to do.
56 yypact[s] = index in yytable of the portion describing state s.
57 The lookahead token's type is used to index that portion
58 to find out what to do.
60 If the value in yytable is positive,
61 we shift the token and go to that state.
63 If the value is negative, it is minus a rule number to reduce by.
65 If the value is zero, the default action from yydefact[s] is used.
67 yypgoto[i] = the index in yytable of the portion describing
68 what to do after reducing a rule that derives variable i + ntokens.
69 This portion is indexed by the parser state number, s,
70 as of before the text for this nonterminal was read.
71 The value from yytable is the state to go to if
72 the corresponding value in yycheck is s.
74 yytable = a vector filled with portions for different uses,
75 found via yypact and yypgoto.
77 yycheck = a vector indexed in parallel with yytable.
78 It indicates, in a roundabout way, the bounds of the
79 portion you are trying to examine.
81 Suppose that the portion of yytable starts at index p
82 and the index to be examined within the portion is i.
83 Then if yycheck[p+i] != i, i is outside the bounds
84 of what is actually allocated, and the default
85 (from yydefact or yydefgoto) should be used.
86 Otherwise, yytable[p+i] should be used.
88 YYFINAL = the state number of the termination state.
89 YYFLAG = most negative short int. Used to flag ??
101 #include "complain.h"
105 #include "conflicts.h"
107 extern void berror
PARAMS((const char *));
113 static short **froms
;
117 static short *actrow
;
118 static short *state_count
;
130 output_short_or_char_table (struct obstack
*oout
,
133 const char *table_name
,
136 short begin
, short end
)
141 obstack_fgrow1 (oout
, "/* %s. */\n", comment
);
143 obstack_fgrow3 (oout
, "static const %s %s[] =\n{\n %6d",
144 type
, table_name
, first_value
);
147 for (i
= begin
; i
< end
; i
++)
149 obstack_1grow (oout
, ',');
153 obstack_sgrow (oout
, "\n ");
161 obstack_fgrow1 (oout
, "%6d", short_table
[i
]);
164 obstack_sgrow (oout
, "\n};\n");
169 output_short_table (struct obstack
*oout
,
171 const char *table_name
,
174 short begin
, short end
)
176 output_short_or_char_table (oout
, comment
, "short", table_name
, short_table
,
177 first_value
, begin
, end
);
181 /*--------------------------------------------------------------.
182 | output_headers -- Output constant strings to the beginning of |
184 `--------------------------------------------------------------*/
186 /* Don't put the `%s' insides quotes, since it quotearg puts them. */
191 extern int yyerror;\n\
192 extern int yycost;\n\
193 extern char * yymsg;\n\
194 extern YYSTYPE yyval;\n\
196 yyguard(n, yyvsp, yylsp)\n\
198 register YYSTYPE *yyvsp;\n\
199 register YYLTYPE *yylsp;\n\
210 extern YYSTYPE yyval;\n\
211 extern int yychar;\n\
213 yyaction(n, yyvsp, yylsp)\n\
215 register YYSTYPE *yyvsp;\n\
216 register YYLTYPE *yylsp;\n\
221 #define ACTSTR_SIMPLE "\n switch (yyn) {\n"
224 output_headers (void)
226 char *attrsfile_quoted
= quotearg_style (c_quoting_style
, attrsfile
);
229 obstack_fgrow1 (&guard_obstack
, GUARDSTR
, attrsfile_quoted
);
235 obstack_fgrow1 (&action_obstack
, ACTSTR
, attrsfile_quoted
);
237 obstack_sgrow (&action_obstack
, ACTSTR_SIMPLE
);
239 /* Rename certain symbols if -p was specified. */
240 if (spec_name_prefix
)
242 obstack_fgrow1 (&table_obstack
,
243 "#define yyparse %sparse\n", spec_name_prefix
);
244 obstack_fgrow1 (&table_obstack
,
245 "#define yylex %slex\n", spec_name_prefix
);
246 obstack_fgrow1 (&table_obstack
,
247 "#define yyerror %serror\n", spec_name_prefix
);
248 obstack_fgrow1 (&table_obstack
,
249 "#define yylval %slval\n", spec_name_prefix
);
250 obstack_fgrow1 (&table_obstack
,
251 "#define yychar %schar\n", spec_name_prefix
);
252 obstack_fgrow1 (&table_obstack
,
253 "#define yydebug %sdebug\n", spec_name_prefix
);
254 obstack_fgrow1 (&table_obstack
,
255 "#define yynerrs %snerrs\n", spec_name_prefix
);
260 /*-------------------------------------------------------.
261 | Output constant strings to the ends of certain files. |
262 `-------------------------------------------------------*/
265 output_trailers (void)
268 obstack_sgrow (&guard_obstack
, "\n }\n}\n");
270 obstack_1grow (&action_obstack
, '\n');
276 obstack_sgrow (&action_obstack
, " }\n");
278 obstack_sgrow (&action_obstack
, "}\n");
284 output_token_translations (void)
286 obstack_sgrow (&table_obstack
, "\
288 /* YYRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */\n");
292 obstack_fgrow2 (&table_obstack
,
293 "#define YYTRANSLATE(x) ((unsigned)(x) <= %d ? yytranslate[x] : %d)\
296 max_user_token_number
, nsyms
);
298 output_short_or_char_table (&table_obstack
,
299 "YYRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX",
300 ntokens
< 127 ? "char" : "short",
301 "yytranslate", token_translations
,
302 0, 1, max_user_token_number
+ 1);
306 obstack_sgrow (&table_obstack
,
307 "\n#define YYTRANSLATE(x) (x)\n");
315 /* With the ordinary parser,
316 yyprhs and yyrhs are needed only for yydebug. */
317 /* With the no_parser option, all tables are generated */
318 if (!semantic_parser
&& !no_parser_flag
)
319 obstack_sgrow (&table_obstack
, "\n#if YYDEBUG != 0\n");
321 output_short_table (&table_obstack
, NULL
, "yyprhs", rrhs
,
325 size_t yyrhs_size
= 1;
329 for (sp
= ritem
+ 1; *sp
; sp
++)
331 yyrhs
= XMALLOC (short, yyrhs_size
);
333 for (sp
= ritem
+ 1, i
= 1; *sp
; ++sp
, ++i
)
334 yyrhs
[i
] = *sp
> 0 ? *sp
: 0;
336 output_short_table (&table_obstack
, NULL
, "yyrhs", yyrhs
,
337 ritem
[0], 1, yyrhs_size
);
341 if (!semantic_parser
&& !no_parser_flag
)
342 obstack_sgrow (&table_obstack
, "\n#endif\n");
349 output_short_table (&table_obstack
, NULL
, "yystos", accessing_symbol
,
355 output_rule_data (void)
359 short *short_tab
= NULL
;
361 obstack_sgrow (&table_obstack
, "\n\
362 #if YYDEBUG != 0\n");
364 output_short_table (&table_obstack
,
365 "YYRLINE[YYN] -- source line where rule number YYN was defined",
369 obstack_sgrow (&table_obstack
, "#endif\n\n");
371 if (token_table_flag
|| no_parser_flag
)
373 obstack_fgrow1 (&table_obstack
, "#define YYNTOKENS %d\n", ntokens
);
374 obstack_fgrow1 (&table_obstack
, "#define YYNNTS %d\n", nvars
);
375 obstack_fgrow1 (&table_obstack
, "#define YYNRULES %d\n", nrules
);
376 obstack_fgrow1 (&table_obstack
, "#define YYNSTATES %d\n", nstates
);
377 obstack_fgrow1 (&table_obstack
, "#define YYMAXUTOK %d\n\n",
378 max_user_token_number
);
381 /* Output the table of symbol names. */
382 if (!token_table_flag
&& !no_parser_flag
)
383 obstack_sgrow (&table_obstack
,
384 "\n#if YYDEBUG != 0 || defined YYERROR_VERBOSE\n\n");
385 obstack_sgrow (&table_obstack
, "\
386 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */\n");
387 obstack_sgrow (&table_obstack
,
388 "static const char *const yytname[] =\n{\n ");
391 for (i
= 0; i
< nsyms
; i
++)
392 /* this used to be i<=nsyms, but that output a final "" symbol
393 almost by accident */
395 /* Width of the next token, including the two quotes, the coma
400 for (p
= tags
[i
]; p
&& *p
; p
++)
401 if (*p
== '"' || *p
== '\\' || *p
== '\n' || *p
== '\t'
404 else if (*p
< 040 || *p
>= 0177)
409 if (j
+ strsize
> 75)
411 obstack_sgrow (&table_obstack
, "\n ");
415 obstack_1grow (&table_obstack
, '\"');
416 for (p
= tags
[i
]; p
&& *p
; p
++)
418 if (*p
== '"' || *p
== '\\')
419 obstack_fgrow1 (&table_obstack
, "\\%c", *p
);
421 obstack_sgrow (&table_obstack
, "\\n");
423 obstack_sgrow (&table_obstack
, "\\t");
425 obstack_sgrow (&table_obstack
, "\\b");
426 else if (*p
< 040 || *p
>= 0177)
427 obstack_fgrow1 (&table_obstack
, "\\%03o", *p
);
429 obstack_1grow (&table_obstack
, *p
);
432 obstack_sgrow (&table_obstack
, "\", ");
435 /* add a NULL entry to list of tokens */
436 obstack_sgrow (&table_obstack
, "NULL\n};\n");
438 if (!token_table_flag
&& !no_parser_flag
)
439 obstack_sgrow (&table_obstack
, "#endif\n\n");
441 /* Output YYTOKNUM. */
442 if (token_table_flag
)
444 output_short_table (&table_obstack
,
445 "YYTOKNUM[YYLEX] -- Index in YYTNAME corresponding to YYLEX",
446 "yytoknum", user_toknums
,
451 output_short_table (&table_obstack
,
452 "YYR1[YYN] -- Symbol number of symbol that rule YYN derives",
457 obstack_1grow (&table_obstack
, '\n');
460 short_tab
= XMALLOC (short, nrules
+ 1);
461 for (i
= 1; i
< nrules
; i
++)
462 short_tab
[i
] = rrhs
[i
+ 1] - rrhs
[i
] - 1;
463 short_tab
[nrules
] = nitems
- rrhs
[nrules
] - 1;
464 output_short_table (&table_obstack
,
465 "YYR2[YYN] -- Number of symbols composing right hand side of rule YYN",
468 obstack_1grow (&table_obstack
, '\n');
477 output_defines (void)
479 obstack_fgrow1 (&table_obstack
, "\n\n#define\tYYFINAL\t\t%d\n", final_state
);
480 obstack_fgrow1 (&table_obstack
, "#define\tYYFLAG\t\t%d\n", MINSHORT
);
481 obstack_fgrow1 (&table_obstack
, "#define\tYYNTBASE\t%d\n", ntokens
);
485 /*------------------------------------------------------------------.
486 | Decide what to do for each type of token if seen as the lookahead |
487 | token in specified state. The value returned is used as the |
488 | default action (yydefact) for the state. In addition, actrow is |
489 | filled with what to do for each kind of token, index by symbol |
490 | number, with zero meaning do the default action. The value |
491 | MINSHORT, a very negative number, means this situation is an |
492 | error. The parser recognizes this value specially. |
494 | This is where conflicts are resolved. The loop over lookahead |
495 | rules considered lower-numbered rules last, and the last rule |
496 | considered that likes a token gets to handle it. |
497 `------------------------------------------------------------------*/
500 action_row (int state
)
519 int nodefault
= 0; /* set nonzero to inhibit having any default reduction */
521 for (i
= 0; i
< ntokens
; i
++)
526 redp
= reduction_table
[state
];
534 /* loop over all the rules available here which require
536 m
= lookaheads
[state
];
537 n
= lookaheads
[state
+ 1];
539 for (i
= n
- 1; i
>= m
; i
--)
542 wordp
= LA
+ i
* tokensetsize
;
545 /* and find each token which the rule finds acceptable
547 for (j
= 0; j
< ntokens
; j
++)
549 /* and record this rule as the rule to use if that
565 shiftp
= shift_table
[state
];
567 /* Now see which tokens are allowed for shifts in this state. For
568 them, record the shift as the thing to do. So shift is preferred
575 for (i
= 0; i
< k
; i
++)
577 shift_state
= shiftp
->shifts
[i
];
581 symbol
= accessing_symbol
[shift_state
];
586 actrow
[symbol
] = shift_state
;
588 /* Do not use any default reduction if there is a shift for
590 if (symbol
== error_token_number
)
595 errp
= err_table
[state
];
597 /* See which tokens are an explicit error in this state (due to
598 %nonassoc). For them, record MINSHORT as the action. */
604 for (i
= 0; i
< k
; i
++)
606 symbol
= errp
->errs
[i
];
607 actrow
[symbol
] = MINSHORT
;
611 /* Now find the most common reduction and make it the default action
614 if (nreds
>= 1 && !nodefault
)
616 if (consistent
[state
])
617 default_rule
= redp
->rules
[0];
621 for (i
= m
; i
< n
; i
++)
626 for (j
= 0; j
< ntokens
; j
++)
628 if (actrow
[j
] == rule
)
639 /* actions which match the default are replaced with zero,
640 which means "use the default" */
644 for (j
= 0; j
< ntokens
; j
++)
646 if (actrow
[j
] == default_rule
)
650 default_rule
= -default_rule
;
655 /* If have no default rule, the default is an error.
656 So replace any action which says "error" with "use default". */
658 if (default_rule
== 0)
659 for (j
= 0; j
< ntokens
; j
++)
661 if (actrow
[j
] == MINSHORT
)
679 for (i
= 0; i
< ntokens
; i
++)
688 froms
[state
] = sp1
= sp
= XCALLOC (short, count
);
689 tos
[state
] = sp2
= XCALLOC (short, count
);
691 for (i
= 0; i
< ntokens
; i
++)
700 tally
[state
] = count
;
701 width
[state
] = sp1
[-1] - sp
[0] + 1;
705 /*------------------------------------------------------------------.
706 | Figure out the actions for the specified state, indexed by |
707 | lookahead token type. |
709 | The YYDEFACT table is output now. The detailed info is saved for |
710 | putting into YYTABLE later. |
711 `------------------------------------------------------------------*/
717 short *yydefact
= XCALLOC (short, nstates
);
719 actrow
= XCALLOC (short, ntokens
);
720 for (i
= 0; i
< nstates
; ++i
)
722 yydefact
[i
] = action_row (i
);
727 output_short_table (&table_obstack
,
728 "YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE\n\
729 doesn't specify something else to do. Zero means the default is an\n\
731 "yydefact", yydefact
,
732 yydefact
[0], 1, nstates
);
733 obstack_1grow (&table_obstack
, '\n');
741 shifts
*sp
, *sptmp
; /* JF derefrenced freed ptr */
745 for (sp
= first_shift
; sp
; sp
= sptmp
)
754 free_reductions (void)
756 reductions
*rp
, *rptmp
; /* JF fixed freed ptr */
758 XFREE (reduction_table
);
760 for (rp
= first_reduction
; rp
; rp
= rptmp
)
770 save_column (int symbol
, int default_state
)
779 short begin
= goto_map
[symbol
];
780 short end
= goto_map
[symbol
+ 1];
783 for (i
= begin
; i
< end
; i
++)
785 if (to_state
[i
] != default_state
)
792 symno
= symbol
- ntokens
+ nstates
;
794 froms
[symno
] = sp1
= sp
= XCALLOC (short, count
);
795 tos
[symno
] = sp2
= XCALLOC (short, count
);
797 for (i
= begin
; i
< end
; i
++)
799 if (to_state
[i
] != default_state
)
801 *sp1
++ = from_state
[i
];
802 *sp2
++ = to_state
[i
];
806 tally
[symno
] = count
;
807 width
[symno
] = sp1
[-1] - sp
[0] + 1;
811 default_goto (int symbol
)
819 m
= goto_map
[symbol
];
820 n
= goto_map
[symbol
+ 1];
825 for (i
= 0; i
< nstates
; i
++)
828 for (i
= m
; i
< n
; i
++)
829 state_count
[to_state
[i
]]++;
834 for (i
= 0; i
< nstates
; i
++)
836 if (state_count
[i
] > max
)
838 max
= state_count
[i
];
843 return default_state
;
847 /*-------------------------------------------------------------------.
848 | Figure out what to do after reducing with each rule, depending on |
849 | the saved state from before the beginning of parsing the data that |
850 | matched this rule. |
852 | The YYDEFGOTO table is output now. The detailed info is saved for |
853 | putting into YYTABLE later. |
854 `-------------------------------------------------------------------*/
861 short *yydefgoto
= XMALLOC (short, nsyms
- ntokens
);
862 state_count
= XCALLOC (short, nstates
);
864 for (i
= ntokens
; i
< nsyms
; ++i
)
866 int default_state
= default_goto (i
);
867 save_column (i
, default_state
);
868 yydefgoto
[i
- ntokens
] = default_state
;
871 output_short_table (&table_obstack
, NULL
, "yydefgoto", yydefgoto
,
872 yydefgoto
[0], 1, nsyms
- ntokens
);
879 /* The next few functions decide how to pack the actions and gotos
880 information into yytable. */
891 order
= XCALLOC (short, nvectors
);
894 for (i
= 0; i
< nvectors
; i
++)
902 while (j
>= 0 && (width
[order
[j
]] < w
))
905 while (j
>= 0 && (width
[order
[j
]] == w
) && (tally
[order
[j
]] < t
))
908 for (k
= nentries
- 1; k
> j
; k
--)
909 order
[k
+ 1] = order
[k
];
919 matching_state (int vector
)
936 for (prev
= vector
- 1; prev
>= 0; prev
--)
939 if (width
[j
] != w
|| tally
[j
] != t
)
943 for (k
= 0; match
&& k
< t
; k
++)
945 if (tos
[j
][k
] != tos
[i
][k
] || froms
[j
][k
] != froms
[i
][k
])
958 pack_vector (int vector
)
977 for (j
= lowzero
- from
[0]; j
< MAXTABLE
; j
++)
981 for (k
= 0; ok
&& k
< t
; k
++)
985 fatal (_("maximum table size (%d) exceeded"), MAXTABLE
);
991 for (k
= 0; ok
&& k
< vector
; k
++)
999 for (k
= 0; k
< t
; k
++)
1003 check
[loc
] = from
[k
];
1006 while (table
[lowzero
] != 0)
1016 berror ("pack_vector");
1017 return 0; /* JF keep lint happy */
1028 base
= XCALLOC (short, nvectors
);
1029 pos
= XCALLOC (short, nentries
);
1030 table
= XCALLOC (short, MAXTABLE
);
1031 check
= XCALLOC (short, MAXTABLE
);
1036 for (i
= 0; i
< nvectors
; i
++)
1039 for (i
= 0; i
< MAXTABLE
; i
++)
1042 for (i
= 0; i
< nentries
; i
++)
1044 state
= matching_state (i
);
1047 place
= pack_vector (i
);
1049 place
= base
[state
];
1052 base
[order
[i
]] = place
;
1055 for (i
= 0; i
< nvectors
; i
++)
1068 /* the following functions output yytable, yycheck
1069 and the vectors whose elements index the portion starts */
1074 output_short_table (&table_obstack
, NULL
, "yypact", base
,
1075 base
[0], 1, nstates
);
1077 obstack_1grow (&table_obstack
, '\n');
1079 output_short_table (&table_obstack
, NULL
, "yypgoto", base
,
1080 base
[nstates
], nstates
+ 1, nvectors
);
1089 obstack_fgrow1 (&table_obstack
, "\n\n#define\tYYLAST\t\t%d\n\n\n", high
);
1090 output_short_table (&table_obstack
, NULL
, "yytable", table
,
1091 table
[0], 1, high
+ 1);
1099 output_short_table (&table_obstack
, NULL
, "yycheck", check
,
1100 check
[0], 1, high
+ 1);
1104 /* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable
1108 output_actions (void)
1110 nvectors
= nstates
+ nvars
;
1112 froms
= XCALLOC (short *, nvectors
);
1113 tos
= XCALLOC (short *, nvectors
);
1114 tally
= XCALLOC (short, nvectors
);
1115 width
= XCALLOC (short, nvectors
);
1123 XFREE (accessing_symbol
);
1126 XFREE (goto_map
+ ntokens
);
1132 obstack_1grow (&table_obstack
, '\n');
1135 obstack_1grow (&table_obstack
, '\n');
1139 /*------------------------------------------.
1140 | Copy the parser code into TABLE_OBSTACK. |
1141 `------------------------------------------*/
1144 output_parser (void)
1149 const char *skeleton
= NULL
;
1150 int actions_dumped
= 0;
1153 obstack_sgrow (&table_obstack
, "#define YYPURE 1\n\n");
1155 /* Loop over lines in the standard parser file. */
1156 if (semantic_parser
)
1157 skeleton
= skeleton_find ("BISON_HAIRY", BISON_HAIRY
);
1159 skeleton
= skeleton_find ("BISON_SIMPLE", BISON_SIMPLE
);
1160 fskel
= xfopen (skeleton
, "r");
1162 /* Set LINE to 2, not 1: `#line LINENUM' -- Here LINENUM is a
1163 decimal integer constant. This specifies that the line number of
1164 the *following* line of input, in its original source file, was
1173 sync_line
, /* #line. */
1174 actions_line
/* %% actions. */
1176 enum line_type_e line_type
= regular_line
;
1180 /* Is this line special? */
1183 /* See if it's a `#line' line. */
1184 if ((c
= getc (fskel
)) == 'l')
1185 if ((c
= getc (fskel
)) == 'i')
1186 if ((c
= getc (fskel
)) == 'n')
1187 if ((c
= getc (fskel
)) == 'e')
1188 line_type
= sync_line
;
1190 obstack_sgrow (&table_obstack
, "#lin");
1192 obstack_sgrow (&table_obstack
, "#li");
1194 obstack_sgrow (&table_obstack
, "#l");
1196 obstack_sgrow (&table_obstack
, "#");
1200 /* See if it's a `%% actions' line. */
1201 if ((c
= getc (fskel
)) == '%')
1202 if ((c
= getc (fskel
)) == ' ')
1203 if ((c
= getc (fskel
)) == 'a')
1204 if ((c
= getc (fskel
)) == 'c')
1205 if ((c
= getc (fskel
)) == 't')
1206 if ((c
= getc (fskel
)) == 'i')
1207 if ((c
= getc (fskel
)) == 'o')
1208 if ((c
= getc (fskel
)) == 'n')
1209 if ((c
= getc (fskel
)) == 's')
1210 line_type
= actions_line
;
1212 obstack_sgrow (&table_obstack
, "%% action");
1214 obstack_sgrow (&table_obstack
, "%% actio");
1216 obstack_sgrow (&table_obstack
, "%% acti");
1218 obstack_sgrow (&table_obstack
, "%% act");
1220 obstack_sgrow (&table_obstack
, "%% ac");
1222 obstack_sgrow (&table_obstack
, "%% a");
1224 obstack_sgrow (&table_obstack
, "%% ");
1226 obstack_sgrow (&table_obstack
, "%%");
1228 obstack_sgrow (&table_obstack
, "%");
1235 obstack_fgrow2 (&table_obstack
, "#line %d %s\n",
1236 line
, quotearg_style (c_quoting_style
, skeleton
));
1238 /* Skip the end of line. */
1239 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1245 size_t size
= obstack_object_size (&action_obstack
);
1248 assert (actions_dumped
== 1);
1249 obstack_grow (&table_obstack
,
1250 obstack_finish (&action_obstack
),
1254 /* Skip the end of line. */
1255 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1260 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1261 obstack_1grow (&table_obstack
, c
);
1266 obstack_1grow (&table_obstack
, c
);
1269 assert (actions_dumped
== 1);
1274 output_program (void)
1279 obstack_fgrow2 (&table_obstack
, "#line %d %s\n",
1280 lineno
, quotearg_style (c_quoting_style
, infile
));
1282 while ((c
= getc (finput
)) != EOF
)
1283 obstack_1grow (&table_obstack
, c
);
1288 free_itemsets (void)
1292 XFREE (state_table
);
1294 for (cp
= first_state
; cp
; cp
= cptmp
)
1302 /*----------------------------------------------------------.
1303 | Output the parsing tables and the parser code to ftable. |
1304 `----------------------------------------------------------*/
1309 /* output_token_defines(ftable); / * JF put out token defines FIRST */
1311 /* If using a simple parser the definition of YYSTYPE are put into
1313 if (!semantic_parser
)
1315 size_t size
= obstack_object_size (&attrs_obstack
);
1316 obstack_grow (&table_obstack
, obstack_finish (&attrs_obstack
), size
);
1318 reader_output_yylsp (&table_obstack
);
1320 obstack_sgrow (&table_obstack
, "\
1322 # define YYDEBUG 1\n\
1326 if (semantic_parser
)
1327 obstack_fgrow1 (&table_obstack
, "#include %s\n",
1328 quotearg_style (c_quoting_style
, attrsfile
));
1330 if (!no_parser_flag
)
1331 obstack_sgrow (&table_obstack
, "#include <stdio.h>\n\n");
1333 /* Make "const" do nothing if not in ANSI C. */
1334 obstack_sgrow (&table_obstack
, "\
1335 #ifndef __cplusplus\n\
1336 # ifndef __STDC__\n\
1344 output_token_translations ();
1345 /* if (semantic_parser) */
1346 /* This is now unconditional because debugging printouts can use it. */
1349 if (semantic_parser
)
1351 output_rule_data ();
1353 if (!no_parser_flag
)