]>
git.saurik.com Git - bison.git/blob - src/output.c
2013bf097b6fa18d70f0d56fca7d4bfd811b3ccc
1 /* Output the generated parsing program for bison,
2 Copyright 1984, 1986, 1989, 1992, 2000, 2001 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"
109 static short **froms
= NULL
;
110 static short **tos
= NULL
;
111 static short *tally
= NULL
;
112 static short *width
= NULL
;
113 static short *actrow
= NULL
;
114 static short *state_count
= NULL
;
115 static short *order
= NULL
;
116 static short *base
= NULL
;
117 static short *pos
= NULL
;
118 static short *table
= NULL
;
119 static short *check
= NULL
;
126 output_short_or_char_table (struct obstack
*oout
,
129 const char *table_name
,
132 short begin
, short end
)
137 obstack_fgrow1 (oout
, "/* %s. */\n", comment
);
139 obstack_fgrow3 (oout
, "static const %s %s[] =\n{\n %6d",
140 type
, table_name
, first_value
);
143 for (i
= begin
; i
< end
; i
++)
145 obstack_1grow (oout
, ',');
149 obstack_sgrow (oout
, "\n ");
157 obstack_fgrow1 (oout
, "%6d", short_table
[i
]);
160 obstack_sgrow (oout
, "\n};\n");
165 output_short_table (struct obstack
*oout
,
167 const char *table_name
,
170 short begin
, short end
)
172 output_short_or_char_table (oout
, comment
, "short", table_name
, short_table
,
173 first_value
, begin
, end
);
177 /*--------------------------------------------------------------.
178 | output_headers -- Output constant strings to the beginning of |
180 `--------------------------------------------------------------*/
182 /* Don't put the `%s' insides quotes, since it quotearg puts them. */
187 extern int yyerror;\n\
188 extern int yycost;\n\
189 extern char * yymsg;\n\
190 extern YYSTYPE yyval;\n\
192 yyguard(n, yyvsp, yylsp)\n\
194 register YYSTYPE *yyvsp;\n\
195 register YYLTYPE *yylsp;\n\
206 extern YYSTYPE yyval;\n\
207 extern int yychar;\n\
209 yyaction(n, yyvsp, yylsp)\n\
211 register YYSTYPE *yyvsp;\n\
212 register YYLTYPE *yylsp;\n\
217 #define ACTSTR_SIMPLE "\n switch (yyn) {\n"
220 output_headers (void)
222 char *attrsfile_quoted
= 0;
226 /* FIXME: This is *buggy*. ATTRSFILE is not computed yet, since
227 we are waiting for the full input file to have been read to
228 be sure of the output file name. So basically, here, a SEGV
229 is guaranteed. OTOH, currently semantic parsers are not
231 attrsfile_quoted
= quotearg_style (c_quoting_style
, attrsfile
);
232 obstack_fgrow1 (&guard_obstack
, GUARDSTR
, attrsfile_quoted
);
239 obstack_fgrow1 (&action_obstack
, ACTSTR
, attrsfile_quoted
);
241 obstack_sgrow (&action_obstack
, ACTSTR_SIMPLE
);
243 /* Rename certain symbols if -p was specified. */
244 if (spec_name_prefix
)
246 obstack_fgrow1 (&table_obstack
,
247 "#define yyparse %sparse\n", spec_name_prefix
);
248 obstack_fgrow1 (&table_obstack
,
249 "#define yylex %slex\n", spec_name_prefix
);
250 obstack_fgrow1 (&table_obstack
,
251 "#define yyerror %serror\n", spec_name_prefix
);
252 obstack_fgrow1 (&table_obstack
,
253 "#define yylval %slval\n", spec_name_prefix
);
254 obstack_fgrow1 (&table_obstack
,
255 "#define yychar %schar\n", spec_name_prefix
);
256 obstack_fgrow1 (&table_obstack
,
257 "#define yydebug %sdebug\n", spec_name_prefix
);
258 obstack_fgrow1 (&table_obstack
,
259 "#define yynerrs %snerrs\n", spec_name_prefix
);
264 /*-------------------------------------------------------.
265 | Output constant strings to the ends of certain files. |
266 `-------------------------------------------------------*/
269 output_trailers (void)
272 obstack_sgrow (&guard_obstack
, "\n }\n}\n");
274 obstack_1grow (&action_obstack
, '\n');
280 obstack_sgrow (&action_obstack
, " }\n");
282 obstack_sgrow (&action_obstack
, "}\n");
288 output_token_translations (void)
290 obstack_sgrow (&table_obstack
, "\
292 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */\n");
294 obstack_fgrow2 (&table_obstack
,
295 "#define YYTRANSLATE(x) ((unsigned)(x) <= %d ? yytranslate[x] : %d)\
298 max_user_token_number
, nsyms
);
300 output_short_or_char_table (&table_obstack
,
301 "YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX",
302 ntokens
< 127 ? "char" : "short",
303 "yytranslate", token_translations
,
304 0, 1, max_user_token_number
+ 1);
306 XFREE (token_translations
);
313 /* With the ordinary parser,
314 yyprhs and yyrhs are needed only for yydebug. */
315 /* With the no_parser option, all tables are generated */
316 if (!semantic_parser
&& !no_parser_flag
)
317 obstack_sgrow (&table_obstack
, "\n#if YYDEBUG != 0\n");
321 short *values
= XCALLOC (short, nrules
+ 1);
322 for (i
= 0; i
< nrules
+ 1; ++i
)
323 values
[i
] = rule_table
[i
].rhs
;
324 output_short_table (&table_obstack
, NULL
, "yyprhs", values
,
330 size_t yyrhs_size
= 1;
334 for (sp
= ritem
+ 1; *sp
; sp
++)
336 yyrhs
= XMALLOC (short, yyrhs_size
);
338 for (sp
= ritem
+ 1, i
= 1; *sp
; ++sp
, ++i
)
339 yyrhs
[i
] = *sp
> 0 ? *sp
: 0;
341 output_short_table (&table_obstack
, NULL
, "yyrhs", yyrhs
,
342 ritem
[0], 1, yyrhs_size
);
346 if (!semantic_parser
&& !no_parser_flag
)
347 obstack_sgrow (&table_obstack
, "\n#endif\n");
355 short *values
= (short *) alloca (sizeof (short) * nstates
);
356 for (i
= 0; i
< nstates
; ++i
)
357 values
[i
] = state_table
[i
].accessing_symbol
;
358 output_short_table (&table_obstack
,
359 "YYSTOS[STATE] -- Accessing symbol to the STATE",
366 output_rule_data (void)
370 short *short_tab
= NULL
;
372 obstack_sgrow (&table_obstack
, "\n\
373 #if YYDEBUG != 0\n");
376 short *values
= XCALLOC (short, nrules
+ 1);
377 for (i
= 0; i
< nrules
+ 1; ++i
)
378 values
[i
] = rule_table
[i
].line
;
379 output_short_table (&table_obstack
,
380 "YYRLINE[YYN] -- source line where rule number YYN was defined",
386 obstack_sgrow (&table_obstack
, "#endif\n\n");
388 if (token_table_flag
|| no_parser_flag
)
390 obstack_fgrow1 (&table_obstack
, "#define YYNTOKENS %d\n", ntokens
);
391 obstack_fgrow1 (&table_obstack
, "#define YYNNTS %d\n", nvars
);
392 obstack_fgrow1 (&table_obstack
, "#define YYNRULES %d\n", nrules
);
393 obstack_fgrow1 (&table_obstack
, "#define YYNSTATES %d\n", nstates
);
394 obstack_fgrow1 (&table_obstack
, "#define YYMAXUTOK %d\n\n",
395 max_user_token_number
);
398 /* Output the table of symbol names. */
399 if (!token_table_flag
&& !no_parser_flag
)
400 obstack_sgrow (&table_obstack
,
401 "\n#if YYDEBUG != 0 || defined YYERROR_VERBOSE\n\n");
402 obstack_sgrow (&table_obstack
, "\
403 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */\n");
404 obstack_sgrow (&table_obstack
,
405 "static const char *const yytname[] =\n{\n ");
408 for (i
= 0; i
< nsyms
; i
++)
409 /* this used to be i<=nsyms, but that output a final "" symbol
410 almost by accident */
412 /* Width of the next token, including the two quotes, the coma
417 for (p
= tags
[i
]; p
&& *p
; p
++)
418 if (*p
== '"' || *p
== '\\' || *p
== '\n' || *p
== '\t'
421 else if (*p
< 040 || *p
>= 0177)
426 if (j
+ strsize
> 75)
428 obstack_sgrow (&table_obstack
, "\n ");
432 obstack_1grow (&table_obstack
, '\"');
433 for (p
= tags
[i
]; p
&& *p
; p
++)
435 if (*p
== '"' || *p
== '\\')
436 obstack_fgrow1 (&table_obstack
, "\\%c", *p
);
438 obstack_sgrow (&table_obstack
, "\\n");
440 obstack_sgrow (&table_obstack
, "\\t");
442 obstack_sgrow (&table_obstack
, "\\b");
443 else if (*p
< 040 || *p
>= 0177)
444 obstack_fgrow1 (&table_obstack
, "\\%03o", *p
);
446 obstack_1grow (&table_obstack
, *p
);
449 obstack_sgrow (&table_obstack
, "\", ");
452 /* add a NULL entry to list of tokens */
453 obstack_sgrow (&table_obstack
, "NULL\n};\n");
455 if (!token_table_flag
&& !no_parser_flag
)
456 obstack_sgrow (&table_obstack
, "#endif\n\n");
458 /* Output YYTOKNUM. */
459 if (token_table_flag
)
461 output_short_table (&table_obstack
,
462 "YYTOKNUM[YYLEX] -- Index in YYTNAME corresponding to YYLEX",
463 "yytoknum", user_toknums
,
469 short *values
= XCALLOC (short, nrules
+ 1);
470 for (i
= 0; i
< nrules
+ 1; ++i
)
471 values
[i
] = rule_table
[i
].lhs
;
472 output_short_table (&table_obstack
,
473 "YYR1[YYN] -- Symbol number of symbol that rule YYN derives",
479 obstack_1grow (&table_obstack
, '\n');
482 short_tab
= XMALLOC (short, nrules
+ 1);
483 for (i
= 1; i
< nrules
; i
++)
484 short_tab
[i
] = rule_table
[i
+ 1].rhs
- rule_table
[i
].rhs
- 1;
485 short_tab
[nrules
] = nitems
- rule_table
[nrules
].rhs
- 1;
486 output_short_table (&table_obstack
,
487 "YYR2[YYN] -- Number of symbols composing right hand side of rule YYN",
490 obstack_1grow (&table_obstack
, '\n');
494 XFREE (rule_table
+ 1);
499 output_defines (void)
501 obstack_fgrow1 (&table_obstack
, "\n\n#define\tYYFINAL\t\t%d\n", final_state
);
502 obstack_fgrow1 (&table_obstack
, "#define\tYYFLAG\t\t%d\n", MINSHORT
);
503 obstack_fgrow1 (&table_obstack
, "#define\tYYNTBASE\t%d\n", ntokens
);
507 /*------------------------------------------------------------------.
508 | Decide what to do for each type of token if seen as the lookahead |
509 | token in specified state. The value returned is used as the |
510 | default action (yydefact) for the state. In addition, actrow is |
511 | filled with what to do for each kind of token, index by symbol |
512 | number, with zero meaning do the default action. The value |
513 | MINSHORT, a very negative number, means this situation is an |
514 | error. The parser recognizes this value specially. |
516 | This is where conflicts are resolved. The loop over lookahead |
517 | rules considered lower-numbered rules last, and the last rule |
518 | considered that likes a token gets to handle it. |
519 `------------------------------------------------------------------*/
522 action_row (int state
)
537 int nodefault
= 0; /* set nonzero to inhibit having any default reduction */
539 for (i
= 0; i
< ntokens
; i
++)
544 redp
= state_table
[state
].reductions
;
552 /* loop over all the rules available here which require
554 m
= state_table
[state
].lookaheads
;
555 n
= state_table
[state
+ 1].lookaheads
;
557 for (i
= n
- 1; i
>= m
; i
--)
558 /* and find each token which the rule finds acceptable
560 for (j
= 0; j
< ntokens
; j
++)
561 /* and record this rule as the rule to use if that
563 if (BITISSET (LA (i
), j
))
564 actrow
[j
] = -LAruleno
[i
];
568 /* Now see which tokens are allowed for shifts in this state. For
569 them, record the shift as the thing to do. So shift is preferred
571 shiftp
= state_table
[state
].shifts
;
572 for (i
= 0; i
< shiftp
->nshifts
; i
++)
574 shift_state
= shiftp
->shifts
[i
];
578 symbol
= state_table
[shift_state
].accessing_symbol
;
583 actrow
[symbol
] = shift_state
;
585 /* Do not use any default reduction if there is a shift for
587 if (symbol
== error_token_number
)
591 /* See which tokens are an explicit error in this state (due to
592 %nonassoc). For them, record MINSHORT as the action. */
593 errp
= state_table
[state
].errs
;
599 for (i
= 0; i
< k
; i
++)
601 symbol
= errp
->errs
[i
];
602 actrow
[symbol
] = MINSHORT
;
606 /* Now find the most common reduction and make it the default action
609 if (nreds
>= 1 && !nodefault
)
611 if (state_table
[state
].consistent
)
612 default_rule
= redp
->rules
[0];
616 for (i
= m
; i
< n
; i
++)
621 for (j
= 0; j
< ntokens
; j
++)
623 if (actrow
[j
] == rule
)
634 /* actions which match the default are replaced with zero,
635 which means "use the default" */
639 for (j
= 0; j
< ntokens
; j
++)
641 if (actrow
[j
] == default_rule
)
645 default_rule
= -default_rule
;
650 /* If have no default rule, the default is an error.
651 So replace any action which says "error" with "use default". */
653 if (default_rule
== 0)
654 for (j
= 0; j
< ntokens
; j
++)
656 if (actrow
[j
] == MINSHORT
)
674 for (i
= 0; i
< ntokens
; i
++)
683 froms
[state
] = sp1
= sp
= XCALLOC (short, count
);
684 tos
[state
] = sp2
= XCALLOC (short, count
);
686 for (i
= 0; i
< ntokens
; i
++)
695 tally
[state
] = count
;
696 width
[state
] = sp1
[-1] - sp
[0] + 1;
700 /*------------------------------------------------------------------.
701 | Figure out the actions for the specified state, indexed by |
702 | lookahead token type. |
704 | The YYDEFACT table is output now. The detailed info is saved for |
705 | putting into YYTABLE later. |
706 `------------------------------------------------------------------*/
712 short *yydefact
= XCALLOC (short, nstates
);
714 actrow
= XCALLOC (short, ntokens
);
715 for (i
= 0; i
< nstates
; ++i
)
717 yydefact
[i
] = action_row (i
);
722 output_short_table (&table_obstack
,
723 "YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE\n\
724 doesn't specify something else to do. Zero means the default is an\n\
726 "yydefact", yydefact
,
727 yydefact
[0], 1, nstates
);
728 obstack_1grow (&table_obstack
, '\n');
734 save_column (int symbol
, int default_state
)
743 short begin
= goto_map
[symbol
];
744 short end
= goto_map
[symbol
+ 1];
747 for (i
= begin
; i
< end
; i
++)
749 if (to_state
[i
] != default_state
)
756 symno
= symbol
- ntokens
+ nstates
;
758 froms
[symno
] = sp1
= sp
= XCALLOC (short, count
);
759 tos
[symno
] = sp2
= XCALLOC (short, count
);
761 for (i
= begin
; i
< end
; i
++)
763 if (to_state
[i
] != default_state
)
765 *sp1
++ = from_state
[i
];
766 *sp2
++ = to_state
[i
];
770 tally
[symno
] = count
;
771 width
[symno
] = sp1
[-1] - sp
[0] + 1;
775 default_goto (int symbol
)
783 m
= goto_map
[symbol
];
784 n
= goto_map
[symbol
+ 1];
789 for (i
= 0; i
< nstates
; i
++)
792 for (i
= m
; i
< n
; i
++)
793 state_count
[to_state
[i
]]++;
798 for (i
= 0; i
< nstates
; i
++)
800 if (state_count
[i
] > max
)
802 max
= state_count
[i
];
807 return default_state
;
811 /*-------------------------------------------------------------------.
812 | Figure out what to do after reducing with each rule, depending on |
813 | the saved state from before the beginning of parsing the data that |
814 | matched this rule. |
816 | The YYDEFGOTO table is output now. The detailed info is saved for |
817 | putting into YYTABLE later. |
818 `-------------------------------------------------------------------*/
825 short *yydefgoto
= XMALLOC (short, nsyms
- ntokens
);
826 state_count
= XCALLOC (short, nstates
);
828 for (i
= ntokens
; i
< nsyms
; ++i
)
830 int default_state
= default_goto (i
);
831 save_column (i
, default_state
);
832 yydefgoto
[i
- ntokens
] = default_state
;
835 output_short_table (&table_obstack
, NULL
, "yydefgoto", yydefgoto
,
836 yydefgoto
[0], 1, nsyms
- ntokens
);
843 /* The next few functions decide how to pack the actions and gotos
844 information into yytable. */
855 order
= XCALLOC (short, nvectors
);
858 for (i
= 0; i
< nvectors
; i
++)
866 while (j
>= 0 && (width
[order
[j
]] < w
))
869 while (j
>= 0 && (width
[order
[j
]] == w
) && (tally
[order
[j
]] < t
))
872 for (k
= nentries
- 1; k
> j
; k
--)
873 order
[k
+ 1] = order
[k
];
883 matching_state (int vector
)
900 for (prev
= vector
- 1; prev
>= 0; prev
--)
903 if (width
[j
] != w
|| tally
[j
] != t
)
907 for (k
= 0; match
&& k
< t
; k
++)
909 if (tos
[j
][k
] != tos
[i
][k
] || froms
[j
][k
] != froms
[i
][k
])
922 pack_vector (int vector
)
941 for (j
= lowzero
- from
[0]; j
< MAXTABLE
; j
++)
945 for (k
= 0; ok
&& k
< t
; k
++)
949 fatal (_("maximum table size (%d) exceeded"), MAXTABLE
);
955 for (k
= 0; ok
&& k
< vector
; k
++)
963 for (k
= 0; k
< t
; k
++)
967 check
[loc
] = from
[k
];
970 while (table
[lowzero
] != 0)
980 assert (!"pack_vector");
992 base
= XCALLOC (short, nvectors
);
993 pos
= XCALLOC (short, nentries
);
994 table
= XCALLOC (short, MAXTABLE
);
995 check
= XCALLOC (short, MAXTABLE
);
1000 for (i
= 0; i
< nvectors
; i
++)
1003 for (i
= 0; i
< MAXTABLE
; i
++)
1006 for (i
= 0; i
< nentries
; i
++)
1008 state
= matching_state (i
);
1011 place
= pack_vector (i
);
1013 place
= base
[state
];
1016 base
[order
[i
]] = place
;
1019 for (i
= 0; i
< nvectors
; i
++)
1032 /* the following functions output yytable, yycheck
1033 and the vectors whose elements index the portion starts */
1038 output_short_table (&table_obstack
, NULL
, "yypact", base
,
1039 base
[0], 1, nstates
);
1041 obstack_1grow (&table_obstack
, '\n');
1043 output_short_table (&table_obstack
, NULL
, "yypgoto", base
,
1044 base
[nstates
], nstates
+ 1, nvectors
);
1053 obstack_fgrow1 (&table_obstack
, "\n\n#define\tYYLAST\t\t%d\n\n\n", high
);
1054 output_short_table (&table_obstack
, NULL
, "yytable", table
,
1055 table
[0], 1, high
+ 1);
1063 output_short_table (&table_obstack
, NULL
, "yycheck", check
,
1064 check
[0], 1, high
+ 1);
1068 /* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable
1072 output_actions (void)
1074 nvectors
= nstates
+ nvars
;
1076 froms
= XCALLOC (short *, nvectors
);
1077 tos
= XCALLOC (short *, nvectors
);
1078 tally
= XCALLOC (short, nvectors
);
1079 width
= XCALLOC (short, nvectors
);
1082 LIST_FREE (shifts
, first_shift
);
1083 LIST_FREE (reductions
, first_reduction
);
1088 XFREE (goto_map
+ ntokens
);
1094 obstack_1grow (&table_obstack
, '\n');
1097 obstack_1grow (&table_obstack
, '\n');
1101 /*------------------------------------------.
1102 | Copy the parser code into TABLE_OBSTACK. |
1103 `------------------------------------------*/
1106 output_parser (void)
1111 int actions_dumped
= 0;
1114 obstack_sgrow (&table_obstack
, "#define YYPURE 1\n\n");
1116 /* Loop over lines in the standard parser file. */
1119 if (semantic_parser
)
1120 skeleton
= skeleton_find ("BISON_HAIRY", BISON_HAIRY
);
1122 skeleton
= skeleton_find ("BISON_SIMPLE", BISON_SIMPLE
);
1125 fskel
= xfopen (skeleton
, "r");
1127 /* Set LINE to 2, not 1: `#line LINENUM' -- Here LINENUM is a
1128 decimal integer constant. This specifies that the line number of
1129 the *following* line of input, in its original source file, was
1138 sync_line
, /* #line. */
1139 actions_line
/* %% actions. */
1141 enum line_type_e line_type
= regular_line
;
1145 /* Is this line special? */
1148 /* See if it's a `#line' line. */
1149 if ((c
= getc (fskel
)) == 'l')
1150 if ((c
= getc (fskel
)) == 'i')
1151 if ((c
= getc (fskel
)) == 'n')
1152 if ((c
= getc (fskel
)) == 'e')
1153 line_type
= sync_line
;
1155 obstack_sgrow (&table_obstack
, "#lin");
1157 obstack_sgrow (&table_obstack
, "#li");
1159 obstack_sgrow (&table_obstack
, "#l");
1161 obstack_sgrow (&table_obstack
, "#");
1165 /* See if it's a `%% actions' line. */
1166 if ((c
= getc (fskel
)) == '%')
1167 if ((c
= getc (fskel
)) == ' ')
1168 if ((c
= getc (fskel
)) == 'a')
1169 if ((c
= getc (fskel
)) == 'c')
1170 if ((c
= getc (fskel
)) == 't')
1171 if ((c
= getc (fskel
)) == 'i')
1172 if ((c
= getc (fskel
)) == 'o')
1173 if ((c
= getc (fskel
)) == 'n')
1174 if ((c
= getc (fskel
)) == 's')
1175 line_type
= actions_line
;
1177 obstack_sgrow (&table_obstack
, "%% action");
1179 obstack_sgrow (&table_obstack
, "%% actio");
1181 obstack_sgrow (&table_obstack
, "%% acti");
1183 obstack_sgrow (&table_obstack
, "%% act");
1185 obstack_sgrow (&table_obstack
, "%% ac");
1187 obstack_sgrow (&table_obstack
, "%% a");
1189 obstack_sgrow (&table_obstack
, "%% ");
1191 obstack_sgrow (&table_obstack
, "%%");
1193 obstack_sgrow (&table_obstack
, "%");
1200 obstack_fgrow2 (&table_obstack
, "#line %d %s\n",
1201 line
, quotearg_style (c_quoting_style
, skeleton
));
1203 /* Skip the end of line. */
1204 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1210 size_t size
= obstack_object_size (&action_obstack
);
1213 assert (actions_dumped
== 1);
1214 obstack_grow (&table_obstack
,
1215 obstack_finish (&action_obstack
),
1219 /* Skip the end of line. */
1220 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1225 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1226 obstack_1grow (&table_obstack
, c
);
1231 obstack_1grow (&table_obstack
, c
);
1234 assert (actions_dumped
== 1);
1239 output_program (void)
1244 obstack_fgrow2 (&table_obstack
, "#line %d %s\n",
1245 lineno
, quotearg_style (c_quoting_style
, infile
));
1247 while ((c
= getc (finput
)) != EOF
)
1248 obstack_1grow (&table_obstack
, c
);
1252 /*----------------------------------------------------------.
1253 | Output the parsing tables and the parser code to ftable. |
1254 `----------------------------------------------------------*/
1259 /* output_token_defines(ftable); / * JF put out token defines FIRST */
1261 /* If using a simple parser the definition of YYSTYPE are put into
1263 if (!semantic_parser
)
1265 size_t size
= obstack_object_size (&attrs_obstack
);
1266 obstack_grow (&table_obstack
, obstack_finish (&attrs_obstack
), size
);
1268 reader_output_yylsp (&table_obstack
);
1270 obstack_sgrow (&table_obstack
, "\
1272 # define YYDEBUG 1\n\
1276 if (semantic_parser
)
1277 obstack_fgrow1 (&table_obstack
, "#include %s\n",
1278 quotearg_style (c_quoting_style
, attrsfile
));
1280 if (!no_parser_flag
)
1281 obstack_sgrow (&table_obstack
, "#include <stdio.h>\n\n");
1283 LIST_FREE (core
, first_state
);
1285 output_token_translations ();
1286 /* if (semantic_parser) */
1287 /* This is now unconditional because debugging printouts can use it. */
1290 if (semantic_parser
)
1292 output_rule_data ();
1294 XFREE (state_table
);
1296 if (!no_parser_flag
)