X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/b0cfa28a1274c014b7bbff301f9421d7d09dd21e..4134cae3c5ff2fc3346ebc5b10d5c25c72c72cfe:/src/output.c diff --git a/src/output.c b/src/output.c index 254927d0..eecb8c68 100644 --- a/src/output.c +++ b/src/output.c @@ -129,8 +129,8 @@ struct obstack output_obstack; /* FIXME. */ static inline void -output_table_data (struct obstack* oout, - short* table, +output_table_data (struct obstack *oout, + short *table_data, short first, short begin, short end) @@ -149,7 +149,7 @@ output_table_data (struct obstack* oout, } else ++j; - obstack_fgrow1 (oout, "%6d", table[i]); + obstack_fgrow1 (oout, "%6d", table_data[i]); } obstack_1grow (oout, 0); } @@ -190,8 +190,10 @@ output_gram (void) XFREE (yyrhs); } - /* if (!semantic_parser && !no_parser_flag) - obstack_sgrow (&table_obstack, "\n#endif\n"); */ +#if 0 + if (!semantic_parser && !no_parser_flag) + obstack_sgrow (&table_obstack, "\n#endif\n"); +#endif } @@ -938,12 +940,10 @@ output_actions (void) sort_actions (); pack_table (); - /* FIXME: See if this is useful. */ - /* obstack_1grow (&table_obstack, '\n'); */ + output_base (); output_table (); - /* FIXME: See if this is useful. */ - /* obstack_1grow (&table_obstack, '\n'); */ + output_check (); } @@ -969,7 +969,7 @@ output_parser (void) } fskel = xfopen (skeleton, "r"); - /* New output code. */ + /* New output code. */ line = 1; c = getc (fskel); while (c != EOF) @@ -983,14 +983,14 @@ output_parser (void) } else if ((c = getc (fskel)) == '%') { - /* Read the macro. */ - char* macro_key = 0; - char* macro_value = 0; + /* Read the macro. */ + const char *macro_key = 0; + const char *macro_value = 0; while (isalnum (c = getc (fskel)) || c == '_') obstack_1grow (¯o_obstack, c); obstack_1grow (¯o_obstack, 0); - /* Output the right value, or see if it's something special. */ + /* Output the right value, or see if it's something special. */ macro_key = obstack_finish (¯o_obstack); macro_value = macro_find (macro_key); if (macro_value) @@ -1013,20 +1013,10 @@ output_parser (void) obstack_1grow (&table_obstack, '%'); } - /* End. */ + /* End. */ xfclose (fskel); } -static void -output_program (void) -{ - int c; - - while ((c = getc (finput)) != EOF) - obstack_1grow (&table_obstack, c); -} - - static void free_itemsets (void) { @@ -1077,23 +1067,15 @@ prepare (void) MACRO_INSERT_INT ("ntbase", ntokens); MACRO_INSERT_INT ("verbose", 0); - MACRO_INSERT_STRING ("filename", infile); - MACRO_INSERT_INT ("nnts", nvars); MACRO_INSERT_INT ("nrules", nrules); MACRO_INSERT_INT ("nstates", nstates); MACRO_INSERT_INT ("ntokens", ntokens); + MACRO_INSERT_INT ("locations_flag", locations_flag); + if (spec_name_prefix) - { - MACRO_INSERT_PREFIX ("yylex", "lex"); - MACRO_INSERT_PREFIX ("yychar", "char"); - MACRO_INSERT_PREFIX ("yylval", "lval"); - MACRO_INSERT_PREFIX ("yydebug", "debug"); - MACRO_INSERT_PREFIX ("yyerror", "error"); - MACRO_INSERT_PREFIX ("yynerrs", "nerrs"); - MACRO_INSERT_PREFIX ("yyparse", "parse"); - } + MACRO_INSERT_STRING ("prefix", spec_name_prefix); } /*----------------------------------------------------------. @@ -1103,20 +1085,11 @@ prepare (void) void output (void) { - obstack_init (¯o_obstack); obstack_init (&output_obstack); #if 0 - /* If using a simple parser the definition of YYSTYPE are put into - TABLE_OBSTACK. */ - if (!semantic_parser) - { - size_t size = obstack_object_size (&attrs_obstack); - obstack_grow (&table_obstack, obstack_finish (&attrs_obstack), size); - } + reader_output_yylsp (&table_obstack); */ #endif - - /* reader_output_yylsp (&table_obstack); */ free_itemsets (); output_token_translations (); @@ -1127,11 +1100,14 @@ output (void) output_stos (); output_rule_data (); output_actions (); - - /* if (!no_parser_flag) */ + +#if 0 + if (!no_parser_flag) */ +#endif prepare (); + /* Copy definitions in directive. */ + macro_insert ("prologue", obstack_finish (&attrs_obstack)); output_parser (); - output_program (); obstack_free (¯o_obstack, 0); obstack_free (&output_obstack, 0);