]>
git.saurik.com Git - bison.git/blob - src/output.c
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
= 0;
230 /* FIXME: This is *buggy*. ATTRSFILE is not computed yet, since
231 we are waiting for the full input file to have been read to
232 be sure of the output file name. So basically, here, a SEGV
233 is guaranteed. OTOH, currently semantic parsers are not
235 attrsfile_quoted
= quotearg_style (c_quoting_style
, attrsfile
);
236 obstack_fgrow1 (&guard_obstack
, GUARDSTR
, attrsfile_quoted
);
243 obstack_fgrow1 (&action_obstack
, ACTSTR
, attrsfile_quoted
);
245 obstack_sgrow (&action_obstack
, ACTSTR_SIMPLE
);
247 /* Rename certain symbols if -p was specified. */
248 if (spec_name_prefix
)
250 obstack_fgrow1 (&table_obstack
,
251 "#define yyparse %sparse\n", spec_name_prefix
);
252 obstack_fgrow1 (&table_obstack
,
253 "#define yylex %slex\n", spec_name_prefix
);
254 obstack_fgrow1 (&table_obstack
,
255 "#define yyerror %serror\n", spec_name_prefix
);
256 obstack_fgrow1 (&table_obstack
,
257 "#define yylval %slval\n", spec_name_prefix
);
258 obstack_fgrow1 (&table_obstack
,
259 "#define yychar %schar\n", spec_name_prefix
);
260 obstack_fgrow1 (&table_obstack
,
261 "#define yydebug %sdebug\n", spec_name_prefix
);
262 obstack_fgrow1 (&table_obstack
,
263 "#define yynerrs %snerrs\n", spec_name_prefix
);
268 /*-------------------------------------------------------.
269 | Output constant strings to the ends of certain files. |
270 `-------------------------------------------------------*/
273 output_trailers (void)
276 obstack_sgrow (&guard_obstack
, "\n }\n}\n");
278 obstack_1grow (&action_obstack
, '\n');
284 obstack_sgrow (&action_obstack
, " }\n");
286 obstack_sgrow (&action_obstack
, "}\n");
292 output_token_translations (void)
294 obstack_sgrow (&table_obstack
, "\
296 /* YYRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */\n");
300 obstack_fgrow2 (&table_obstack
,
301 "#define YYTRANSLATE(x) ((unsigned)(x) <= %d ? yytranslate[x] : %d)\
304 max_user_token_number
, nsyms
);
306 output_short_or_char_table (&table_obstack
,
307 "YYRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX",
308 ntokens
< 127 ? "char" : "short",
309 "yytranslate", token_translations
,
310 0, 1, max_user_token_number
+ 1);
314 obstack_sgrow (&table_obstack
,
315 "\n#define YYTRANSLATE(x) (x)\n");
323 /* With the ordinary parser,
324 yyprhs and yyrhs are needed only for yydebug. */
325 /* With the no_parser option, all tables are generated */
326 if (!semantic_parser
&& !no_parser_flag
)
327 obstack_sgrow (&table_obstack
, "\n#if YYDEBUG != 0\n");
329 output_short_table (&table_obstack
, NULL
, "yyprhs", rrhs
,
333 size_t yyrhs_size
= 1;
337 for (sp
= ritem
+ 1; *sp
; sp
++)
339 yyrhs
= XMALLOC (short, yyrhs_size
);
341 for (sp
= ritem
+ 1, i
= 1; *sp
; ++sp
, ++i
)
342 yyrhs
[i
] = *sp
> 0 ? *sp
: 0;
344 output_short_table (&table_obstack
, NULL
, "yyrhs", yyrhs
,
345 ritem
[0], 1, yyrhs_size
);
349 if (!semantic_parser
&& !no_parser_flag
)
350 obstack_sgrow (&table_obstack
, "\n#endif\n");
357 output_short_table (&table_obstack
, NULL
, "yystos", accessing_symbol
,
363 output_rule_data (void)
367 short *short_tab
= NULL
;
369 obstack_sgrow (&table_obstack
, "\n\
370 #if YYDEBUG != 0\n");
372 output_short_table (&table_obstack
,
373 "YYRLINE[YYN] -- source line where rule number YYN was defined",
377 obstack_sgrow (&table_obstack
, "#endif\n\n");
379 if (token_table_flag
|| no_parser_flag
)
381 obstack_fgrow1 (&table_obstack
, "#define YYNTOKENS %d\n", ntokens
);
382 obstack_fgrow1 (&table_obstack
, "#define YYNNTS %d\n", nvars
);
383 obstack_fgrow1 (&table_obstack
, "#define YYNRULES %d\n", nrules
);
384 obstack_fgrow1 (&table_obstack
, "#define YYNSTATES %d\n", nstates
);
385 obstack_fgrow1 (&table_obstack
, "#define YYMAXUTOK %d\n\n",
386 max_user_token_number
);
389 /* Output the table of symbol names. */
390 if (!token_table_flag
&& !no_parser_flag
)
391 obstack_sgrow (&table_obstack
,
392 "\n#if YYDEBUG != 0 || defined YYERROR_VERBOSE\n\n");
393 obstack_sgrow (&table_obstack
, "\
394 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */\n");
395 obstack_sgrow (&table_obstack
,
396 "static const char *const yytname[] =\n{\n ");
399 for (i
= 0; i
< nsyms
; i
++)
400 /* this used to be i<=nsyms, but that output a final "" symbol
401 almost by accident */
403 /* Width of the next token, including the two quotes, the coma
408 for (p
= tags
[i
]; p
&& *p
; p
++)
409 if (*p
== '"' || *p
== '\\' || *p
== '\n' || *p
== '\t'
412 else if (*p
< 040 || *p
>= 0177)
417 if (j
+ strsize
> 75)
419 obstack_sgrow (&table_obstack
, "\n ");
423 obstack_1grow (&table_obstack
, '\"');
424 for (p
= tags
[i
]; p
&& *p
; p
++)
426 if (*p
== '"' || *p
== '\\')
427 obstack_fgrow1 (&table_obstack
, "\\%c", *p
);
429 obstack_sgrow (&table_obstack
, "\\n");
431 obstack_sgrow (&table_obstack
, "\\t");
433 obstack_sgrow (&table_obstack
, "\\b");
434 else if (*p
< 040 || *p
>= 0177)
435 obstack_fgrow1 (&table_obstack
, "\\%03o", *p
);
437 obstack_1grow (&table_obstack
, *p
);
440 obstack_sgrow (&table_obstack
, "\", ");
443 /* add a NULL entry to list of tokens */
444 obstack_sgrow (&table_obstack
, "NULL\n};\n");
446 if (!token_table_flag
&& !no_parser_flag
)
447 obstack_sgrow (&table_obstack
, "#endif\n\n");
449 /* Output YYTOKNUM. */
450 if (token_table_flag
)
452 output_short_table (&table_obstack
,
453 "YYTOKNUM[YYLEX] -- Index in YYTNAME corresponding to YYLEX",
454 "yytoknum", user_toknums
,
459 output_short_table (&table_obstack
,
460 "YYR1[YYN] -- Symbol number of symbol that rule YYN derives",
465 obstack_1grow (&table_obstack
, '\n');
468 short_tab
= XMALLOC (short, nrules
+ 1);
469 for (i
= 1; i
< nrules
; i
++)
470 short_tab
[i
] = rrhs
[i
+ 1] - rrhs
[i
] - 1;
471 short_tab
[nrules
] = nitems
- rrhs
[nrules
] - 1;
472 output_short_table (&table_obstack
,
473 "YYR2[YYN] -- Number of symbols composing right hand side of rule YYN",
476 obstack_1grow (&table_obstack
, '\n');
485 output_defines (void)
487 obstack_fgrow1 (&table_obstack
, "\n\n#define\tYYFINAL\t\t%d\n", final_state
);
488 obstack_fgrow1 (&table_obstack
, "#define\tYYFLAG\t\t%d\n", MINSHORT
);
489 obstack_fgrow1 (&table_obstack
, "#define\tYYNTBASE\t%d\n", ntokens
);
493 /*------------------------------------------------------------------.
494 | Decide what to do for each type of token if seen as the lookahead |
495 | token in specified state. The value returned is used as the |
496 | default action (yydefact) for the state. In addition, actrow is |
497 | filled with what to do for each kind of token, index by symbol |
498 | number, with zero meaning do the default action. The value |
499 | MINSHORT, a very negative number, means this situation is an |
500 | error. The parser recognizes this value specially. |
502 | This is where conflicts are resolved. The loop over lookahead |
503 | rules considered lower-numbered rules last, and the last rule |
504 | considered that likes a token gets to handle it. |
505 `------------------------------------------------------------------*/
508 action_row (int state
)
527 int nodefault
= 0; /* set nonzero to inhibit having any default reduction */
529 for (i
= 0; i
< ntokens
; i
++)
534 redp
= reduction_table
[state
];
542 /* loop over all the rules available here which require
544 m
= lookaheads
[state
];
545 n
= lookaheads
[state
+ 1];
547 for (i
= n
- 1; i
>= m
; i
--)
550 wordp
= LA
+ i
* tokensetsize
;
553 /* and find each token which the rule finds acceptable
555 for (j
= 0; j
< ntokens
; j
++)
557 /* and record this rule as the rule to use if that
573 shiftp
= shift_table
[state
];
575 /* Now see which tokens are allowed for shifts in this state. For
576 them, record the shift as the thing to do. So shift is preferred
583 for (i
= 0; i
< k
; i
++)
585 shift_state
= shiftp
->shifts
[i
];
589 symbol
= accessing_symbol
[shift_state
];
594 actrow
[symbol
] = shift_state
;
596 /* Do not use any default reduction if there is a shift for
598 if (symbol
== error_token_number
)
603 errp
= err_table
[state
];
605 /* See which tokens are an explicit error in this state (due to
606 %nonassoc). For them, record MINSHORT as the action. */
612 for (i
= 0; i
< k
; i
++)
614 symbol
= errp
->errs
[i
];
615 actrow
[symbol
] = MINSHORT
;
619 /* Now find the most common reduction and make it the default action
622 if (nreds
>= 1 && !nodefault
)
624 if (consistent
[state
])
625 default_rule
= redp
->rules
[0];
629 for (i
= m
; i
< n
; i
++)
634 for (j
= 0; j
< ntokens
; j
++)
636 if (actrow
[j
] == rule
)
647 /* actions which match the default are replaced with zero,
648 which means "use the default" */
652 for (j
= 0; j
< ntokens
; j
++)
654 if (actrow
[j
] == default_rule
)
658 default_rule
= -default_rule
;
663 /* If have no default rule, the default is an error.
664 So replace any action which says "error" with "use default". */
666 if (default_rule
== 0)
667 for (j
= 0; j
< ntokens
; j
++)
669 if (actrow
[j
] == MINSHORT
)
687 for (i
= 0; i
< ntokens
; i
++)
696 froms
[state
] = sp1
= sp
= XCALLOC (short, count
);
697 tos
[state
] = sp2
= XCALLOC (short, count
);
699 for (i
= 0; i
< ntokens
; i
++)
708 tally
[state
] = count
;
709 width
[state
] = sp1
[-1] - sp
[0] + 1;
713 /*------------------------------------------------------------------.
714 | Figure out the actions for the specified state, indexed by |
715 | lookahead token type. |
717 | The YYDEFACT table is output now. The detailed info is saved for |
718 | putting into YYTABLE later. |
719 `------------------------------------------------------------------*/
725 short *yydefact
= XCALLOC (short, nstates
);
727 actrow
= XCALLOC (short, ntokens
);
728 for (i
= 0; i
< nstates
; ++i
)
730 yydefact
[i
] = action_row (i
);
735 output_short_table (&table_obstack
,
736 "YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE\n\
737 doesn't specify something else to do. Zero means the default is an\n\
739 "yydefact", yydefact
,
740 yydefact
[0], 1, nstates
);
741 obstack_1grow (&table_obstack
, '\n');
749 shifts
*sp
, *sptmp
; /* JF derefrenced freed ptr */
753 for (sp
= first_shift
; sp
; sp
= sptmp
)
762 free_reductions (void)
764 reductions
*rp
, *rptmp
; /* JF fixed freed ptr */
766 XFREE (reduction_table
);
768 for (rp
= first_reduction
; rp
; rp
= rptmp
)
778 save_column (int symbol
, int default_state
)
787 short begin
= goto_map
[symbol
];
788 short end
= goto_map
[symbol
+ 1];
791 for (i
= begin
; i
< end
; i
++)
793 if (to_state
[i
] != default_state
)
800 symno
= symbol
- ntokens
+ nstates
;
802 froms
[symno
] = sp1
= sp
= XCALLOC (short, count
);
803 tos
[symno
] = sp2
= XCALLOC (short, count
);
805 for (i
= begin
; i
< end
; i
++)
807 if (to_state
[i
] != default_state
)
809 *sp1
++ = from_state
[i
];
810 *sp2
++ = to_state
[i
];
814 tally
[symno
] = count
;
815 width
[symno
] = sp1
[-1] - sp
[0] + 1;
819 default_goto (int symbol
)
827 m
= goto_map
[symbol
];
828 n
= goto_map
[symbol
+ 1];
833 for (i
= 0; i
< nstates
; i
++)
836 for (i
= m
; i
< n
; i
++)
837 state_count
[to_state
[i
]]++;
842 for (i
= 0; i
< nstates
; i
++)
844 if (state_count
[i
] > max
)
846 max
= state_count
[i
];
851 return default_state
;
855 /*-------------------------------------------------------------------.
856 | Figure out what to do after reducing with each rule, depending on |
857 | the saved state from before the beginning of parsing the data that |
858 | matched this rule. |
860 | The YYDEFGOTO table is output now. The detailed info is saved for |
861 | putting into YYTABLE later. |
862 `-------------------------------------------------------------------*/
869 short *yydefgoto
= XMALLOC (short, nsyms
- ntokens
);
870 state_count
= XCALLOC (short, nstates
);
872 for (i
= ntokens
; i
< nsyms
; ++i
)
874 int default_state
= default_goto (i
);
875 save_column (i
, default_state
);
876 yydefgoto
[i
- ntokens
] = default_state
;
879 output_short_table (&table_obstack
, NULL
, "yydefgoto", yydefgoto
,
880 yydefgoto
[0], 1, nsyms
- ntokens
);
887 /* The next few functions decide how to pack the actions and gotos
888 information into yytable. */
899 order
= XCALLOC (short, nvectors
);
902 for (i
= 0; i
< nvectors
; i
++)
910 while (j
>= 0 && (width
[order
[j
]] < w
))
913 while (j
>= 0 && (width
[order
[j
]] == w
) && (tally
[order
[j
]] < t
))
916 for (k
= nentries
- 1; k
> j
; k
--)
917 order
[k
+ 1] = order
[k
];
927 matching_state (int vector
)
944 for (prev
= vector
- 1; prev
>= 0; prev
--)
947 if (width
[j
] != w
|| tally
[j
] != t
)
951 for (k
= 0; match
&& k
< t
; k
++)
953 if (tos
[j
][k
] != tos
[i
][k
] || froms
[j
][k
] != froms
[i
][k
])
966 pack_vector (int vector
)
985 for (j
= lowzero
- from
[0]; j
< MAXTABLE
; j
++)
989 for (k
= 0; ok
&& k
< t
; k
++)
993 fatal (_("maximum table size (%d) exceeded"), MAXTABLE
);
999 for (k
= 0; ok
&& k
< vector
; k
++)
1007 for (k
= 0; k
< t
; k
++)
1011 check
[loc
] = from
[k
];
1014 while (table
[lowzero
] != 0)
1024 berror ("pack_vector");
1025 return 0; /* JF keep lint happy */
1036 base
= XCALLOC (short, nvectors
);
1037 pos
= XCALLOC (short, nentries
);
1038 table
= XCALLOC (short, MAXTABLE
);
1039 check
= XCALLOC (short, MAXTABLE
);
1044 for (i
= 0; i
< nvectors
; i
++)
1047 for (i
= 0; i
< MAXTABLE
; i
++)
1050 for (i
= 0; i
< nentries
; i
++)
1052 state
= matching_state (i
);
1055 place
= pack_vector (i
);
1057 place
= base
[state
];
1060 base
[order
[i
]] = place
;
1063 for (i
= 0; i
< nvectors
; i
++)
1076 /* the following functions output yytable, yycheck
1077 and the vectors whose elements index the portion starts */
1082 output_short_table (&table_obstack
, NULL
, "yypact", base
,
1083 base
[0], 1, nstates
);
1085 obstack_1grow (&table_obstack
, '\n');
1087 output_short_table (&table_obstack
, NULL
, "yypgoto", base
,
1088 base
[nstates
], nstates
+ 1, nvectors
);
1097 obstack_fgrow1 (&table_obstack
, "\n\n#define\tYYLAST\t\t%d\n\n\n", high
);
1098 output_short_table (&table_obstack
, NULL
, "yytable", table
,
1099 table
[0], 1, high
+ 1);
1107 output_short_table (&table_obstack
, NULL
, "yycheck", check
,
1108 check
[0], 1, high
+ 1);
1112 /* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable
1116 output_actions (void)
1118 nvectors
= nstates
+ nvars
;
1120 froms
= XCALLOC (short *, nvectors
);
1121 tos
= XCALLOC (short *, nvectors
);
1122 tally
= XCALLOC (short, nvectors
);
1123 width
= XCALLOC (short, nvectors
);
1131 XFREE (accessing_symbol
);
1134 XFREE (goto_map
+ ntokens
);
1140 obstack_1grow (&table_obstack
, '\n');
1143 obstack_1grow (&table_obstack
, '\n');
1147 /*------------------------------------------.
1148 | Copy the parser code into TABLE_OBSTACK. |
1149 `------------------------------------------*/
1152 output_parser (void)
1157 const char *skeleton
= NULL
;
1158 int actions_dumped
= 0;
1161 obstack_sgrow (&table_obstack
, "#define YYPURE 1\n\n");
1163 /* Loop over lines in the standard parser file. */
1164 if (semantic_parser
)
1165 skeleton
= skeleton_find ("BISON_HAIRY", BISON_HAIRY
);
1167 skeleton
= skeleton_find ("BISON_SIMPLE", BISON_SIMPLE
);
1168 fskel
= xfopen (skeleton
, "r");
1170 /* Set LINE to 2, not 1: `#line LINENUM' -- Here LINENUM is a
1171 decimal integer constant. This specifies that the line number of
1172 the *following* line of input, in its original source file, was
1181 sync_line
, /* #line. */
1182 actions_line
/* %% actions. */
1184 enum line_type_e line_type
= regular_line
;
1188 /* Is this line special? */
1191 /* See if it's a `#line' line. */
1192 if ((c
= getc (fskel
)) == 'l')
1193 if ((c
= getc (fskel
)) == 'i')
1194 if ((c
= getc (fskel
)) == 'n')
1195 if ((c
= getc (fskel
)) == 'e')
1196 line_type
= sync_line
;
1198 obstack_sgrow (&table_obstack
, "#lin");
1200 obstack_sgrow (&table_obstack
, "#li");
1202 obstack_sgrow (&table_obstack
, "#l");
1204 obstack_sgrow (&table_obstack
, "#");
1208 /* See if it's a `%% actions' line. */
1209 if ((c
= getc (fskel
)) == '%')
1210 if ((c
= getc (fskel
)) == ' ')
1211 if ((c
= getc (fskel
)) == 'a')
1212 if ((c
= getc (fskel
)) == 'c')
1213 if ((c
= getc (fskel
)) == 't')
1214 if ((c
= getc (fskel
)) == 'i')
1215 if ((c
= getc (fskel
)) == 'o')
1216 if ((c
= getc (fskel
)) == 'n')
1217 if ((c
= getc (fskel
)) == 's')
1218 line_type
= actions_line
;
1220 obstack_sgrow (&table_obstack
, "%% action");
1222 obstack_sgrow (&table_obstack
, "%% actio");
1224 obstack_sgrow (&table_obstack
, "%% acti");
1226 obstack_sgrow (&table_obstack
, "%% act");
1228 obstack_sgrow (&table_obstack
, "%% ac");
1230 obstack_sgrow (&table_obstack
, "%% a");
1232 obstack_sgrow (&table_obstack
, "%% ");
1234 obstack_sgrow (&table_obstack
, "%%");
1236 obstack_sgrow (&table_obstack
, "%");
1243 obstack_fgrow2 (&table_obstack
, "#line %d %s\n",
1244 line
, quotearg_style (c_quoting_style
, skeleton
));
1246 /* Skip the end of line. */
1247 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1253 size_t size
= obstack_object_size (&action_obstack
);
1256 assert (actions_dumped
== 1);
1257 obstack_grow (&table_obstack
,
1258 obstack_finish (&action_obstack
),
1262 /* Skip the end of line. */
1263 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1268 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1269 obstack_1grow (&table_obstack
, c
);
1274 obstack_1grow (&table_obstack
, c
);
1277 assert (actions_dumped
== 1);
1282 output_program (void)
1287 obstack_fgrow2 (&table_obstack
, "#line %d %s\n",
1288 lineno
, quotearg_style (c_quoting_style
, infile
));
1290 while ((c
= getc (finput
)) != EOF
)
1291 obstack_1grow (&table_obstack
, c
);
1296 free_itemsets (void)
1300 XFREE (state_table
);
1302 for (cp
= first_state
; cp
; cp
= cptmp
)
1310 /*----------------------------------------------------------.
1311 | Output the parsing tables and the parser code to ftable. |
1312 `----------------------------------------------------------*/
1317 /* output_token_defines(ftable); / * JF put out token defines FIRST */
1319 /* If using a simple parser the definition of YYSTYPE are put into
1321 if (!semantic_parser
)
1323 size_t size
= obstack_object_size (&attrs_obstack
);
1324 obstack_grow (&table_obstack
, obstack_finish (&attrs_obstack
), size
);
1326 reader_output_yylsp (&table_obstack
);
1328 obstack_sgrow (&table_obstack
, "\
1330 # define YYDEBUG 1\n\
1334 if (semantic_parser
)
1335 obstack_fgrow1 (&table_obstack
, "#include %s\n",
1336 quotearg_style (c_quoting_style
, attrsfile
));
1338 if (!no_parser_flag
)
1339 obstack_sgrow (&table_obstack
, "#include <stdio.h>\n\n");
1341 /* Make "const" do nothing if not in ANSI C. */
1342 obstack_sgrow (&table_obstack
, "\
1343 #ifndef __cplusplus\n\
1344 # ifndef __STDC__\n\
1352 output_token_translations ();
1353 /* if (semantic_parser) */
1354 /* This is now unconditional because debugging printouts can use it. */
1357 if (semantic_parser
)
1359 output_rule_data ();
1361 if (!no_parser_flag
)