]> git.saurik.com Git - bison.git/blob - src/output.c
regen
[bison.git] / src / output.c
1 /* Output the generated parsing program for Bison.
2
3 Copyright (C) 1984, 1986, 1989, 1992, 2000-2012 Free Software
4 Foundation, Inc.
5
6 This file is part of Bison, the GNU Compiler Compiler.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21 #include <config.h>
22 #include "system.h"
23
24 #include <concat-filename.h>
25 #include <configmake.h>
26 #include <filename.h>
27 #include <get-errno.h>
28 #include <quotearg.h>
29 #include <spawn-pipe.h>
30 #include <timevar.h>
31 #include <wait-process.h>
32
33 #include "complain.h"
34 #include "files.h"
35 #include "getargs.h"
36 #include "gram.h"
37 #include "muscle-tab.h"
38 #include "output.h"
39 #include "reader.h"
40 #include "scan-code.h" /* max_left_semantic_context */
41 #include "scan-skel.h"
42 #include "symtab.h"
43 #include "tables.h"
44
45 static struct obstack format_obstack;
46
47
48 /*-------------------------------------------------------------------.
49 | Create a function NAME which associates to the muscle NAME the |
50 | result of formatting the FIRST and then TABLE_DATA[BEGIN..END[ (of |
51 | TYPE), and to the muscle NAME_max, the max value of the |
52 | TABLE_DATA. |
53 `-------------------------------------------------------------------*/
54
55
56 #define GENERATE_MUSCLE_INSERT_TABLE(Name, Type) \
57 \
58 static void \
59 Name (char const *name, \
60 Type *table_data, \
61 Type first, \
62 int begin, \
63 int end) \
64 { \
65 Type min = first; \
66 Type max = first; \
67 long int lmin; \
68 long int lmax; \
69 int i; \
70 int j = 1; \
71 \
72 obstack_fgrow1 (&format_obstack, "%6d", first); \
73 for (i = begin; i < end; ++i) \
74 { \
75 obstack_1grow (&format_obstack, ','); \
76 if (j >= 10) \
77 { \
78 obstack_sgrow (&format_obstack, "\n "); \
79 j = 1; \
80 } \
81 else \
82 ++j; \
83 obstack_fgrow1 (&format_obstack, "%6d", table_data[i]); \
84 if (table_data[i] < min) \
85 min = table_data[i]; \
86 if (max < table_data[i]) \
87 max = table_data[i]; \
88 } \
89 obstack_1grow (&format_obstack, 0); \
90 muscle_insert (name, obstack_finish (&format_obstack)); \
91 \
92 lmin = min; \
93 lmax = max; \
94 /* Build `NAME_min' and `NAME_max' in the obstack. */ \
95 obstack_fgrow1 (&format_obstack, "%s_min", name); \
96 obstack_1grow (&format_obstack, 0); \
97 MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
98 obstack_fgrow1 (&format_obstack, "%s_max", name); \
99 obstack_1grow (&format_obstack, 0); \
100 MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
101 }
102
103 GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_unsigned_int_table, unsigned int)
104 GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_int_table, int)
105 GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_base_table, base_number)
106 GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_rule_number_table, rule_number)
107 GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_symbol_number_table, symbol_number)
108 GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number)
109
110
111 /*--------------------------------------------------------------------.
112 | Print to OUT a representation of STRING escaped both for C and M4. |
113 `--------------------------------------------------------------------*/
114
115 static void
116 escaped_output (FILE *out, char const *string)
117 {
118 char const *p;
119 fprintf (out, "[[");
120
121 for (p = quotearg_style (c_quoting_style, string); *p; p++)
122 switch (*p)
123 {
124 case '$': fputs ("$][", out); break;
125 case '@': fputs ("@@", out); break;
126 case '[': fputs ("@{", out); break;
127 case ']': fputs ("@}", out); break;
128 default: fputc (*p, out); break;
129 }
130
131 fprintf (out, "]]");
132 }
133
134
135 /*------------------------------------------------------------------.
136 | Prepare the muscles related to the symbols: translate, tname, and |
137 | toknum. |
138 `------------------------------------------------------------------*/
139
140 static void
141 prepare_symbols (void)
142 {
143 MUSCLE_INSERT_INT ("tokens_number", ntokens);
144 MUSCLE_INSERT_INT ("nterms_number", nvars);
145 MUSCLE_INSERT_INT ("symbols_number", nsyms);
146 MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
147 MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);
148
149 muscle_insert_symbol_number_table ("translate",
150 token_translations,
151 token_translations[0],
152 1, max_user_token_number + 1);
153
154 /* tname -- token names. */
155 {
156 int i;
157 /* We assume that the table will be output starting at column 2. */
158 int j = 2;
159 struct quoting_options *qo = clone_quoting_options (0);
160 set_quoting_style (qo, c_quoting_style);
161 set_quoting_flags (qo, QA_SPLIT_TRIGRAPHS);
162 for (i = 0; i < nsyms; i++)
163 {
164 char *cp = quotearg_alloc (symbols[i]->tag, -1, qo);
165 /* Width of the next token, including the two quotes, the
166 comma and the space. */
167 int width = strlen (cp) + 2;
168
169 if (j + width > 75)
170 {
171 obstack_sgrow (&format_obstack, "\n ");
172 j = 1;
173 }
174
175 if (i)
176 obstack_1grow (&format_obstack, ' ');
177 MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
178 free (cp);
179 obstack_1grow (&format_obstack, ',');
180 j += width;
181 }
182 free (qo);
183 obstack_sgrow (&format_obstack, " ]b4_null[");
184
185 /* Finish table and store. */
186 obstack_1grow (&format_obstack, 0);
187 muscle_insert ("tname", obstack_finish (&format_obstack));
188 }
189
190 /* Output YYTOKNUM. */
191 {
192 int i;
193 int *values = xnmalloc (ntokens, sizeof *values);
194 for (i = 0; i < ntokens; ++i)
195 values[i] = symbols[i]->user_token_number;
196 muscle_insert_int_table ("toknum", values,
197 values[0], 1, ntokens);
198 free (values);
199 }
200 }
201
202
203 /*----------------------------------------------------------------.
204 | Prepare the muscles related to the rules: r1, r2, rline, dprec, |
205 | merger, immediate. |
206 `----------------------------------------------------------------*/
207
208 static void
209 prepare_rules (void)
210 {
211 unsigned int *rline = xnmalloc (nrules, sizeof *rline);
212 symbol_number *r1 = xnmalloc (nrules, sizeof *r1);
213 unsigned int *r2 = xnmalloc (nrules, sizeof *r2);
214 int *dprec = xnmalloc (nrules, sizeof *dprec);
215 int *merger = xnmalloc (nrules, sizeof *merger);
216 int *immediate = xnmalloc (nrules, sizeof *immediate);
217
218 rule_number r;
219 for (r = 0; r < nrules; ++r)
220 {
221 /* LHS of the rule R. */
222 r1[r] = rules[r].lhs->number;
223 /* Length of rule R's RHS. */
224 r2[r] = rule_rhs_length(&rules[r]);
225 /* Line where rule was defined. */
226 rline[r] = rules[r].location.start.line;
227 /* Dynamic precedence (GLR). */
228 dprec[r] = rules[r].dprec;
229 /* Merger-function index (GLR). */
230 merger[r] = rules[r].merger;
231 /* Immediate reduction flags (GLR). */
232 immediate[r] = rules[r].is_predicate;
233 }
234
235 muscle_insert_unsigned_int_table ("rline", rline, 0, 0, nrules);
236 muscle_insert_symbol_number_table ("r1", r1, 0, 0, nrules);
237 muscle_insert_unsigned_int_table ("r2", r2, 0, 0, nrules);
238 muscle_insert_int_table ("dprec", dprec, 0, 0, nrules);
239 muscle_insert_int_table ("merger", merger, 0, 0, nrules);
240 muscle_insert_int_table ("immediate", immediate, 0, 0, nrules);
241
242 MUSCLE_INSERT_INT ("rules_number", nrules);
243 MUSCLE_INSERT_INT ("max_left_semantic_context", max_left_semantic_context);
244
245 free (rline);
246 free (r1);
247 free (r2);
248 free (dprec);
249 free (merger);
250 free (immediate);
251 }
252
253 /*--------------------------------------------.
254 | Prepare the muscles related to the states. |
255 `--------------------------------------------*/
256
257 static void
258 prepare_states (void)
259 {
260 state_number i;
261 symbol_number *values = xnmalloc (nstates, sizeof *values);
262 for (i = 0; i < nstates; ++i)
263 values[i] = states[i]->accessing_symbol;
264 muscle_insert_symbol_number_table ("stos", values,
265 0, 1, nstates);
266 free (values);
267
268 MUSCLE_INSERT_INT ("last", high);
269 MUSCLE_INSERT_INT ("final_state_number", final_state->number);
270 MUSCLE_INSERT_INT ("states_number", nstates);
271 }
272
273
274 /*-------------------------------------------------------.
275 | Compare two symbols by type-name, and then by number. |
276 `-------------------------------------------------------*/
277
278 static int
279 symbol_type_name_cmp (const symbol **lhs, const symbol **rhs)
280 {
281 int res = UNIQSTR_CMP((*lhs)->type_name, (*rhs)->type_name);
282 if (res)
283 return res;
284 return (*lhs)->number - (*rhs)->number;
285 }
286
287
288 /*----------------------------------------------------------------.
289 | Return a (malloc'ed) table of the symbols sorted by type-name. |
290 `----------------------------------------------------------------*/
291
292 static symbol **
293 symbols_by_type_name (void)
294 {
295 typedef int (*qcmp_type) (const void *, const void *);
296 symbol **res = xmemdup (symbols, nsyms * sizeof *res);
297 qsort (res, nsyms, sizeof *res, (qcmp_type) &symbol_type_name_cmp);
298 return res;
299 }
300
301
302 /*------------------------------------------------------------------.
303 | Define b4_type_names, which is a list of (lists of the numbers of |
304 | symbols with same type-name). |
305 `------------------------------------------------------------------*/
306
307 static void
308 type_names_output (FILE *out)
309 {
310 int i;
311 symbol **syms = symbols_by_type_name ();
312 fputs ("m4_define([b4_type_names],\n[", out);
313 for (i = 0; i < nsyms; /* nothing */)
314 {
315 // The index of the first symbol of the current type-name.
316 int i0 = i;
317 fputs (i ? ",\n[" : "[", out);
318 for (; i < nsyms && syms[i]->type_name == syms[i0]->type_name; ++i)
319 fprintf (out, "%s%d", i != i0 ? ", " : "", syms[i]->number);
320 fputs ("]", out);
321 }
322 fputs ("])\n\n", out);
323 free (syms);
324 }
325
326
327 /*-------------------------------------.
328 | The list of all the symbol numbers. |
329 `-------------------------------------*/
330
331 static void
332 symbol_numbers_output (FILE *out)
333 {
334 int i;
335 fputs ("m4_define([b4_symbol_numbers],\n[", out);
336 for (i = 0; i < nsyms; ++i)
337 fprintf (out, "%s[%d]", i ? ", " : "", i);
338 fputs ("])\n\n", out);
339 }
340
341
342 /*---------------------------------.
343 | Output the user actions to OUT. |
344 `---------------------------------*/
345
346 static void
347 user_actions_output (FILE *out)
348 {
349 rule_number r;
350
351 fputs ("m4_define([b4_actions], \n[", out);
352 for (r = 0; r < nrules; ++r)
353 if (rules[r].action)
354 {
355 fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ",
356 rules[r].is_predicate ? "predicate_" : "",
357 r + 1, rules[r].action_location.start.line);
358 escaped_output (out, rules[r].action_location.start.file);
359 fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
360 }
361 fputs ("])\n\n", out);
362 }
363
364 /*------------------------------------.
365 | Output the merge functions to OUT. |
366 `------------------------------------*/
367
368 static void
369 merger_output (FILE *out)
370 {
371 int n;
372 merger_list* p;
373
374 fputs ("m4_define([b4_mergers], \n[[", out);
375 for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next)
376 {
377 if (p->type[0] == '\0')
378 fprintf (out, " case %d: *yy0 = %s (*yy0, *yy1); break;\n",
379 n, p->name);
380 else
381 fprintf (out, " case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
382 n, p->type, p->name);
383 }
384 fputs ("]])\n\n", out);
385 }
386
387
388 /*---------------------------------------------.
389 | Prepare the muscles for symbol definitions. |
390 `---------------------------------------------*/
391
392 static void
393 prepare_symbol_definitions (void)
394 {
395 int i;
396 for (i = 0; i < nsyms; ++i)
397 {
398 symbol *sym = symbols[i];
399 const char *key;
400 const char *value;
401
402 #define SET_KEY(Entry) \
403 obstack_fgrow2 (&format_obstack, "symbol(%d, %s)", \
404 i, Entry); \
405 obstack_1grow (&format_obstack, 0); \
406 key = obstack_finish (&format_obstack);
407
408 #define SET_KEY2(Entry, Suffix) \
409 obstack_fgrow3 (&format_obstack, "symbol(%d, %s_%s)", \
410 i, Entry, Suffix); \
411 obstack_1grow (&format_obstack, 0); \
412 key = obstack_finish (&format_obstack);
413
414 // Whether the symbol has an identifier.
415 value = symbol_id_get (sym);
416 SET_KEY("has_id");
417 MUSCLE_INSERT_INT (key, !!value);
418
419 // Its identifier.
420 SET_KEY("id");
421 MUSCLE_INSERT_STRING (key, value ? value : "");
422
423 // Its tag. Typically for documentation purpose.
424 SET_KEY("tag");
425 MUSCLE_INSERT_STRING (key, sym->tag);
426
427 SET_KEY("user_number");
428 MUSCLE_INSERT_INT (key, sym->user_token_number);
429
430 SET_KEY("is_token");
431 MUSCLE_INSERT_INT (key,
432 i < ntokens && sym != errtoken && sym != undeftoken);
433
434 SET_KEY("number");
435 MUSCLE_INSERT_INT (key, sym->number);
436
437 SET_KEY("has_type");
438 MUSCLE_INSERT_INT (key, !!sym->type_name);
439
440 SET_KEY("type");
441 MUSCLE_INSERT_STRING (key, sym->type_name ? sym->type_name : "");
442
443 {
444 int j;
445 for (j = 0; j < CODE_PROPS_SIZE; ++j)
446 {
447 /* "printer", not "%printer". */
448 char const *pname = code_props_type_string (j) + 1;
449 code_props const *p = symbol_code_props_get (sym, j);
450 SET_KEY2("has", pname);
451 MUSCLE_INSERT_INT (key, !!p->code);
452
453 if (p->code)
454 {
455 SET_KEY2(pname, "file");
456 MUSCLE_INSERT_STRING (key, p->location.start.file);
457
458 SET_KEY2(pname, "line");
459 MUSCLE_INSERT_INT (key, p->location.start.line);
460
461 SET_KEY(pname);
462 MUSCLE_INSERT_STRING_RAW (key, p->code);
463 }
464 }
465 }
466 #undef SET_KEY2
467 #undef SET_KEY
468 }
469 }
470
471
472 static void
473 prepare_actions (void)
474 {
475 /* Figure out the actions for the specified state, indexed by
476 lookahead token type. */
477
478 muscle_insert_rule_number_table ("defact", yydefact,
479 yydefact[0], 1, nstates);
480
481 /* Figure out what to do after reducing with each rule, depending on
482 the saved state from before the beginning of parsing the data
483 that matched this rule. */
484 muscle_insert_state_number_table ("defgoto", yydefgoto,
485 yydefgoto[0], 1, nsyms - ntokens);
486
487
488 /* Output PACT. */
489 muscle_insert_base_table ("pact", base,
490 base[0], 1, nstates);
491 MUSCLE_INSERT_INT ("pact_ninf", base_ninf);
492
493 /* Output PGOTO. */
494 muscle_insert_base_table ("pgoto", base,
495 base[nstates], nstates + 1, nvectors);
496
497 muscle_insert_base_table ("table", table,
498 table[0], 1, high + 1);
499 MUSCLE_INSERT_INT ("table_ninf", table_ninf);
500
501 muscle_insert_base_table ("check", check,
502 check[0], 1, high + 1);
503
504 /* GLR parsing slightly modifies YYTABLE and YYCHECK (and thus
505 YYPACT) so that in states with unresolved conflicts, the default
506 reduction is not used in the conflicted entries, so that there is
507 a place to put a conflict pointer.
508
509 This means that YYCONFLP and YYCONFL are nonsense for a non-GLR
510 parser, so we could avoid accidents by not writing them out in
511 that case. Nevertheless, it seems even better to be able to use
512 the GLR skeletons even without the non-deterministic tables. */
513 muscle_insert_unsigned_int_table ("conflict_list_heads", conflict_table,
514 conflict_table[0], 1, high + 1);
515 muscle_insert_unsigned_int_table ("conflicting_rules", conflict_list,
516 0, 1, conflict_list_cnt);
517 }
518
519
520 /*--------------------------------------------.
521 | Output the definitions of all the muscles. |
522 `--------------------------------------------*/
523
524 static void
525 muscles_output (FILE *out)
526 {
527 fputs ("m4_init()\n", out);
528 merger_output (out);
529 symbol_numbers_output (out);
530 type_names_output (out);
531 user_actions_output (out);
532 // Must be last.
533 muscles_m4_output (out);
534 }
535 \f
536 /*---------------------------.
537 | Call the skeleton parser. |
538 `---------------------------*/
539
540 static void
541 output_skeleton (void)
542 {
543 int filter_fd[2];
544 pid_t pid;
545
546 /* Compute the names of the package data dir and skeleton files. */
547 char const *m4 = (m4 = getenv ("M4")) ? m4 : M4;
548 char const *datadir = pkgdatadir ();
549 char *m4sugar = xconcatenated_filename (datadir, "m4sugar/m4sugar.m4", NULL);
550 char *m4bison = xconcatenated_filename (datadir, "bison.m4", NULL);
551 char *skel = (IS_PATH_WITH_DIR (skeleton)
552 ? xstrdup (skeleton)
553 : xconcatenated_filename (datadir, skeleton, NULL));
554
555 /* Test whether m4sugar.m4 is readable, to check for proper
556 installation. A faulty installation can cause deadlock, so a
557 cheap sanity check is worthwhile. */
558 xfclose (xfopen (m4sugar, "r"));
559
560 /* Create an m4 subprocess connected to us via two pipes. */
561
562 if (trace_flag & trace_tools)
563 fprintf (stderr, "running: %s %s - %s %s\n",
564 m4, m4sugar, m4bison, skel);
565
566 /* Some future version of GNU M4 (most likely 1.6) may treat the -dV in a
567 position-dependent manner. Keep it as the first argument so that all
568 files are traced.
569
570 See the thread starting at
571 <http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>
572 for details. */
573 {
574 char const *argv[10];
575 int i = 0;
576 argv[i++] = m4;
577
578 /* When POSIXLY_CORRECT is set, GNU M4 1.6 and later disable GNU
579 extensions, which Bison's skeletons depend on. With older M4,
580 it has no effect. M4 1.4.12 added a -g/--gnu command-line
581 option to make it explicit that a program wants GNU M4
582 extensions even when POSIXLY_CORRECT is set.
583
584 See the thread starting at
585 <http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>
586 for details. */
587 if (*M4_GNU_OPTION)
588 argv[i++] = M4_GNU_OPTION;
589
590 argv[i++] = "-I";
591 argv[i++] = datadir;
592 if (trace_flag & trace_m4)
593 argv[i++] = "-dV";
594 argv[i++] = m4sugar;
595 argv[i++] = "-";
596 argv[i++] = m4bison;
597 argv[i++] = skel;
598 argv[i++] = NULL;
599 aver (i <= ARRAY_CARDINALITY (argv));
600
601 /* The ugly cast is because gnulib gets the const-ness wrong. */
602 pid = create_pipe_bidi ("m4", m4, (char **)(void*)argv, false, true,
603 true, filter_fd);
604 }
605
606 free (m4sugar);
607 free (m4bison);
608 free (skel);
609
610 if (trace_flag & trace_muscles)
611 muscles_output (stderr);
612 {
613 FILE *out = xfdopen (filter_fd[1], "w");
614 muscles_output (out);
615 xfclose (out);
616 }
617
618 /* Read and process m4's output. */
619 timevar_push (TV_M4);
620 {
621 FILE *in = xfdopen (filter_fd[0], "r");
622 scan_skel (in);
623 /* scan_skel should have read all of M4's output. Otherwise, when we
624 close the pipe, we risk letting M4 report a broken-pipe to the
625 Bison user. */
626 aver (feof (in));
627 xfclose (in);
628 }
629 wait_subprocess (pid, "m4", false, false, true, true, NULL);
630 timevar_pop (TV_M4);
631 }
632
633 static void
634 prepare (void)
635 {
636 /* BISON_USE_PUSH_FOR_PULL is for the test suite and should not be
637 documented for the user. */
638 char const *cp = getenv ("BISON_USE_PUSH_FOR_PULL");
639 bool use_push_for_pull_flag = cp && *cp && strtol (cp, 0, 10);
640
641 /* Flags. */
642 MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
643 MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
644 MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
645 MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
646 MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
647 MUSCLE_INSERT_BOOL ("token_table_flag", token_table_flag);
648 MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
649 MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag);
650
651 /* File names. */
652 if (spec_name_prefix)
653 MUSCLE_INSERT_STRING ("prefix", spec_name_prefix);
654
655 MUSCLE_INSERT_STRING ("file_name_all_but_ext", all_but_ext);
656
657 #define DEFINE(Name) MUSCLE_INSERT_STRING (#Name, Name ? Name : "")
658 DEFINE (dir_prefix);
659 DEFINE (parser_file_name);
660 DEFINE (spec_defines_file);
661 DEFINE (spec_file_prefix);
662 DEFINE (spec_graph_file);
663 DEFINE (spec_name_prefix);
664 DEFINE (spec_outfile);
665 DEFINE (spec_verbose_file);
666 #undef DEFINE
667
668 /* Find the right skeleton file, and add muscles about the skeletons. */
669 if (skeleton)
670 MUSCLE_INSERT_C_STRING ("skeleton", skeleton);
671 else
672 skeleton = language->skeleton;
673
674 /* About the skeletons. */
675 {
676 /* b4_pkgdatadir is used inside m4_include in the skeletons, so digraphs
677 would never be expanded. Hopefully no one has M4-special characters in
678 his Bison installation path. */
679 MUSCLE_INSERT_STRING_RAW ("pkgdatadir", pkgdatadir ());
680 }
681 }
682
683
684 /*----------------------------------------------------------.
685 | Output the parsing tables and the parser code to ftable. |
686 `----------------------------------------------------------*/
687
688 void
689 output (void)
690 {
691 obstack_init (&format_obstack);
692
693 prepare_symbols ();
694 prepare_rules ();
695 prepare_states ();
696 prepare_actions ();
697 prepare_symbol_definitions ();
698
699 prepare ();
700
701 /* Process the selected skeleton file. */
702 output_skeleton ();
703
704 obstack_free (&format_obstack, NULL);
705 }
706
707 char const *
708 pkgdatadir (void)
709 {
710 char const *cp = getenv ("BISON_PKGDATADIR");
711 return cp ? cp : PKGDATADIR;
712 }