]>
git.saurik.com Git - bison.git/blob - src/output.c
1 /* Output the generated parsing program for bison,
3 Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001 Free Software
6 This file is part of Bison, the GNU Compiler Compiler.
8 Bison is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 Bison is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Bison; see the file COPYING. If not, write to the Free
20 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 /* The parser tables consist of these tables.
25 Starred ones needed only for the semantic parser.
26 Double starred are output only if switches are set.
28 yytranslate = vector mapping yylex's token numbers into bison's token
31 ** yytname = vector of string-names indexed by bison token number
33 ** yytoknum = vector of yylex token numbers corresponding to entries
36 yyrline = vector of line-numbers of all rules. For yydebug printouts.
38 yyrhs = vector of items of all rules.
39 This is exactly what ritems contains. For yydebug and for semantic
42 yyprhs[r] = index in yyrhs of first item for rule r.
44 yyr1[r] = symbol number of symbol that rule r derives.
46 yyr2[r] = number of symbols composing right hand side of rule r.
48 * yystos[s] = the symbol number of the symbol that leads to state s.
50 yydefact[s] = default rule to reduce with in state s,
51 when yytable doesn't specify something else to do.
52 Zero means the default is an error.
54 yydefgoto[i] = default state to go to after a reduction of a rule that
55 generates variable ntokens + i, except when yytable
56 specifies something else to do.
58 yypact[s] = index in yytable of the portion describing state s.
59 The lookahead token's type is used to index that portion
60 to find out what to do.
62 If the value in yytable is positive,
63 we shift the token and go to that state.
65 If the value is negative, it is minus a rule number to reduce by.
67 If the value is zero, the default action from yydefact[s] is used.
69 yypgoto[i] = the index in yytable of the portion describing
70 what to do after reducing a rule that derives variable i + ntokens.
71 This portion is indexed by the parser state number, s,
72 as of before the text for this nonterminal was read.
73 The value from yytable is the state to go to if
74 the corresponding value in yycheck is s.
76 yytable = a vector filled with portions for different uses,
77 found via yypact and yypgoto.
79 yycheck = a vector indexed in parallel with yytable.
80 It indicates, in a roundabout way, the bounds of the
81 portion you are trying to examine.
83 Suppose that the portion of yytable starts at index p
84 and the index to be examined within the portion is i.
85 Then if yycheck[p+i] != i, i is outside the bounds
86 of what is actually allocated, and the default
87 (from yydefact or yydefgoto) should be used.
88 Otherwise, yytable[p+i] should be used.
90 YYFINAL = the state number of the termination state.
91 YYFLAG = most negative short int. Used to flag ??
102 #include "complain.h"
106 #include "conflicts.h"
111 static short **froms
= NULL
;
112 static short **tos
= NULL
;
113 static short *tally
= NULL
;
114 static short *width
= NULL
;
115 static short *actrow
= NULL
;
116 static short *state_count
= NULL
;
117 static short *order
= NULL
;
118 static short *base
= NULL
;
119 static short *pos
= NULL
;
120 static short *table
= NULL
;
121 static short *check
= NULL
;
128 output_short_or_char_table (struct obstack
*oout
,
131 const char *table_name
,
139 obstack_fgrow1 (oout
, "/* %s. */\n", comment
);
141 obstack_fgrow3 (oout
, "static const %s %s[] =\n{\n %6d",
142 type
, table_name
, first_value
);
145 for (i
= begin
; i
< end
; i
++)
147 obstack_1grow (oout
, ',');
151 obstack_sgrow (oout
, "\n ");
159 obstack_fgrow1 (oout
, "%6d", short_table
[i
]);
162 obstack_sgrow (oout
, "\n};\n");
167 output_short_table (struct obstack
*oout
,
169 const char *table_name
,
174 output_short_or_char_table (oout
, comment
, "short", table_name
, short_table
,
175 first_value
, begin
, end
);
179 /*--------------------------------------------------------------.
180 | output_headers -- Output constant strings to the beginning of |
182 `--------------------------------------------------------------*/
184 /* Don't put the `%s' insides quotes, since it quotearg puts them. */
189 extern int yyerror;\n\
190 extern int yycost;\n\
191 extern char * yymsg;\n\
192 extern YYSTYPE yyval;\n\
194 yyguard(n, yyvsp, yylsp)\n\
196 register YYSTYPE *yyvsp;\n\
197 register YYLTYPE *yylsp;\n\
208 extern YYSTYPE yyval;\n\
209 extern int yychar;\n\
211 yyaction(n, yyvsp, yylsp)\n\
213 register YYSTYPE *yyvsp;\n\
214 register YYLTYPE *yylsp;\n\
219 #define ACTSTR_SIMPLE "\n switch (yyn) {\n"
222 output_headers (void)
224 char *attrsfile_quoted
= 0;
228 /* FIXME: This is *buggy*. ATTRSFILE is not computed yet, since
229 we are waiting for the full input file to have been read to
230 be sure of the output file name. So basically, here, a SEGV
231 is guaranteed. OTOH, currently semantic parsers are not
233 attrsfile_quoted
= quotearg_style (c_quoting_style
, attrsfile
);
234 obstack_fgrow1 (&guard_obstack
, GUARDSTR
, attrsfile_quoted
);
241 obstack_fgrow1 (&action_obstack
, ACTSTR
, attrsfile_quoted
);
243 obstack_sgrow (&action_obstack
, ACTSTR_SIMPLE
);
245 /* Rename certain symbols if -p was specified. */
246 if (spec_name_prefix
)
248 obstack_fgrow1 (&table_obstack
,
249 "#define yyparse %sparse\n", spec_name_prefix
);
250 obstack_fgrow1 (&table_obstack
,
251 "#define yylex %slex\n", spec_name_prefix
);
252 obstack_fgrow1 (&table_obstack
,
253 "#define yyerror %serror\n", spec_name_prefix
);
254 obstack_fgrow1 (&table_obstack
,
255 "#define yylval %slval\n", spec_name_prefix
);
256 obstack_fgrow1 (&table_obstack
,
257 "#define yychar %schar\n", spec_name_prefix
);
258 obstack_fgrow1 (&table_obstack
,
259 "#define yydebug %sdebug\n", spec_name_prefix
);
260 obstack_fgrow1 (&table_obstack
,
261 "#define yynerrs %snerrs\n", spec_name_prefix
);
266 /*-------------------------------------------------------.
267 | Output constant strings to the ends of certain files. |
268 `-------------------------------------------------------*/
271 output_trailers (void)
274 obstack_sgrow (&guard_obstack
, "\n }\n}\n");
276 obstack_1grow (&action_obstack
, '\n');
282 obstack_sgrow (&action_obstack
, " }\n");
284 obstack_sgrow (&action_obstack
, "}\n");
290 output_token_translations (void)
292 obstack_sgrow (&table_obstack
, "\
294 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */\n");
296 obstack_fgrow2 (&table_obstack
,
297 "#define YYTRANSLATE(x) ((unsigned)(x) <= %d ? yytranslate[x] : %d)\
300 max_user_token_number
, nsyms
);
302 output_short_or_char_table (&table_obstack
,
303 "YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX",
304 ntokens
< 127 ? "char" : "short",
305 "yytranslate", token_translations
,
306 0, 1, max_user_token_number
+ 1);
308 XFREE (token_translations
);
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\n");
323 short *values
= XCALLOC (short, nrules
+ 1);
324 for (i
= 0; i
< nrules
+ 1; ++i
)
325 values
[i
] = rule_table
[i
].rhs
;
326 output_short_table (&table_obstack
, NULL
, "yyprhs", values
,
332 size_t yyrhs_size
= 1;
336 for (sp
= ritem
+ 1; *sp
; sp
++)
338 yyrhs
= XMALLOC (short, yyrhs_size
);
340 for (sp
= ritem
+ 1, i
= 1; *sp
; ++sp
, ++i
)
341 yyrhs
[i
] = *sp
> 0 ? *sp
: 0;
343 output_short_table (&table_obstack
, NULL
, "yyrhs", yyrhs
,
344 ritem
[0], 1, yyrhs_size
);
348 if (!semantic_parser
&& !no_parser_flag
)
349 obstack_sgrow (&table_obstack
, "\n#endif\n");
357 short *values
= (short *) alloca (sizeof (short) * nstates
);
358 for (i
= 0; i
< nstates
; ++i
)
359 values
[i
] = state_table
[i
].accessing_symbol
;
360 output_short_table (&table_obstack
,
361 "YYSTOS[STATE] -- Accessing symbol to the STATE",
368 output_rule_data (void)
372 short *short_tab
= NULL
;
374 obstack_sgrow (&table_obstack
, "\n\
378 short *values
= XCALLOC (short, nrules
+ 1);
379 for (i
= 0; i
< nrules
+ 1; ++i
)
380 values
[i
] = rule_table
[i
].line
;
381 output_short_table (&table_obstack
,
382 "YYRLINE[YYN] -- source line where rule number YYN was defined",
388 obstack_sgrow (&table_obstack
, "#endif\n\n");
390 if (token_table_flag
|| no_parser_flag
)
392 obstack_fgrow1 (&table_obstack
, "#define YYNTOKENS %d\n", ntokens
);
393 obstack_fgrow1 (&table_obstack
, "#define YYNNTS %d\n", nvars
);
394 obstack_fgrow1 (&table_obstack
, "#define YYNRULES %d\n", nrules
);
395 obstack_fgrow1 (&table_obstack
, "#define YYNSTATES %d\n", nstates
);
396 obstack_fgrow1 (&table_obstack
, "#define YYMAXUTOK %d\n\n",
397 max_user_token_number
);
400 /* Output the table of symbol names. */
401 if (!token_table_flag
&& !no_parser_flag
)
402 obstack_sgrow (&table_obstack
,
403 "\n#if (YYDEBUG) || defined YYERROR_VERBOSE\n\n");
404 obstack_sgrow (&table_obstack
, "\
405 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */\n");
406 obstack_sgrow (&table_obstack
,
407 "static const char *const yytname[] =\n{\n ");
410 for (i
= 0; i
< nsyms
; i
++)
411 /* this used to be i<=nsyms, but that output a final "" symbol
412 almost by accident */
414 /* Width of the next token, including the two quotes, the coma
419 for (p
= tags
[i
]; p
&& *p
; p
++)
420 if (*p
== '"' || *p
== '\\' || *p
== '\n' || *p
== '\t'
423 else if (*p
< 040 || *p
>= 0177)
428 if (j
+ strsize
> 75)
430 obstack_sgrow (&table_obstack
, "\n ");
434 obstack_1grow (&table_obstack
, '\"');
435 for (p
= tags
[i
]; p
&& *p
; p
++)
437 if (*p
== '"' || *p
== '\\')
438 obstack_fgrow1 (&table_obstack
, "\\%c", *p
);
440 obstack_sgrow (&table_obstack
, "\\n");
442 obstack_sgrow (&table_obstack
, "\\t");
444 obstack_sgrow (&table_obstack
, "\\b");
445 else if (*p
< 040 || *p
>= 0177)
446 obstack_fgrow1 (&table_obstack
, "\\%03o", *p
);
448 obstack_1grow (&table_obstack
, *p
);
451 obstack_sgrow (&table_obstack
, "\", ");
454 /* add a NULL entry to list of tokens */
455 obstack_sgrow (&table_obstack
, "NULL\n};\n");
457 if (!token_table_flag
&& !no_parser_flag
)
458 obstack_sgrow (&table_obstack
, "#endif\n\n");
460 /* Output YYTOKNUM. */
461 if (token_table_flag
)
463 output_short_table (&table_obstack
,
464 "YYTOKNUM[YYLEX] -- Index in YYTNAME corresponding to YYLEX",
465 "yytoknum", user_toknums
,
471 short *values
= XCALLOC (short, nrules
+ 1);
472 for (i
= 0; i
< nrules
+ 1; ++i
)
473 values
[i
] = rule_table
[i
].lhs
;
474 output_short_table (&table_obstack
,
475 "YYR1[YYN] -- Symbol number of symbol that rule YYN derives",
481 obstack_1grow (&table_obstack
, '\n');
484 short_tab
= XMALLOC (short, nrules
+ 1);
485 for (i
= 1; i
< nrules
; i
++)
486 short_tab
[i
] = rule_table
[i
+ 1].rhs
- rule_table
[i
].rhs
- 1;
487 short_tab
[nrules
] = nitems
- rule_table
[nrules
].rhs
- 1;
488 output_short_table (&table_obstack
,
489 "YYR2[YYN] -- Number of symbols composing right hand side of rule YYN",
492 obstack_1grow (&table_obstack
, '\n');
496 XFREE (rule_table
+ 1);
501 output_defines (void)
503 obstack_fgrow1 (&table_obstack
, "\n\n#define\tYYFINAL\t\t%d\n", final_state
);
504 obstack_fgrow1 (&table_obstack
, "#define\tYYFLAG\t\t%d\n", MINSHORT
);
505 obstack_fgrow1 (&table_obstack
, "#define\tYYNTBASE\t%d\n", ntokens
);
509 /*------------------------------------------------------------------.
510 | Decide what to do for each type of token if seen as the lookahead |
511 | token in specified state. The value returned is used as the |
512 | default action (yydefact) for the state. In addition, actrow is |
513 | filled with what to do for each kind of token, index by symbol |
514 | number, with zero meaning do the default action. The value |
515 | MINSHORT, a very negative number, means this situation is an |
516 | error. The parser recognizes this value specially. |
518 | This is where conflicts are resolved. The loop over lookahead |
519 | rules considered lower-numbered rules last, and the last rule |
520 | considered that likes a token gets to handle it. |
521 `------------------------------------------------------------------*/
524 action_row (int state
)
539 int nodefault
= 0; /* set nonzero to inhibit having any default reduction */
541 for (i
= 0; i
< ntokens
; i
++)
546 redp
= state_table
[state
].reductions
;
554 /* loop over all the rules available here which require
556 m
= state_table
[state
].lookaheads
;
557 n
= state_table
[state
+ 1].lookaheads
;
559 for (i
= n
- 1; i
>= m
; i
--)
560 /* and find each token which the rule finds acceptable
562 for (j
= 0; j
< ntokens
; j
++)
563 /* and record this rule as the rule to use if that
565 if (BITISSET (LA (i
), j
))
566 actrow
[j
] = -LAruleno
[i
];
570 /* Now see which tokens are allowed for shifts in this state. For
571 them, record the shift as the thing to do. So shift is preferred
573 shiftp
= state_table
[state
].shifts
;
574 for (i
= 0; i
< shiftp
->nshifts
; i
++)
576 shift_state
= shiftp
->shifts
[i
];
580 symbol
= state_table
[shift_state
].accessing_symbol
;
585 actrow
[symbol
] = shift_state
;
587 /* Do not use any default reduction if there is a shift for
589 if (symbol
== error_token_number
)
593 /* See which tokens are an explicit error in this state (due to
594 %nonassoc). For them, record MINSHORT as the action. */
595 errp
= state_table
[state
].errs
;
601 for (i
= 0; i
< k
; i
++)
603 symbol
= errp
->errs
[i
];
604 actrow
[symbol
] = MINSHORT
;
608 /* Now find the most common reduction and make it the default action
611 if (nreds
>= 1 && !nodefault
)
613 if (state_table
[state
].consistent
)
614 default_rule
= redp
->rules
[0];
618 for (i
= m
; i
< n
; i
++)
623 for (j
= 0; j
< ntokens
; j
++)
625 if (actrow
[j
] == rule
)
636 /* actions which match the default are replaced with zero,
637 which means "use the default" */
641 for (j
= 0; j
< ntokens
; j
++)
643 if (actrow
[j
] == default_rule
)
647 default_rule
= -default_rule
;
652 /* If have no default rule, the default is an error.
653 So replace any action which says "error" with "use default". */
655 if (default_rule
== 0)
656 for (j
= 0; j
< ntokens
; j
++)
658 if (actrow
[j
] == MINSHORT
)
676 for (i
= 0; i
< ntokens
; i
++)
685 froms
[state
] = sp1
= sp
= XCALLOC (short, count
);
686 tos
[state
] = sp2
= XCALLOC (short, count
);
688 for (i
= 0; i
< ntokens
; i
++)
697 tally
[state
] = count
;
698 width
[state
] = sp1
[-1] - sp
[0] + 1;
702 /*------------------------------------------------------------------.
703 | Figure out the actions for the specified state, indexed by |
704 | lookahead token type. |
706 | The YYDEFACT table is output now. The detailed info is saved for |
707 | putting into YYTABLE later. |
708 `------------------------------------------------------------------*/
714 short *yydefact
= XCALLOC (short, nstates
);
716 actrow
= XCALLOC (short, ntokens
);
717 for (i
= 0; i
< nstates
; ++i
)
719 yydefact
[i
] = action_row (i
);
724 output_short_table (&table_obstack
,
725 "YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE\n\
726 doesn't specify something else to do. Zero means the default is an\n\
728 "yydefact", yydefact
,
729 yydefact
[0], 1, nstates
);
730 obstack_1grow (&table_obstack
, '\n');
736 save_column (int symbol
, int default_state
)
745 short begin
= goto_map
[symbol
];
746 short end
= goto_map
[symbol
+ 1];
749 for (i
= begin
; i
< end
; i
++)
751 if (to_state
[i
] != default_state
)
758 symno
= symbol
- ntokens
+ nstates
;
760 froms
[symno
] = sp1
= sp
= XCALLOC (short, count
);
761 tos
[symno
] = sp2
= XCALLOC (short, count
);
763 for (i
= begin
; i
< end
; i
++)
765 if (to_state
[i
] != default_state
)
767 *sp1
++ = from_state
[i
];
768 *sp2
++ = to_state
[i
];
772 tally
[symno
] = count
;
773 width
[symno
] = sp1
[-1] - sp
[0] + 1;
777 default_goto (int symbol
)
785 m
= goto_map
[symbol
];
786 n
= goto_map
[symbol
+ 1];
791 for (i
= 0; i
< nstates
; i
++)
794 for (i
= m
; i
< n
; i
++)
795 state_count
[to_state
[i
]]++;
800 for (i
= 0; i
< nstates
; i
++)
802 if (state_count
[i
] > max
)
804 max
= state_count
[i
];
809 return default_state
;
813 /*-------------------------------------------------------------------.
814 | Figure out what to do after reducing with each rule, depending on |
815 | the saved state from before the beginning of parsing the data that |
816 | matched this rule. |
818 | The YYDEFGOTO table is output now. The detailed info is saved for |
819 | putting into YYTABLE later. |
820 `-------------------------------------------------------------------*/
827 short *yydefgoto
= XMALLOC (short, nsyms
- ntokens
);
828 state_count
= XCALLOC (short, nstates
);
830 for (i
= ntokens
; i
< nsyms
; ++i
)
832 int default_state
= default_goto (i
);
833 save_column (i
, default_state
);
834 yydefgoto
[i
- ntokens
] = default_state
;
837 output_short_table (&table_obstack
, NULL
, "yydefgoto", yydefgoto
,
838 yydefgoto
[0], 1, nsyms
- ntokens
);
845 /* The next few functions decide how to pack the actions and gotos
846 information into yytable. */
857 order
= XCALLOC (short, nvectors
);
860 for (i
= 0; i
< nvectors
; i
++)
868 while (j
>= 0 && (width
[order
[j
]] < w
))
871 while (j
>= 0 && (width
[order
[j
]] == w
) && (tally
[order
[j
]] < t
))
874 for (k
= nentries
- 1; k
> j
; k
--)
875 order
[k
+ 1] = order
[k
];
885 matching_state (int vector
)
902 for (prev
= vector
- 1; prev
>= 0; prev
--)
905 if (width
[j
] != w
|| tally
[j
] != t
)
909 for (k
= 0; match
&& k
< t
; k
++)
911 if (tos
[j
][k
] != tos
[i
][k
] || froms
[j
][k
] != froms
[i
][k
])
924 pack_vector (int vector
)
943 for (j
= lowzero
- from
[0]; j
< MAXTABLE
; j
++)
947 for (k
= 0; ok
&& k
< t
; k
++)
951 fatal (_("maximum table size (%d) exceeded"), MAXTABLE
);
957 for (k
= 0; ok
&& k
< vector
; k
++)
965 for (k
= 0; k
< t
; k
++)
969 check
[loc
] = from
[k
];
972 while (table
[lowzero
] != 0)
981 #define pack_vector_succeeded 0
982 assert (pack_vector_succeeded
);
994 base
= XCALLOC (short, nvectors
);
995 pos
= XCALLOC (short, nentries
);
996 table
= XCALLOC (short, MAXTABLE
);
997 check
= XCALLOC (short, MAXTABLE
);
1002 for (i
= 0; i
< nvectors
; i
++)
1005 for (i
= 0; i
< MAXTABLE
; i
++)
1008 for (i
= 0; i
< nentries
; i
++)
1010 state
= matching_state (i
);
1013 place
= pack_vector (i
);
1015 place
= base
[state
];
1018 base
[order
[i
]] = place
;
1021 for (i
= 0; i
< nvectors
; i
++)
1034 /* the following functions output yytable, yycheck
1035 and the vectors whose elements index the portion starts */
1040 output_short_table (&table_obstack
, NULL
, "yypact", base
,
1041 base
[0], 1, nstates
);
1043 obstack_1grow (&table_obstack
, '\n');
1045 output_short_table (&table_obstack
, NULL
, "yypgoto", base
,
1046 base
[nstates
], nstates
+ 1, nvectors
);
1055 obstack_fgrow1 (&table_obstack
, "\n\n#define\tYYLAST\t\t%d\n\n\n", high
);
1056 output_short_table (&table_obstack
, NULL
, "yytable", table
,
1057 table
[0], 1, high
+ 1);
1065 output_short_table (&table_obstack
, NULL
, "yycheck", check
,
1066 check
[0], 1, high
+ 1);
1070 /* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable
1074 output_actions (void)
1076 nvectors
= nstates
+ nvars
;
1078 froms
= XCALLOC (short *, nvectors
);
1079 tos
= XCALLOC (short *, nvectors
);
1080 tally
= XCALLOC (short, nvectors
);
1081 width
= XCALLOC (short, nvectors
);
1084 LIST_FREE (shifts
, first_shift
);
1085 LIST_FREE (reductions
, first_reduction
);
1090 XFREE (goto_map
+ ntokens
);
1096 obstack_1grow (&table_obstack
, '\n');
1099 obstack_1grow (&table_obstack
, '\n');
1103 /*------------------------------------------.
1104 | Copy the parser code into TABLE_OBSTACK. |
1105 `------------------------------------------*/
1108 output_parser (void)
1113 int actions_dumped
= 0;
1116 obstack_sgrow (&table_obstack
, "#define YYPURE 1\n\n");
1118 /* Loop over lines in the standard parser file. */
1121 if (semantic_parser
)
1122 skeleton
= skeleton_find ("BISON_HAIRY", BISON_HAIRY
);
1124 skeleton
= skeleton_find ("BISON_SIMPLE", BISON_SIMPLE
);
1127 fskel
= xfopen (skeleton
, "r");
1129 /* Set LINE to 2, not 1: `#line LINENUM' -- Here LINENUM is a
1130 decimal integer constant. This specifies that the line number of
1131 the *following* line of input, in its original source file, was
1140 sync_line
, /* #line. */
1141 actions_line
/* %% actions. */
1143 enum line_type_e line_type
= regular_line
;
1147 /* Is this line special? */
1150 /* See if it's a `#line' line. */
1151 if ((c
= getc (fskel
)) == 'l')
1152 if ((c
= getc (fskel
)) == 'i')
1153 if ((c
= getc (fskel
)) == 'n')
1154 if ((c
= getc (fskel
)) == 'e')
1155 line_type
= sync_line
;
1157 obstack_sgrow (&table_obstack
, "#lin");
1159 obstack_sgrow (&table_obstack
, "#li");
1161 obstack_sgrow (&table_obstack
, "#l");
1163 obstack_sgrow (&table_obstack
, "#");
1167 /* See if it's a `%% actions' line. */
1168 if ((c
= getc (fskel
)) == '%')
1169 if ((c
= getc (fskel
)) == ' ')
1170 if ((c
= getc (fskel
)) == 'a')
1171 if ((c
= getc (fskel
)) == 'c')
1172 if ((c
= getc (fskel
)) == 't')
1173 if ((c
= getc (fskel
)) == 'i')
1174 if ((c
= getc (fskel
)) == 'o')
1175 if ((c
= getc (fskel
)) == 'n')
1176 if ((c
= getc (fskel
)) == 's')
1177 line_type
= actions_line
;
1179 obstack_sgrow (&table_obstack
, "%% action");
1181 obstack_sgrow (&table_obstack
, "%% actio");
1183 obstack_sgrow (&table_obstack
, "%% acti");
1185 obstack_sgrow (&table_obstack
, "%% act");
1187 obstack_sgrow (&table_obstack
, "%% ac");
1189 obstack_sgrow (&table_obstack
, "%% a");
1191 obstack_sgrow (&table_obstack
, "%% ");
1193 obstack_sgrow (&table_obstack
, "%%");
1195 obstack_sgrow (&table_obstack
, "%");
1202 obstack_fgrow2 (&table_obstack
, "#line %d %s\n",
1203 line
, quotearg_style (c_quoting_style
, skeleton
));
1205 /* Skip the end of line. */
1206 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1212 size_t size
= obstack_object_size (&action_obstack
);
1215 assert (actions_dumped
== 1);
1216 obstack_grow (&table_obstack
,
1217 obstack_finish (&action_obstack
),
1221 /* Skip the end of line. */
1222 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1227 for (; c
!= '\n' && c
!= EOF
; c
= getc (fskel
))
1228 obstack_1grow (&table_obstack
, c
);
1233 obstack_1grow (&table_obstack
, c
);
1236 assert (actions_dumped
== 1);
1241 output_program (void)
1246 obstack_fgrow2 (&table_obstack
, "#line %d %s\n",
1247 lineno
, quotearg_style (c_quoting_style
, infile
));
1249 while ((c
= getc (finput
)) != EOF
)
1250 obstack_1grow (&table_obstack
, c
);
1254 /*----------------------------------------------------------.
1255 | Output the parsing tables and the parser code to ftable. |
1256 `----------------------------------------------------------*/
1261 /* output_token_defines(ftable); / * JF put out token defines FIRST */
1263 /* If using a simple parser the definition of YYSTYPE are put into
1265 if (!semantic_parser
)
1267 size_t size
= obstack_object_size (&attrs_obstack
);
1268 obstack_grow (&table_obstack
, obstack_finish (&attrs_obstack
), size
);
1270 reader_output_yylsp (&table_obstack
);
1271 obstack_fgrow1 (&table_obstack
, "\
1273 # define YYDEBUG %d\n\
1277 if (semantic_parser
)
1278 obstack_fgrow1 (&table_obstack
, "#include %s\n",
1279 quotearg_style (c_quoting_style
, attrsfile
));
1281 LIST_FREE (core
, first_state
);
1283 output_token_translations ();
1284 /* if (semantic_parser) */
1285 /* This is now unconditional because debugging printouts can use it. */
1288 if (semantic_parser
)
1290 output_rule_data ();
1292 XFREE (state_table
);
1294 if (!no_parser_flag
)