X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/7651439487857a666baa5fa5df453b715a85a090..aa96fda183953df7df0b6b2d59b6f443b11e42ad:/src/output.c diff --git a/src/output.c b/src/output.c index 706ee272..63b1e0dc 100644 --- a/src/output.c +++ b/src/output.c @@ -89,6 +89,7 @@ negative short int. Used to flag ?? */ #include "system.h" +#include "bitsetv.h" #include "quotearg.h" #include "error.h" #include "getargs.h" @@ -191,8 +192,8 @@ output_gram (void) { int i; short *values = XCALLOC (short, nrules + 1); - for (i = 0; i < nrules + 1; ++i) - values[i] = rules[i].rhs; + for (i = 1; i < nrules + 1; ++i) + values[i] = rules[i].rhs - ritem; output_table_data (&format_obstack, values, 0, 1, nrules + 1); XFREE (values); @@ -245,7 +246,7 @@ output_rule_data (void) { short *values = XCALLOC (short, nrules + 1); - for (i = 0; i < nrules + 1; ++i) + for (i = 1; i < nrules + 1; ++i) values[i] = rules[i].line; output_table_data (&format_obstack, values, 0, 1, nrules + 1); @@ -298,7 +299,7 @@ output_rule_data (void) /* Output YYR1. */ { short *values = XCALLOC (short, nrules + 1); - for (i = 0; i < nrules + 1; ++i) + for (i = 1; i < nrules + 1; ++i) values[i] = rules[i].lhs; output_table_data (&format_obstack, values, 0, 1, nrules + 1); @@ -310,7 +311,7 @@ output_rule_data (void) short_tab = XMALLOC (short, nrules + 1); for (i = 1; i < nrules; i++) short_tab[i] = rules[i + 1].rhs - rules[i].rhs - 1; - short_tab[nrules] = nritems - rules[nrules].rhs - 1; + short_tab[nrules] = nritems - (rules[nrules].rhs - ritem) - 1; output_table_data (&format_obstack, short_tab, 0, 1, nrules + 1); muscle_insert ("r2", obstack_finish (&format_obstack)); @@ -567,6 +568,7 @@ void token_definitions_output (FILE *out) { int i; + int first = 1; for (i = 0; i < ntokens; ++i) { bucket *symbol = symbols[i]; @@ -575,7 +577,7 @@ token_definitions_output (FILE *out) if (number == SALIAS) continue; /* Skip error token. */ - if (symbol->value == error_token_number) + if (symbol->number == error_token_number) continue; if (symbol->tag[0] == '\'') continue; /* skip literal character */ @@ -593,12 +595,13 @@ token_definitions_output (FILE *out) if (strchr (symbol->tag, '.') || strchr (symbol->tag, '$')) continue; - fprintf (out, "# define %s\t%d\n", - symbol->tag, number); + fprintf (out, "%s [[[%s]], [%d]]", + first ? "" : ",\n", symbol->tag, number); if (semantic_parser) /* FIXME: This is probably wrong, and should be just as above. --akim. */ - fprintf (out, "# define T%s\t%d\n", symbol->tag, symbol->value); + fprintf (out, "# define T%s\t%d\n", symbol->tag, symbol->number); + first = 0; } } @@ -922,7 +925,7 @@ output_actions (void) width = XCALLOC (short, nvectors); token_actions (); - XFREE (LA); + bitsetv_free (LA); XFREE (LAruleno); goto_actions (); @@ -957,10 +960,9 @@ static void output_skeleton (void) { /* Store the definition of all the muscles. */ - char *tempdir = getenv ("TMPDIR"); + const char *tempdir = getenv ("TMPDIR"); char *tempfile = NULL; FILE *out = NULL; - ssize_t bytes_read; int fd; if (tempdir == NULL) @@ -988,9 +990,9 @@ output_skeleton (void) guards_output (out); fputs ("]])\n\n", out); - fputs ("m4_define([b4_tokendef], \n[[", out); + fputs ("m4_define([b4_tokens], \n[", out); token_definitions_output (out); - fputs ("]])\n\n", out); + fputs ("])\n\n", out); muscles_m4_output (out);