1 /* Output the generated parsing program for Bison.
3 Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018-2021 Free
4 Software Foundation, Inc.
6 This file is part of Bison, the GNU Compiler Compiler.
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.
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.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
24 #include <filename.h> /* IS_PATH_WITH_DIR */
25 #include <get-errno.h>
27 #include <path-join.h>
29 #include <spawn-pipe.h>
31 #include <wait-process.h>
37 #include "muscle-tab.h"
41 #include "scan-code.h" /* max_left_semantic_context */
42 #include "scan-skel.h"
45 #include "strversion.h"
47 static struct obstack format_obstack
;
50 /*-------------------------------------------------------------------.
51 | Create a function NAME which associates to the muscle NAME the |
52 | result of formatting the FIRST and then TABLE_DATA[BEGIN..END[ (of |
53 | TYPE), and to the muscle NAME_max, the max value of the |
56 | For the typical case of outputting a complete table from 0, pass |
57 | TABLE[0] as FIRST, and 1 as BEGIN. For instance |
58 | muscle_insert_base_table ("pact", base, base[0], 1, nstates); |
59 `-------------------------------------------------------------------*/
62 #define GENERATE_MUSCLE_INSERT_TABLE(Name, Type) \
65 Name (char const *name, Type *table_data, Type first, \
72 obstack_printf (&format_obstack, "%6d", first); \
73 for (int i = begin; i < end; ++i) \
75 obstack_1grow (&format_obstack, ','); \
78 obstack_sgrow (&format_obstack, "\n "); \
83 obstack_printf (&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]; \
89 muscle_insert (name, obstack_finish0 (&format_obstack)); \
93 /* Build 'NAME_min' and 'NAME_max' in the obstack. */ \
94 obstack_printf (&format_obstack, "%s_min", name); \
95 MUSCLE_INSERT_LONG_INT (obstack_finish0 (&format_obstack), lmin); \
96 obstack_printf (&format_obstack, "%s_max", name); \
97 MUSCLE_INSERT_LONG_INT (obstack_finish0 (&format_obstack), lmax); \
100 GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_int_table
, int)
101 GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_base_table
, base_number
)
102 GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_rule_number_table
, rule_number
)
103 GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_symbol_number_table
, symbol_number
)
104 GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_item_number_table
, item_number
)
105 GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_state_number_table
, state_number
)
107 /*----------------------------------------------------------------.
108 | Print to OUT a representation of CP quoted and escaped for M4. |
109 `----------------------------------------------------------------*/
112 output_escaped (FILE *out
, const char *cp
)
117 case '$': fputs ("$][", out
); break;
118 case '@': fputs ("@@", out
); break;
119 case '[': fputs ("@{", out
); break;
120 case ']': fputs ("@}", out
); break;
121 default: fputc (*cp
, out
); break;
126 output_quoted (FILE *out
, char const *cp
)
129 output_escaped (out
, cp
);
133 /*----------------------------------------------------------------.
134 | Print to OUT a representation of STRING quoted and escaped both |
136 `----------------------------------------------------------------*/
139 string_output (FILE *out
, char const *string
)
141 output_quoted (out
, quotearg_style (c_quoting_style
, string
));
145 /* Store in BUFFER a copy of SRC where trigraphs are escaped, return
146 the size of the result (including the final NUL). If called with
147 BUFFERSIZE = 0, returns the needed size for BUFFER. */
149 escape_trigraphs (char *buffer
, ptrdiff_t buffersize
, const char *src
)
154 if (res < buffersize) \
160 for (ptrdiff_t i
= 0, len
= strlen (src
); i
< len
; ++i
)
163 && src
[i
] == '?' && src
[i
+1] == '?')
168 case '(': case ')': case '-': case '/':
169 case '<': case '=': case '>':
185 /* Same as xstrdup, except that trigraphs are escaped. */
187 xescape_trigraphs (const char *src
)
189 ptrdiff_t bufsize
= escape_trigraphs (NULL
, 0, src
);
190 char *buf
= xcharalloc (bufsize
);
191 escape_trigraphs (buf
, bufsize
, src
);
195 /* The tag to show in the generated parsers. Use "end of file" rather
196 than "$end". But keep "$end" in the reports, it's shorter and more
197 consistent. Support i18n if the user already uses it. */
199 symbol_tag (const symbol
*sym
)
201 const bool eof_is_user_defined
202 = !eoftoken
->alias
|| STRNEQ (eoftoken
->alias
->tag
, "$end");
204 if (!eof_is_user_defined
&& sym
->content
== eoftoken
->content
)
205 return "\"end of file\"";
206 else if (sym
->content
== undeftoken
->content
)
207 return "\"invalid token\"";
212 /* Generate the b4_<MUSCLE_NAME> (e.g., b4_tname) table with the
213 symbol names (aka tags). */
216 prepare_symbol_names (char const *muscle_name
)
218 // Whether to add a pair of quotes around the name.
219 const bool quote
= STREQ (muscle_name
, "tname");
220 bool has_translations
= false;
222 /* We assume that the table will be output starting at column 2. */
224 struct quoting_options
*qo
= clone_quoting_options (0);
225 set_quoting_style (qo
, c_quoting_style
);
226 set_quoting_flags (qo
, QA_SPLIT_TRIGRAPHS
);
227 for (int i
= 0; i
< nsyms
; i
++)
229 const char *tag
= symbol_tag (symbols
[i
]);
230 bool translatable
= !quote
&& symbols
[i
]->translatable
;
232 has_translations
= true;
235 = tag
[0] == '"' && !quote
236 ? xescape_trigraphs (tag
)
237 : quotearg_alloc (tag
, -1, qo
);
238 /* Width of the next token, including the two quotes, the
239 comma and the space. */
241 = mbswidth (cp
, 0) + 2
242 + (translatable
? strlen ("N_()") : 0);
244 if (col
+ width
> 75)
246 obstack_sgrow (&format_obstack
, "\n ");
251 obstack_1grow (&format_obstack
, ' ');
253 obstack_sgrow (&format_obstack
, "]b4_symbol_translate""([");
254 obstack_escape (&format_obstack
, cp
);
256 obstack_sgrow (&format_obstack
, "])[");
258 obstack_1grow (&format_obstack
, ',');
262 obstack_sgrow (&format_obstack
, " ]b4_null[");
264 /* Finish table and store. */
265 muscle_insert (muscle_name
, obstack_finish0 (&format_obstack
));
267 /* Announce whether translation support is needed. */
268 MUSCLE_INSERT_BOOL ("has_translations_flag", has_translations
);
272 /*------------------------------------------------------------------.
273 | Prepare the muscles related to the symbols: translate, tname, and |
275 `------------------------------------------------------------------*/
278 prepare_symbols (void)
280 MUSCLE_INSERT_INT ("tokens_number", ntokens
);
281 MUSCLE_INSERT_INT ("nterms_number", nnterms
);
282 MUSCLE_INSERT_INT ("symbols_number", nsyms
);
283 MUSCLE_INSERT_INT ("code_max", max_code
);
285 muscle_insert_symbol_number_table ("translate",
287 token_translations
[0],
290 /* tname -- token names. */
291 prepare_symbol_names ("tname");
292 prepare_symbol_names ("symbol_names");
294 /* translatable -- whether a token is translatable. */
296 bool translatable
= false;
297 for (int i
= 0; i
< ntokens
; ++i
)
298 if (symbols
[i
]->translatable
)
305 int *values
= xnmalloc (nsyms
, sizeof *values
);
306 for (int i
= 0; i
< ntokens
; ++i
)
307 values
[i
] = symbols
[i
]->translatable
;
308 muscle_insert_int_table ("translatable", values
,
309 values
[0], 1, ntokens
);
314 /* Output YYTOKNUM. */
316 int *values
= xnmalloc (ntokens
, sizeof *values
);
317 for (int i
= 0; i
< ntokens
; ++i
)
318 values
[i
] = symbols
[i
]->content
->code
;
319 muscle_insert_int_table ("toknum", values
,
320 values
[0], 1, ntokens
);
326 /*-------------------------------------------------------------.
327 | Prepare the muscles related to the rules: rhs, prhs, r1, r2, |
328 | rline, dprec, merger, immediate. |
329 `-------------------------------------------------------------*/
334 int *prhs
= xnmalloc (nrules
, sizeof *prhs
);
335 item_number
*rhs
= xnmalloc (nritems
, sizeof *rhs
);
336 int *rline
= xnmalloc (nrules
, sizeof *rline
);
337 symbol_number
*r1
= xnmalloc (nrules
, sizeof *r1
);
338 int *r2
= xnmalloc (nrules
, sizeof *r2
);
339 int *dprec
= xnmalloc (nrules
, sizeof *dprec
);
340 int *merger
= xnmalloc (nrules
, sizeof *merger
);
341 int *immediate
= xnmalloc (nrules
, sizeof *immediate
);
345 for (rule_number r
= 0; r
< nrules
; ++r
)
347 /* Index of rule R in RHS. */
349 /* RHS of the rule R. */
350 for (item_number
*rhsp
= rules
[r
].rhs
; 0 <= *rhsp
; ++rhsp
)
352 /* Separator in RHS. */
355 /* Line where rule was defined. */
356 rline
[r
] = rules
[r
].location
.start
.line
;
357 /* LHS of the rule R. */
358 r1
[r
] = rules
[r
].lhs
->number
;
359 /* Length of rule R's RHS. */
360 r2
[r
] = rule_rhs_length (&rules
[r
]);
361 /* Dynamic precedence (GLR). */
362 dprec
[r
] = rules
[r
].dprec
;
363 /* Merger-function index (GLR). */
364 merger
[r
] = rules
[r
].merger
;
365 /* Immediate reduction flags (GLR). */
366 immediate
[r
] = rules
[r
].is_predicate
;
370 muscle_insert_item_number_table ("rhs", rhs
, ritem
[0], 1, nritems
);
371 muscle_insert_int_table ("prhs", prhs
, 0, 0, nrules
);
372 muscle_insert_int_table ("rline", rline
, 0, 0, nrules
);
373 muscle_insert_symbol_number_table ("r1", r1
, 0, 0, nrules
);
374 muscle_insert_int_table ("r2", r2
, 0, 0, nrules
);
375 muscle_insert_int_table ("dprec", dprec
, 0, 0, nrules
);
376 muscle_insert_int_table ("merger", merger
, 0, 0, nrules
);
377 muscle_insert_int_table ("immediate", immediate
, 0, 0, nrules
);
379 MUSCLE_INSERT_INT ("rules_number", nrules
);
380 MUSCLE_INSERT_INT ("max_left_semantic_context", max_left_semantic_context
);
392 /*--------------------------------------------.
393 | Prepare the muscles related to the states. |
394 `--------------------------------------------*/
397 prepare_states (void)
399 symbol_number
*values
= xnmalloc (nstates
, sizeof *values
);
400 for (state_number i
= 0; i
< nstates
; ++i
)
401 values
[i
] = states
[i
]->accessing_symbol
;
402 muscle_insert_symbol_number_table ("stos", values
,
406 MUSCLE_INSERT_INT ("last", high
);
407 MUSCLE_INSERT_INT ("final_state_number", final_state
->number
);
408 MUSCLE_INSERT_INT ("states_number", nstates
);
412 /*-------------------------------------------------------.
413 | Compare two symbols by type-name, and then by number. |
414 `-------------------------------------------------------*/
417 symbol_type_name_cmp (const symbol
**lhs
, const symbol
**rhs
)
419 int res
= uniqstr_cmp ((*lhs
)->content
->type_name
, (*rhs
)->content
->type_name
);
421 res
= (*lhs
)->content
->number
- (*rhs
)->content
->number
;
426 /*----------------------------------------------------------------.
427 | Return a (malloc'ed) table of the symbols sorted by type-name. |
428 `----------------------------------------------------------------*/
431 symbols_by_type_name (void)
433 typedef int (*qcmp_type
) (const void *, const void *);
434 symbol
**res
= xmemdup (symbols
, nsyms
* sizeof *res
);
435 qsort (res
, nsyms
, sizeof *res
, (qcmp_type
) &symbol_type_name_cmp
);
440 /*------------------------------------------------------------------.
441 | Define b4_type_names, which is a list of (lists of the numbers of |
442 | symbols with same type-name). |
443 `------------------------------------------------------------------*/
446 type_names_output (FILE *out
)
448 symbol
**syms
= symbols_by_type_name ();
449 fputs ("m4_define([b4_type_names],\n[", out
);
450 for (int i
= 0; i
< nsyms
; /* nothing */)
452 /* The index of the first symbol of the current type-name. */
454 fputs (i
? ",\n[" : "[", out
);
456 && syms
[i
]->content
->type_name
== syms
[i0
]->content
->type_name
; ++i
)
457 fprintf (out
, "%s%d", i
!= i0
? ", " : "", syms
[i
]->content
->number
);
460 fputs ("])\n\n", out
);
465 /* Define the list of start symbols *if* there are several. Define
466 them by pairs: [START-SYMBOL-NUM, SWITCHING-TOKEN-SYMBOL-NUM]. */
468 start_symbols_output (FILE *out
)
470 if (start_symbols
&& start_symbols
->next
)
472 fputs ("m4_define([b4_start_symbols],\n[", out
);
473 for (symbol_list
*list
= start_symbols
; list
; list
= list
->next
)
475 const symbol
*start
= list
->content
.sym
;
476 const symbol
*swtok
= switching_token (start
);
477 fprintf (out
, "%s[%d, %d]",
478 list
== start_symbols
? "" : ", ",
479 start
->content
->number
, swtok
->content
->number
);
481 fputs ("])\n\n", out
);
486 /*-------------------------------------.
487 | The list of all the symbol numbers. |
488 `-------------------------------------*/
491 symbol_numbers_output (FILE *out
)
493 fputs ("m4_define([b4_symbol_numbers],\n[", out
);
494 for (int i
= 0; i
< nsyms
; ++i
)
495 fprintf (out
, "%s[%d]", i
? ", " : "", i
);
496 fputs ("])\n\n", out
);
500 /*-------------------------------------------.
501 | Output the user reduction actions to OUT. |
502 `-------------------------------------------*/
505 rule_output (const rule
*r
, FILE *out
)
507 output_escaped (out
, r
->lhs
->symbol
->tag
);
510 for (item_number
*rhsp
= r
->rhs
; 0 <= *rhsp
; ++rhsp
)
513 output_escaped (out
, symbols
[*rhsp
]->tag
);
516 fputs (" %empty", out
);
520 user_actions_output (FILE *out
)
522 fputs ("m4_define([b4_actions], \n[", out
);
523 for (rule_number r
= 0; r
< nrules
; ++r
)
526 /* The useless "" is there to pacify syntax-check. */
527 fprintf (out
, "%s""(%d, [",
528 rules
[r
].is_predicate
? "b4_predicate_case" : "b4_case",
532 fprintf (out
, "b4_syncline(%d, ",
533 rules
[r
].action_loc
.start
.line
);
534 string_output (out
, map_file_name (rules
[r
].action_loc
.start
.file
));
535 fprintf (out
, ")dnl\n");
537 fprintf (out
, "[%*s%s]],\n[[",
538 rules
[r
].action_loc
.start
.column
- 1, "",
540 rule_output (&rules
[r
], out
);
541 fprintf (out
, "]])\n\n");
543 fputs ("])\n\n", out
);
546 /*------------------------------------.
547 | Output the merge functions to OUT. |
548 `------------------------------------*/
551 merger_output (FILE *out
)
553 fputs ("m4_define([b4_mergers], \n[[", out
);
556 for (n
= 1, p
= merge_functions
; p
!= NULL
; n
+= 1, p
= p
->next
)
557 fprintf (out
, "]b4_call_merger""([%d], [%s], [%d])[\n",
558 n
, p
->name
, p
->sym
->content
->number
);
559 fputs ("]])\n\n", out
);
563 /*---------------------------------------------.
564 | Prepare the muscles for symbol definitions. |
565 `---------------------------------------------*/
568 prepare_symbol_definitions (void)
570 /* Map "orig NUM" to new numbers. See data/README. */
571 for (symbol_number i
= ntokens
; i
< nsyms
+ nuseless_nonterminals
; ++i
)
573 obstack_printf (&format_obstack
, "symbol""(orig %d, number)", i
);
574 const char *key
= obstack_finish0 (&format_obstack
);
575 MUSCLE_INSERT_INT (key
, nterm_map
? nterm_map
[i
- ntokens
] : i
);
578 for (int i
= 0; i
< nsyms
; ++i
)
580 symbol
*sym
= symbols
[i
];
583 #define SET_KEY(Entry) \
584 obstack_printf (&format_obstack, "symbol""(%d, %s)", \
586 key = obstack_finish0 (&format_obstack);
588 #define SET_KEY2(Entry, Suffix) \
589 obstack_printf (&format_obstack, "symbol""(%d, %s_%s)", \
591 key = obstack_finish0 (&format_obstack);
593 /* Whether the symbol has an identifier. */
594 const char *id
= symbol_id_get (sym
);
596 MUSCLE_INSERT_INT (key
, !!id
);
598 /* Its identifier. */
600 MUSCLE_INSERT_STRING (key
, id
? id
: "");
602 /* Its tag. Typically for documentation purpose. */
604 MUSCLE_INSERT_STRING (key
, symbol_tag (sym
));
607 MUSCLE_INSERT_INT (key
, sym
->content
->code
);
609 SET_KEY ("is_token");
610 MUSCLE_INSERT_INT (key
, i
< ntokens
);
613 MUSCLE_INSERT_INT (key
, sym
->content
->number
);
615 SET_KEY ("has_type");
616 MUSCLE_INSERT_INT (key
, !!sym
->content
->type_name
);
619 MUSCLE_INSERT_STRING (key
, sym
->content
->type_name
620 ? sym
->content
->type_name
: "");
622 for (int j
= 0; j
< CODE_PROPS_SIZE
; ++j
)
624 /* "printer", not "%printer". */
625 char const *pname
= code_props_type_string (j
) + 1;
626 code_props
const *p
= symbol_code_props_get (sym
, j
);
627 SET_KEY2 ("has", pname
);
628 MUSCLE_INSERT_INT (key
, !!p
->code
);
632 SET_KEY2 (pname
, "file");
633 MUSCLE_INSERT_C_STRING (key
, map_file_name (p
->location
.start
.file
));
635 SET_KEY2 (pname
, "line");
636 MUSCLE_INSERT_INT (key
, p
->location
.start
.line
);
638 SET_KEY2 (pname
, "loc");
639 muscle_location_grow (key
, p
->location
);
642 obstack_printf (&muscle_obstack
,
643 "%*s%s", p
->location
.start
.column
- 1, "", p
->code
);
644 muscle_insert (key
, obstack_finish0 (&muscle_obstack
));
654 prepare_actions (void)
656 /* Figure out the actions for the specified state. */
657 muscle_insert_rule_number_table ("defact", yydefact
,
658 yydefact
[0], 1, nstates
);
660 /* Figure out what to do after reducing with each rule, depending on
661 the saved state from before the beginning of parsing the data
662 that matched this rule. */
663 muscle_insert_state_number_table ("defgoto", yydefgoto
,
664 yydefgoto
[0], 1, nsyms
- ntokens
);
668 muscle_insert_base_table ("pact", base
,
669 base
[0], 1, nstates
);
670 MUSCLE_INSERT_INT ("pact_ninf", base_ninf
);
673 muscle_insert_base_table ("pgoto", base
,
674 base
[nstates
], nstates
+ 1, nvectors
);
676 muscle_insert_base_table ("table", table
,
677 table
[0], 1, high
+ 1);
678 MUSCLE_INSERT_INT ("table_ninf", table_ninf
);
680 muscle_insert_base_table ("check", check
,
681 check
[0], 1, high
+ 1);
683 /* GLR parsing slightly modifies YYTABLE and YYCHECK (and thus
684 YYPACT) so that in states with unresolved conflicts, the default
685 reduction is not used in the conflicted entries, so that there is
686 a place to put a conflict pointer.
688 This means that YYCONFLP and YYCONFL are nonsense for a non-GLR
689 parser, so we could avoid accidents by not writing them out in
690 that case. Nevertheless, it seems even better to be able to use
691 the GLR skeletons even without the non-deterministic tables. */
692 muscle_insert_int_table ("conflict_list_heads", conflict_table
,
693 conflict_table
[0], 1, high
+ 1);
694 muscle_insert_int_table ("conflicting_rules", conflict_list
,
695 0, 1, conflict_list_cnt
);
699 /*--------------------------------------------.
700 | Output the definitions of all the muscles. |
701 `--------------------------------------------*/
704 muscles_output (FILE *out
)
706 fputs ("m4_init()\n", out
);
708 symbol_numbers_output (out
);
709 type_names_output (out
);
710 start_symbols_output (out
);
711 user_actions_output (out
);
713 muscles_m4_output (out
);
716 /*---------------------------.
717 | Call the skeleton parser. |
718 `---------------------------*/
721 output_skeleton (void)
723 /* Compute the names of the package data dir and skeleton files. */
724 char const *m4
= m4path ();
725 char const *datadir
= pkgdatadir ();
726 char *skeldir
= xpath_join (datadir
, "skeletons");
727 char *m4sugar
= xpath_join (datadir
, "m4sugar/m4sugar.m4");
728 char *m4bison
= xpath_join (skeldir
, "bison.m4");
729 char *traceon
= xpath_join (skeldir
, "traceon.m4");
730 char *skel
= (IS_PATH_WITH_DIR (skeleton
)
732 : xpath_join (skeldir
, skeleton
));
734 /* Test whether m4sugar.m4 is readable, to check for proper
735 installation. A faulty installation can cause deadlock, so a
736 cheap sanity check is worthwhile. */
737 xfclose (xfopen (m4sugar
, "r"));
739 /* Create an m4 subprocess connected to us via two pipes. */
744 char const *argv
[11];
748 /* When POSIXLY_CORRECT is set, GNU M4 1.6 and later disable GNU
749 extensions, which Bison's skeletons depend on. With older M4,
750 it has no effect. M4 1.4.12 added a -g/--gnu command-line
751 option to make it explicit that a program wants GNU M4
752 extensions even when POSIXLY_CORRECT is set.
754 See the thread starting at
755 <https://lists.gnu.org/r/bug-bison/2008-07/msg00000.html>
758 argv
[i
++] = M4_GNU_OPTION
;
762 /* Some future version of GNU M4 (most likely 1.6) may treat the
763 -dV in a position-dependent manner. See the thread starting at
764 <https://lists.gnu.org/r/bug-bison/2008-07/msg00000.html>
766 if (trace_flag
& trace_m4_early
)
771 if (trace_flag
& trace_m4
)
775 aver (i
<= ARRAY_CARDINALITY (argv
));
777 if (trace_flag
& trace_tools
)
779 fputs ("running:", stderr
);
780 for (int j
= 0; argv
[j
]; ++j
)
781 fprintf (stderr
, " %s", argv
[j
]);
782 fputc ('\n', stderr
);
785 pid
= create_pipe_bidi ("m4", m4
, argv
,
786 /* directory */ NULL
,
787 /* null_stderr */ false,
788 /* slave_process */ true,
789 /* exit_on_error */ true,
799 if (trace_flag
& trace_muscles
)
800 muscles_output (stderr
);
802 FILE *out
= xfdopen (filter_fd
[1], "w");
803 muscles_output (out
);
807 /* Read and process m4's output. */
808 timevar_push (tv_m4
);
810 FILE *in
= xfdopen (filter_fd
[0], "r");
812 /* scan_skel should have read all of M4's output. Otherwise, when we
813 close the pipe, we risk letting M4 report a broken-pipe to the
818 wait_subprocess (pid
, "m4", false, false, true, true, NULL
);
825 /* BISON_USE_PUSH_FOR_PULL is for the test suite and should not be
826 documented for the user. */
827 char const *cp
= getenv ("BISON_USE_PUSH_FOR_PULL");
828 bool use_push_for_pull_flag
= cp
&& *cp
&& strtol (cp
, 0, 10);
831 MUSCLE_INSERT_STRING ("version_string", VERSION
);
832 MUSCLE_INSERT_INT ("version", strversion_to_int (VERSION
));
833 MUSCLE_INSERT_INT ("required_version", required_version
);
836 MUSCLE_INSERT_BOOL ("header_flag", header_flag
);
837 MUSCLE_INSERT_BOOL ("glr_flag", glr_parser
);
838 MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser
);
839 MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag
);
840 MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen
);
841 MUSCLE_INSERT_BOOL ("token_table_flag", token_table_flag
);
842 MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag
);
843 MUSCLE_INSERT_BOOL ("yacc_flag", !location_empty (yacc_loc
));
846 if (spec_name_prefix
)
847 MUSCLE_INSERT_STRING ("prefix", spec_name_prefix
);
849 MUSCLE_INSERT_STRING ("file_name_all_but_ext", all_but_ext
);
851 const char *spec_mapped_header_file
= map_file_name (spec_header_file
);
852 const char *mapped_dir_prefix
= map_file_name (dir_prefix
);
854 #define DEFINE(Name) MUSCLE_INSERT_STRING (#Name, Name ? Name : "")
856 DEFINE (mapped_dir_prefix
);
857 DEFINE (parser_file_name
);
858 DEFINE (spec_header_file
);
859 DEFINE (spec_mapped_header_file
);
860 DEFINE (spec_file_prefix
);
861 DEFINE (spec_graph_file
);
862 DEFINE (spec_name_prefix
);
863 DEFINE (spec_outfile
);
864 DEFINE (spec_verbose_file
);
867 /* Find the right skeleton file, and add muscles about the skeletons. */
869 MUSCLE_INSERT_C_STRING ("skeleton", skeleton
);
871 skeleton
= language
->skeleton
;
873 /* About the skeletons. */
875 /* b4_skeletonsdir is used inside m4_include in the skeletons, so digraphs
876 would never be expanded. Hopefully no one has M4-special characters in
877 his Bison installation path. */
878 char *skeldir
= xpath_join (pkgdatadir (), "skeletons");
879 MUSCLE_INSERT_STRING_RAW ("skeletonsdir", skeldir
);
885 /*----------------------------------------------------------.
886 | Output the parsing tables and the parser code to ftable. |
887 `----------------------------------------------------------*/
892 obstack_init (&format_obstack
);
898 prepare_symbol_definitions ();
902 /* Process the selected skeleton file. */
905 /* If late errors were generated, destroy the generated source
907 if (complaint_status
)
908 unlink_generated_sources ();
910 obstack_free (&format_obstack
, NULL
);