X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/3b2942e671eadc31ca5cacf4c2965a1cac4edf04..76290368d48b584808a120dfbd415be93aef04f6:/src/output.c?ds=sidebyside diff --git a/src/output.c b/src/output.c index d3a39f78..70be1b9d 100644 --- a/src/output.c +++ b/src/output.c @@ -373,70 +373,41 @@ token_definitions_output (FILE *out) } -/*---------------------------------------. -| Output the symbol destructors to OUT. | -`---------------------------------------*/ +/*----------------------------------------------------. +| Output the symbol destructors and printers to OUT. | +`----------------------------------------------------*/ static void -symbol_destructors_output (FILE *out) +symbol_code_props_output (FILE *out, char const *what, + code_props (*get)(symbol *)) { int i; char const *sep = ""; - fputs ("m4_define([b4_symbol_destructors], \n[", out); + fputs ("m4_define([b4_symbol_", out); + fputs (what, out); + fputs ("], \n[", out); for (i = 0; i < nsyms; ++i) - if (symbol_destructor_get (symbols[i])) - { - symbol *sym = symbols[i]; - - /* Filename, lineno, - Symbol-name, Symbol-number, - destructor, optional typename. */ - fprintf (out, "%s[", sep); - sep = ",\n"; - escaped_output (out, symbol_destructor_location_get (sym).start.file); - fprintf (out, ", %d, ", - symbol_destructor_location_get (sym).start.line); - escaped_output (out, sym->tag); - fprintf (out, ", %d, [[%s]]", sym->number, - symbol_destructor_get (sym)); - if (sym->type_name) - fprintf (out, ", [[%s]]", sym->type_name); - fputc (']', out); - } - fputs ("])\n\n", out); -} - - -/*------------------------------------. -| Output the symbol printers to OUT. | -`------------------------------------*/ - -static void -symbol_printers_output (FILE *out) -{ - int i; - char const *sep = ""; - - fputs ("m4_define([b4_symbol_printers], \n[", out); - for (i = 0; i < nsyms; ++i) - if (symbol_printer_get (symbols[i])) - { - symbol *sym = symbols[i]; - - /* Filename, lineno, - Symbol-name, Symbol-number, - printer, optional typename. */ - fprintf (out, "%s[", sep); - sep = ",\n"; - escaped_output (out, symbol_printer_location_get (sym).start.file); - fprintf (out, ", %d, ", symbol_printer_location_get (sym).start.line); - escaped_output (out, sym->tag); - fprintf (out, ", %d, [[%s]]", sym->number, symbol_printer_get (sym)); - if (sym->type_name) - fprintf (out, ", [[%s]]", sym->type_name); - fputc (']', out); - } + { + symbol *sym = symbols[i]; + char const *code = code_props_code_get ((*get) (sym)); + if (code) + { + location loc = code_props_location_get ((*get) (sym)); + /* Filename, lineno, + Symbol-name, Symbol-number, + code, optional typename. */ + fprintf (out, "%s[", sep); + sep = ",\n"; + escaped_output (out, loc.start.file); + fprintf (out, ", %d, ", loc.start.line); + escaped_output (out, sym->tag); + fprintf (out, ", %d, [[%s]]", sym->number, code); + if (sym->type_name) + fprintf (out, ", [[%s]]", sym->type_name); + fputc (']', out); + } + } fputs ("])\n\n", out); } @@ -499,7 +470,7 @@ output_skeleton (void) FILE *in; FILE *out; int filter_fd[2]; - char const *argv[6]; + char const *argv[7]; pid_t pid; /* Compute the names of the package data dir and skeleton file. @@ -507,7 +478,9 @@ output_skeleton (void) installation. A faulty installation can cause deadlock, so a cheap sanity check is worthwhile. */ char const m4sugar[] = "m4sugar/m4sugar.m4"; + char const m4bison[] = "bison.m4"; char *full_m4sugar; + char *full_m4bison; char *full_skeleton; char const *p; char const *m4 = (p = getenv ("M4")) ? p : M4; @@ -523,24 +496,28 @@ output_skeleton (void) full_skeleton[pkgdatadirlen] = '/'; strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar); full_m4sugar = xstrdup (full_skeleton); + strcpy (full_skeleton + pkgdatadirlen + 1, m4bison); + full_m4bison = xstrdup (full_skeleton); strcpy (full_skeleton + pkgdatadirlen + 1, skeleton); xfclose (xfopen (full_m4sugar, "r")); /* Create an m4 subprocess connected to us via two pipes. */ if (trace_flag & trace_tools) - fprintf (stderr, "running: %s %s - %s\n", - m4, full_m4sugar, full_skeleton); + fprintf (stderr, "running: %s %s - %s %s\n", + m4, full_m4sugar, full_m4bison, full_skeleton); argv[0] = m4; argv[1] = full_m4sugar; argv[2] = "-"; - argv[3] = full_skeleton; - argv[4] = trace_flag & trace_m4 ? "-dV" : NULL; - argv[5] = NULL; + argv[3] = full_m4bison; + argv[4] = full_skeleton; + argv[5] = trace_flag & trace_m4 ? "-dV" : NULL; + argv[6] = NULL; init_subpipe (); pid = create_subpipe (argv, filter_fd); + free (full_m4bison); free (full_m4sugar); free (full_skeleton); @@ -555,8 +532,8 @@ output_skeleton (void) user_actions_output (out); merger_output (out); token_definitions_output (out); - symbol_destructors_output (out); - symbol_printers_output (out); + symbol_code_props_output (out, "destructors", &symbol_destructor_get); + symbol_code_props_output (out, "printers", &symbol_printer_get); muscles_m4_output (out); @@ -584,7 +561,9 @@ prepare (void) MUSCLE_INSERT_BOOL ("debug_flag", debug_flag); MUSCLE_INSERT_BOOL ("defines_flag", defines_flag); MUSCLE_INSERT_BOOL ("error_verbose_flag", error_verbose); + MUSCLE_INSERT_BOOL ("glr_flag", glr_parser); MUSCLE_INSERT_BOOL ("locations_flag", locations_flag); + MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser); MUSCLE_INSERT_BOOL ("pure_flag", pure_parser); MUSCLE_INSERT_BOOL ("push_flag", push_parser); MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag); @@ -592,7 +571,9 @@ prepare (void) MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag); /* File names. */ - MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy"); + if (spec_name_prefix) + MUSCLE_INSERT_STRING ("prefix", spec_name_prefix); + #define DEFINE(Name) MUSCLE_INSERT_STRING (#Name, Name ? Name : "") DEFINE (dir_prefix); DEFINE (parser_file_name);