]>
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 ??
100 #include "complain.h"
104 #include "conflicts.h"
106 extern void berror
PARAMS((const char *));
112 static short **froms
;
116 static short *actrow
;
117 static short *state_count
;
129 output_short_or_char_table (struct obstack
*oout
,
132 const char *table_name
,
135 short begin
, short end
)
140 obstack_fgrow1 (oout
, "/* %s. */\n", comment
);
142 obstack_fgrow3 (oout
, "static const %s %s[] =\n{\n %6d",
143 type
, table_name
, first_value
);
146 for (i
= begin
; i
< end
; i
++)
148 obstack_1grow (oout
, ',');
152 obstack_grow_literal_string (oout
, "\n ");
160 obstack_fgrow1 (oout
, "%6d", short_table
[i
]);
163 obstack_grow_literal_string (oout
, "\n};\n");
168 output_short_table (struct obstack
*oout
,
170 const char *table_name
,
173 short begin
, short end
)
175 output_short_or_char_table (oout
, comment
, "short", table_name
, short_table
,
176 first_value
, begin
, end
);
180 /*--------------------------------------------------------------.
181 | output_headers -- Output constant strings to the beginning of |
183 `--------------------------------------------------------------*/
188 extern int yyerror;\n\
189 extern int yycost;\n\
190 extern char * yymsg;\n\
191 extern YYSTYPE yyval;\n\
193 yyguard(n, yyvsp, yylsp)\n\
195 register YYSTYPE *yyvsp;\n\
196 register YYLTYPE *yylsp;\n\
207 extern YYSTYPE yyval;\n\
208 extern int yychar;\n\
210 yyaction(n, yyvsp, yylsp)\n\
212 register YYSTYPE *yyvsp;\n\
213 register YYLTYPE *yylsp;\n\
218 #define ACTSTR_PROLOGUE \
222 #define ACTSTR_EPILOGUE \
224 extern YYSTYPE yyval;\n\
225 extern int yychar;\n\
227 yyaction(n, yyvsp, yylsp)\n\
229 register YYSTYPE *yyvsp;\n\
230 register YYLTYPE *yylsp;\n\
235 #define ACTSTR_SIMPLE "\n switch (yyn) {\n"
238 output_headers (void)
241 fprintf (fguard
, GUARDSTR
, attrsfile
);
248 obstack_grow_literal_string (&action_obstack
,
250 obstack_grow (&action_obstack
,
251 attrsfile
, strlen (attrsfile
));
252 obstack_grow_literal_string (&action_obstack
,
257 obstack_grow_literal_string (&action_obstack
, ACTSTR_SIMPLE
);
260 /* if (semantic_parser) JF moved this below
261 fprintf(ftable, "#include \"%s\"\n", attrsfile);
262 fprintf(ftable, "#include <stdio.h>\n\n");
265 /* Rename certain symbols if -p was specified. */
266 if (spec_name_prefix
)
268 obstack_fgrow1 (&table_obstack
,
269 "#define yyparse %sparse\n", spec_name_prefix
);
270 obstack_fgrow1 (&table_obstack
,
271 "#define yylex %slex\n", spec_name_prefix
);
272 obstack_fgrow1 (&table_obstack
,
273 "#define yyerror %serror\n", spec_name_prefix
);
274 obstack_fgrow1 (&table_obstack
,
275 "#define yylval %slval\n", spec_name_prefix
);
276 obstack_fgrow1 (&table_obstack
,
277 "#define yychar %schar\n", spec_name_prefix
);
278 obstack_fgrow1 (&table_obstack
,
279 "#define yydebug %sdebug\n", spec_name_prefix
);
280 obstack_fgrow1 (&table_obstack
,
281 "#define yynerrs %snerrs\n", spec_name_prefix
);
286 /*-------------------------------------------------------.
287 | Output constant strings to the ends of certain files. |
288 `-------------------------------------------------------*/
291 output_trailers (void)
294 fprintf (fguard
, "\n }\n}\n");
296 obstack_1grow (&action_obstack
, '\n');
303 obstack_grow_literal_string (&action_obstack
,
306 obstack_grow_literal_string (&action_obstack
,
313 output_token_translations (void)
315 obstack_grow_literal_string (&table_obstack
, "\
317 /* YYRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */\n");
321 obstack_fgrow2 (&table_obstack
,
322 "#define YYTRANSLATE(x) ((unsigned)(x) <= %d ? yytranslate[x] : %d)\
325 max_user_token_number
, nsyms
);
327 output_short_or_char_table (&table_obstack
,
328 "YYRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX",
329 ntokens
< 127 ? "char" : "short",
330 "yytranslate", token_translations
,
331 0, 1, max_user_token_number
+ 1);
335 obstack_grow_literal_string (&table_obstack
,
336 "\n#define YYTRANSLATE(x) (x)\n");
344 /* With the ordinary parser,
345 yyprhs and yyrhs are needed only for yydebug. */
346 /* With the no_parser option, all tables are generated */
347 if (!semantic_parser
&& !no_parser_flag
)
348 obstack_grow_literal_string (&table_obstack
, "\n#if YYDEBUG != 0\n");
350 output_short_table (&table_obstack
, NULL
, "yyprhs", rrhs
,
354 size_t yyrhs_size
= 1;
358 for (sp
= ritem
+ 1; *sp
; sp
++)
360 yyrhs
= XMALLOC (short, yyrhs_size
);
362 for (sp
= ritem
+ 1, i
= 1; *sp
; ++sp
, ++i
)
363 yyrhs
[i
] = *sp
> 0 ? *sp
: 0;
365 output_short_table (&table_obstack
, NULL
, "yyrhs", yyrhs
,
366 ritem
[0], 1, yyrhs_size
);
370 if (!semantic_parser
&& !no_parser_flag
)
371 obstack_grow_literal_string (&table_obstack
, "\n#endif\n");
378 output_short_table (&table_obstack
, NULL
, "yystos", accessing_symbol
,
384 output_rule_data (void)
388 short *short_tab
= NULL
;
390 obstack_grow_literal_string (&table_obstack
, "\n\
391 #if YYDEBUG != 0\n");
393 output_short_table (&table_obstack
,
394 "YYRLINE[YYN] -- source line where rule number YYN was defined",
398 obstack_grow_literal_string (&table_obstack
, "#endif\n\n");
400 if (token_table_flag
|| no_parser_flag
)
402 obstack_fgrow1 (&table_obstack
, "#define YYNTOKENS %d\n", ntokens
);
403 obstack_fgrow1 (&table_obstack
, "#define YYNNTS %d\n", nvars
);
404 obstack_fgrow1 (&table_obstack
, "#define YYNRULES %d\n", nrules
);
405 obstack_fgrow1 (&table_obstack
, "#define YYNSTATES %d\n", nstates
);
406 obstack_fgrow1 (&table_obstack
, "#define YYMAXUTOK %d\n\n",
407 max_user_token_number
);
410 /* Output the table of symbol names. */
411 if (!token_table_flag
&& !no_parser_flag
)
412 obstack_grow_literal_string (&table_obstack
,
413 "\n#if YYDEBUG != 0 || defined YYERROR_VERBOSE\n\n");
414 obstack_grow_literal_string (&table_obstack
, "\
415 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */\n");
416 obstack_grow_literal_string (&table_obstack
,
417 "static const char *const yytname[] =\n{\n ");
420 for (i
= 0; i
< nsyms
; i
++)
421 /* this used to be i<=nsyms, but that output a final "" symbol
422 almost by accident */
424 /* Width of the next token, including the two quotes, the coma
429 for (p
= tags
[i
]; p
&& *p
; p
++)
430 if (*p
== '"' || *p
== '\\' || *p
== '\n' || *p
== '\t'
433 else if (*p
< 040 || *p
>= 0177)
438 if (j
+ strsize
> 75)
440 obstack_grow_literal_string (&table_obstack
, "\n ");
444 obstack_1grow (&table_obstack
, '\"');
445 for (p
= tags
[i
]; p
&& *p
; p
++)
447 if (*p
== '"' || *p
== '\\')
449 obstack_fgrow1 (&table_obstack
, "\\%c", *p
);
453 obstack_grow_literal_string (&table_obstack
, "\\n");
457 obstack_grow_literal_string (&table_obstack
, "\\t");
461 obstack_grow_literal_string (&table_obstack
, "\\b");
463 else if (*p
< 040 || *p
>= 0177)
465 obstack_fgrow1 (&table_obstack
, "\\%03o", *p
);
469 obstack_1grow (&table_obstack
, *p
);
473 obstack_grow_literal_string (&table_obstack
, "\", ");
476 /* add a NULL entry to list of tokens */
477 obstack_grow_literal_string (&table_obstack
, "NULL\n};\n");
479 if (!token_table_flag
&& !no_parser_flag
)
480 obstack_grow_literal_string (&table_obstack
, "#endif\n\n");
482 /* Output YYTOKNUM. */
483 if (token_table_flag
)
485 output_short_table (&table_obstack
,
486 "YYTOKNUM[YYLEX] -- Index in YYTNAME corresponding to YYLEX",
487 "yytoknum", user_toknums
,
492 output_short_table (&table_obstack
,
493 "YYR1[YYN] -- Symbol number of symbol that rule YYN derives",
498 obstack_1grow (&table_obstack
, '\n');
501 short_tab
= XMALLOC (short, nrules
+ 1);
502 for (i
= 1; i
< nrules
; i
++)
503 short_tab
[i
] = rrhs
[i
+ 1] - rrhs
[i
] - 1;
504 short_tab
[nrules
] = nitems
- rrhs
[nrules
] - 1;
505 output_short_table (&table_obstack
,
506 "YYR2[YYN] -- Number of symbols composing right hand side of rule YYN",
509 obstack_1grow (&table_obstack
, '\n');
518 output_defines (void)
520 obstack_fgrow1 (&table_obstack
, "\n\n#define\tYYFINAL\t\t%d\n", final_state
);
521 obstack_fgrow1 (&table_obstack
, "#define\tYYFLAG\t\t%d\n", MINSHORT
);
522 obstack_fgrow1 (&table_obstack
, "#define\tYYNTBASE\t%d\n", ntokens
);
526 /*------------------------------------------------------------------.
527 | Decide what to do for each type of token if seen as the lookahead |
528 | token in specified state. The value returned is used as the |
529 | default action (yydefact) for the state. In addition, actrow is |
530 | filled with what to do for each kind of token, index by symbol |
531 | number, with zero meaning do the default action. The value |
532 | MINSHORT, a very negative number, means this situation is an |
533 | error. The parser recognizes this value specially. |
535 | This is where conflicts are resolved. The loop over lookahead |
536 | rules considered lower-numbered rules last, and the last rule |
537 | considered that likes a token gets to handle it. |
538 `------------------------------------------------------------------*/
541 action_row (int state
)
560 int nodefault
= 0; /* set nonzero to inhibit having any default reduction */
562 for (i
= 0; i
< ntokens
; i
++)
567 redp
= reduction_table
[state
];
575 /* loop over all the rules available here which require
577 m
= lookaheads
[state
];
578 n
= lookaheads
[state
+ 1];
580 for (i
= n
- 1; i
>= m
; i
--)
583 wordp
= LA
+ i
* tokensetsize
;
586 /* and find each token which the rule finds acceptable
588 for (j
= 0; j
< ntokens
; j
++)
590 /* and record this rule as the rule to use if that
606 shiftp
= shift_table
[state
];
608 /* Now see which tokens are allowed for shifts in this state. For
609 them, record the shift as the thing to do. So shift is preferred
616 for (i
= 0; i
< k
; i
++)
618 shift_state
= shiftp
->shifts
[i
];
622 symbol
= accessing_symbol
[shift_state
];
627 actrow
[symbol
] = shift_state
;
629 /* Do not use any default reduction if there is a shift for
631 if (symbol
== error_token_number
)
636 errp
= err_table
[state
];
638 /* See which tokens are an explicit error in this state (due to
639 %nonassoc). For them, record MINSHORT as the action. */
645 for (i
= 0; i
< k
; i
++)
647 symbol
= errp
->errs
[i
];
648 actrow
[symbol
] = MINSHORT
;
652 /* Now find the most common reduction and make it the default action
655 if (nreds
>= 1 && !nodefault
)
657 if (consistent
[state
])
658 default_rule
= redp
->rules
[0];
662 for (i
= m
; i
< n
; i
++)
667 for (j
= 0; j
< ntokens
; j
++)
669 if (actrow
[j
] == rule
)
680 /* actions which match the default are replaced with zero,
681 which means "use the default" */
685 for (j
= 0; j
< ntokens
; j
++)
687 if (actrow
[j
] == default_rule
)
691 default_rule
= -default_rule
;
696 /* If have no default rule, the default is an error.
697 So replace any action which says "error" with "use default". */
699 if (default_rule
== 0)
700 for (j
= 0; j
< ntokens
; j
++)
702 if (actrow
[j
] == MINSHORT
)
720 for (i
= 0; i
< ntokens
; i
++)
729 froms
[state
] = sp1
= sp
= XCALLOC (short, count
);
730 tos
[state
] = sp2
= XCALLOC (short, count
);
732 for (i
= 0; i
< ntokens
; i
++)
741 tally
[state
] = count
;
742 width
[state
] = sp1
[-1] - sp
[0] + 1;
746 /*------------------------------------------------------------------.
747 | Figure out the actions for the specified state, indexed by |
748 | lookahead token type. |
750 | The YYDEFACT table is output now. The detailed info is saved for |
751 | putting into YYTABLE later. |
752 `------------------------------------------------------------------*/
758 short *yydefact
= XCALLOC (short, nstates
);
760 actrow
= XCALLOC (short, ntokens
);
761 for (i
= 0; i
< nstates
; ++i
)
763 yydefact
[i
] = action_row (i
);
768 output_short_table (&table_obstack
,
769 "YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE\n\
770 doesn't specify something else to do. Zero means the default is an\n\
772 "yydefact", yydefact
,
773 yydefact
[0], 1, nstates
);
774 obstack_1grow (&table_obstack
, '\n');
782 shifts
*sp
, *sptmp
; /* JF derefrenced freed ptr */
786 for (sp
= first_shift
; sp
; sp
= sptmp
)
795 free_reductions (void)
797 reductions
*rp
, *rptmp
; /* JF fixed freed ptr */
799 XFREE (reduction_table
);
801 for (rp
= first_reduction
; rp
; rp
= rptmp
)
811 save_column (int symbol
, int default_state
)
820 short begin
= goto_map
[symbol
];
821 short end
= goto_map
[symbol
+ 1];
824 for (i
= begin
; i
< end
; i
++)
826 if (to_state
[i
] != default_state
)
833 symno
= symbol
- ntokens
+ nstates
;
835 froms
[symno
] = sp1
= sp
= XCALLOC (short, count
);
836 tos
[symno
] = sp2
= XCALLOC (short, count
);
838 for (i
= begin
; i
< end
; i
++)
840 if (to_state
[i
] != default_state
)
842 *sp1
++ = from_state
[i
];
843 *sp2
++ = to_state
[i
];
847 tally
[symno
] = count
;
848 width
[symno
] = sp1
[-1] - sp
[0] + 1;
852 default_goto (int symbol
)
860 m
= goto_map
[symbol
];
861 n
= goto_map
[symbol
+ 1];
866 for (i
= 0; i
< nstates
; i
++)
869 for (i
= m
; i
< n
; i
++)
870 state_count
[to_state
[i
]]++;
875 for (i
= 0; i
< nstates
; i
++)
877 if (state_count
[i
] > max
)
879 max
= state_count
[i
];
884 return default_state
;
888 /*-------------------------------------------------------------------.
889 | Figure out what to do after reducing with each rule, depending on |
890 | the saved state from before the beginning of parsing the data that |
891 | matched this rule. |
893 | The YYDEFGOTO table is output now. The detailed info is saved for |
894 | putting into YYTABLE later. |
895 `-------------------------------------------------------------------*/
902 short *yydefgoto
= XMALLOC (short, nsyms
- ntokens
);
903 state_count
= XCALLOC (short, nstates
);
905 for (i
= ntokens
; i
< nsyms
; ++i
)
907 int default_state
= default_goto (i
);
908 save_column (i
, default_state
);
909 yydefgoto
[i
- ntokens
] = default_state
;
912 output_short_table (&table_obstack
, NULL
, "yydefgoto", yydefgoto
,
913 yydefgoto
[0], 1, nsyms
- ntokens
);
920 /* The next few functions decide how to pack the actions and gotos
921 information into yytable. */
932 order
= XCALLOC (short, nvectors
);
935 for (i
= 0; i
< nvectors
; i
++)
943 while (j
>= 0 && (width
[order
[j
]] < w
))
946 while (j
>= 0 && (width
[order
[j
]] == w
) && (tally
[order
[j
]] < t
))
949 for (k
= nentries
- 1; k
> j
; k
--)
950 order
[k
+ 1] = order
[k
];
960 matching_state (int vector
)
977 for (prev
= vector
- 1; prev
>= 0; prev
--)
980 if (width
[j
] != w
|| tally
[j
] != t
)
984 for (k
= 0; match
&& k
< t
; k
++)
986 if (tos
[j
][k
] != tos
[i
][k
] || froms
[j
][k
] != froms
[i
][k
])
999 pack_vector (int vector
)
1018 for (j
= lowzero
- from
[0]; j
< MAXTABLE
; j
++)
1022 for (k
= 0; ok
&& k
< t
; k
++)
1026 fatal (_("maximum table size (%d) exceeded"), MAXTABLE
);
1028 if (table
[loc
] != 0)
1032 for (k
= 0; ok
&& k
< vector
; k
++)
1040 for (k
= 0; k
< t
; k
++)
1044 check
[loc
] = from
[k
];
1047 while (table
[lowzero
] != 0)
1057 berror ("pack_vector");
1058 return 0; /* JF keep lint happy */
1069 base
= XCALLOC (short, nvectors
);
1070 pos
= XCALLOC (short, nentries
);
1071 table
= XCALLOC (short, MAXTABLE
);
1072 check
= XCALLOC (short, MAXTABLE
);
1077 for (i
= 0; i
< nvectors
; i
++)
1080 for (i
= 0; i
< MAXTABLE
; i
++)
1083 for (i
= 0; i
< nentries
; i
++)
1085 state
= matching_state (i
);
1088 place
= pack_vector (i
);
1090 place
= base
[state
];
1093 base
[order
[i
]] = place
;
1096 for (i
= 0; i
< nvectors
; i
++)
1109 /* the following functions output yytable, yycheck
1110 and the vectors whose elements index the portion starts */
1115 output_short_table (&table_obstack
, NULL
, "yypact", base
,
1116 base
[0], 1, nstates
);
1118 obstack_1grow (&table_obstack
, '\n');
1120 output_short_table (&table_obstack
, NULL
, "yypgoto", base
,
1121 base
[nstates
], nstates
+ 1, nvectors
);
1130 obstack_fgrow1 (&table_obstack
, "\n\n#define\tYYLAST\t\t%d\n\n\n", high
);
1131 output_short_table (&table_obstack
, NULL
, "yytable", table
,
1132 table
[0], 1, high
+ 1);
1140 output_short_table (&table_obstack
, NULL
, "yycheck", check
,
1141 check
[0], 1, high
+ 1);
1145 /* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable
1149 output_actions (void)
1151 nvectors
= nstates
+ nvars
;
1153 froms
= XCALLOC (short *, nvectors
);
1154 tos
= XCALLOC (short *, nvectors
);
1155 tally
= XCALLOC (short, nvectors
);
1156 width
= XCALLOC (short, nvectors
);
1164 XFREE (accessing_symbol
);
1167 XFREE (goto_map
+ ntokens
);
1173 obstack_1grow (&table_obstack
, '\n');
1176 obstack_1grow (&table_obstack
, '\n');
1180 /* copy the parser code into the ftable file at the end. */
1183 output_parser (void)
1186 static int number_of_dollar_signs
= 0;
1190 #define fpars fparser
1194 obstack_grow_literal_string (&table_obstack
, "#define YYPURE 1\n\n");
1197 /* JF no longer needed 'cuz open_extra_files changes the currently
1198 open parser from bison.simple to bison.hairy */
1199 if (semantic_parser
)
1205 /* Loop over lines in the standard parser file. */
1213 /* See if the line starts with `#line.
1214 If so, set write_line to 0. */
1231 obstack_grow_literal_string (&table_obstack
, "#lin");
1234 obstack_grow_literal_string (&table_obstack
, "#li");
1237 obstack_grow_literal_string (&table_obstack
, "#l");
1240 obstack_grow_literal_string (&table_obstack
, "#");
1243 /* now write out the line... */
1244 for (; c
!= '\n' && c
!= EOF
; c
= getc (fpars
))
1247 /* `$' in the parser file indicates where to put the
1248 actions. Copy them in at this point. */
1251 size_t size
= obstack_object_size (&action_obstack
);
1253 number_of_dollar_signs
++;
1254 assert (number_of_dollar_signs
== 1);
1255 obstack_grow (&table_obstack
,
1256 obstack_finish (&action_obstack
),
1259 /* Skip the end of the line containing `$'. */
1263 obstack_1grow (&table_obstack
, c
);
1267 obstack_1grow (&table_obstack
, c
);
1269 assert (number_of_dollar_signs
== 1);
1273 output_program (void)
1278 obstack_fgrow2 (&table_obstack
, "#line %d \"%s\"\n", lineno
, infile
);
1283 obstack_1grow (&table_obstack
, c
);
1290 free_itemsets (void)
1294 XFREE (state_table
);
1296 for (cp
= first_state
; cp
; cp
= cptmp
)
1304 /*----------------------------------------------------------.
1305 | Output the parsing tables and the parser code to ftable. |
1306 `----------------------------------------------------------*/
1311 /* output_token_defines(ftable); / * JF put out token defines FIRST */
1313 /* If using a simple parser the definition of YYSTYPE are put into
1315 if (!semantic_parser
)
1317 size_t size
= obstack_object_size (&attrs_obstack
);
1318 obstack_grow (&table_obstack
, obstack_finish (&attrs_obstack
), size
);
1320 reader_output_yylsp (&table_obstack
);
1322 obstack_grow_literal_string (&table_obstack
, "\
1324 # define YYDEBUG 1\n\
1328 if (semantic_parser
)
1329 obstack_fgrow1 (&table_obstack
, "#include \"%s\"\n", attrsfile
);
1331 if (!no_parser_flag
)
1332 obstack_grow_literal_string (&table_obstack
, "#include <stdio.h>\n\n");
1334 /* Make "const" do nothing if not in ANSI C. */
1335 obstack_grow_literal_string (&table_obstack
, "\
1336 #ifndef __cplusplus\n\
1337 # ifndef __STDC__\n\
1345 output_token_translations ();
1346 /* if (semantic_parser) */
1347 /* This is now unconditional because debugging printouts can use it. */
1350 if (semantic_parser
)
1352 output_rule_data ();
1354 if (!no_parser_flag
)