From 11d82f03b4baf017d825166bd60b21f69131547c Mon Sep 17 00:00:00 2001 From: Marc Autret Date: Sun, 2 Sep 2001 15:43:29 +0000 Subject: [PATCH] * src/reader.c: Include muscle_tab.h. (parse_union_decl): Update. (parse_macro_decl): Rename parse_muscle_decl. Update to use renamed functions and variable. (read_declarations, copy_action, read_additionnal_code, : Updated with correct variables and functions names. (packsymbols, reader): Likewise. * src/reader.h (muscle_obstack): Extern declaration update. * src/output.c: Include muscle_tab.h In all functions using macro_insert, change by using muscle_insert (). (macro_obstack): Rename muscle_obstack. Echo modifications in the whole file. (MACRO_INSERT_INT): Rename MUSCLE_INSERT_INT. (MACRO_INSERT_STRING): Rename MUSCLE_INSERT_STRING. (MACRO_INSERT_PREFIX): Rename MUSCLE_INSERT_PREFIX. * src/muscle_tab.h: Update double inclusion macros. (macro_entry_s): Rename muscle_entry_s. Update prototypes. * src/muscle_tab.c: Include muscle_tab.h. Rename macro_tabble to muscle_table. (mhash1, mhash2, mcmp): Use muscle_entry. (macro_init): Rename muscle_init. Update. (macro_insert): Rename muscle_insert. Update. (macro_find): Rename muscle_find. Update. * src/main.c: Include muscle_tab.h. (main): Call muscle_init (). * src/Makefile.am (bison_SOURCES): Echo modifications. --- ChangeLog | 35 ++++++++++++++ src/Makefile.am | 14 +++--- src/main.c | 4 +- src/output.c | 124 ++++++++++++++++++++++++------------------------ src/reader.c | 38 +++++++-------- src/reader.h | 2 +- 6 files changed, 126 insertions(+), 91 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5fee45a0..416fbc02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,38 @@ +2001-09-02 Marc Autret + + * src/reader.c: Include muscle_tab.h. + (parse_union_decl): Update. + (parse_macro_decl): Rename parse_muscle_decl. + Update to use renamed functions and variable. + (read_declarations, copy_action, read_additionnal_code, : Updated + with correct variables and functions names. + (packsymbols, reader): Likewise. + + * src/reader.h (muscle_obstack): Extern declaration update. + + * src/output.c: Include muscle_tab.h + In all functions using macro_insert, change by using muscle_insert (). + (macro_obstack): Rename muscle_obstack. + Echo modifications in the whole file. + (MACRO_INSERT_INT): Rename MUSCLE_INSERT_INT. + (MACRO_INSERT_STRING): Rename MUSCLE_INSERT_STRING. + (MACRO_INSERT_PREFIX): Rename MUSCLE_INSERT_PREFIX. + + * src/muscle_tab.h: Update double inclusion macros. + (macro_entry_s): Rename muscle_entry_s. + Update prototypes. + + * src/muscle_tab.c: Include muscle_tab.h. + Rename macro_tabble to muscle_table. + (mhash1, mhash2, mcmp): Use muscle_entry. + (macro_init): Rename muscle_init. Update. + (macro_insert): Rename muscle_insert. Update. + (macro_find): Rename muscle_find. Update. + + * src/main.c: Include muscle_tab.h. + (main): Call muscle_init (). + * src/Makefile.am (bison_SOURCES): Echo modifications. + 2001-09-02 Marc Autret Now the files macro_tab.[ch] are named muscle_tab.[ch]. diff --git a/src/Makefile.am b/src/Makefile.am index ae5e26d7..322c614c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,19 +13,19 @@ bin_PROGRAMS = bison bison_SOURCES = LR0.c closure.c complain.c conflicts.c \ derives.c \ files.c getargs.c gram.c lalr.c lex.c main.c nullable.c \ - output.c \ - macrotab.c \ - print.c reader.c reduce.c symtab.c warshall.c vcg.c print_graph.c + output.c print_graph.c \ + muscle_tab.c \ + print.c reader.c reduce.c symtab.c warshall.c vcg.c EXTRA_bison_SOURCES = vmsgetargs.c noinst_HEADERS = LR0.h closure.h complain.h conflicts.h \ derives.h \ files.h getargs.h gram.h lalr.h lex.h nullable.h \ - output.h state.h \ - macrotab.h \ - print.h reader.h reduce.h symtab.h warshall.h system.h types.h \ - vcg.h vcg_defaults.h print_graph.h + output.h print_graph.h \ + muscle_tab.h \ + print.h reader.h reduce.h state.h symtab.h warshall.h system.h \ + types.h vcg.h vcg_defaults.h pkgdata_DATA = bison.simple bison.hairy diff --git a/src/main.c b/src/main.c index 0fd82bc1..6dfffbeb 100644 --- a/src/main.c +++ b/src/main.c @@ -34,7 +34,7 @@ #include "LR0.h" #include "conflicts.h" #include "print_graph.h" -#include "macrotab.h" +#include "muscle_tab.h" /* The name this program was run with, for messages. */ char *program_name; @@ -52,7 +52,7 @@ main (int argc, char *argv[]) lineno = 0; getargs (argc, argv); - macro_init (); + muscle_init (); open_files (); /* Read the input. Copy some parts of it to FGUARD, FACTION, FTABLE diff --git a/src/output.c b/src/output.c index eecb8c68..b07988a7 100644 --- a/src/output.c +++ b/src/output.c @@ -103,7 +103,7 @@ #include "lalr.h" #include "reader.h" #include "conflicts.h" -#include "macrotab.h" +#include "muscle_tab.h" extern void berror PARAMS((const char *)); @@ -123,7 +123,7 @@ static short *check; static int lowzero; static int high; -struct obstack macro_obstack; +struct obstack muscle_obstack; struct obstack output_obstack; /* FIXME. */ @@ -160,7 +160,7 @@ output_token_translations (void) { output_table_data (&output_obstack, token_translations, 0, 1, max_user_token_number + 1); - macro_insert ("translate", obstack_finish (&output_obstack)); + muscle_insert ("translate", obstack_finish (&output_obstack)); } @@ -169,7 +169,7 @@ output_gram (void) { output_table_data (&output_obstack, rrhs, 0, 1, nrules + 1); - macro_insert ("prhs", obstack_finish (&output_obstack)); + muscle_insert ("prhs", obstack_finish (&output_obstack)); { size_t yyrhs_size = 1; @@ -185,7 +185,7 @@ output_gram (void) output_table_data (&output_obstack, yyrhs, ritem[0], 1, yyrhs_size); - macro_insert ("rhs", obstack_finish (&output_obstack)); + muscle_insert ("rhs", obstack_finish (&output_obstack)); XFREE (yyrhs); } @@ -202,7 +202,7 @@ output_stos (void) { output_table_data (&output_obstack, accessing_symbol, 0, 1, nstates); - macro_insert ("stos", obstack_finish (&output_obstack)); + muscle_insert ("stos", obstack_finish (&output_obstack)); } @@ -215,7 +215,7 @@ output_rule_data (void) output_table_data (&output_obstack, rline, 0, 1, nrules + 1); - macro_insert ("rline", obstack_finish (&output_obstack)); + muscle_insert ("rline", obstack_finish (&output_obstack)); j = 0; for (i = 0; i < nsyms; i++) @@ -267,17 +267,17 @@ output_rule_data (void) /* Finish table and store. */ obstack_1grow (&output_obstack, 0); - macro_insert ("tname", obstack_finish (&output_obstack)); + muscle_insert ("tname", obstack_finish (&output_obstack)); /* Output YYTOKNUM. */ output_table_data (&output_obstack, user_toknums, 0, 1, ntokens + 1); - macro_insert ("toknum", obstack_finish (&output_obstack)); + muscle_insert ("toknum", obstack_finish (&output_obstack)); /* Output YYR1. */ output_table_data (&output_obstack, rlhs, 0, 1, nrules + 1); - macro_insert ("r1", obstack_finish (&output_obstack)); + muscle_insert ("r1", obstack_finish (&output_obstack)); XFREE (rlhs + 1); /* Output YYR2. */ @@ -287,7 +287,7 @@ output_rule_data (void) short_tab[nrules] = nitems - rrhs[nrules] - 1; output_table_data (&output_obstack, short_tab, 0, 1, nrules + 1); - macro_insert ("r2", obstack_finish (&output_obstack)); + muscle_insert ("r2", obstack_finish (&output_obstack)); XFREE (short_tab); XFREE (rrhs + 1); @@ -536,7 +536,7 @@ token_actions (void) output_table_data (&output_obstack, yydefact, yydefact[0], 1, nstates); - macro_insert ("defact", obstack_finish (&output_obstack)); + muscle_insert ("defact", obstack_finish (&output_obstack)); XFREE (actrow); XFREE (yydefact); @@ -677,7 +677,7 @@ goto_actions (void) output_table_data (&output_obstack, yydefgoto, yydefgoto[0], 1, nsyms - ntokens); - macro_insert ("defgoto", obstack_finish (&output_obstack)); + muscle_insert ("defgoto", obstack_finish (&output_obstack)); XFREE (state_count); XFREE (yydefgoto); @@ -882,12 +882,12 @@ output_base (void) /* Output pact. */ output_table_data (&output_obstack, base, base[0], 1, nstates); - macro_insert ("pact", obstack_finish (&output_obstack)); + muscle_insert ("pact", obstack_finish (&output_obstack)); /* Output pgoto. */ output_table_data (&output_obstack, base, base[nstates], nstates + 1, nvectors); - macro_insert ("pgoto", obstack_finish (&output_obstack)); + muscle_insert ("pgoto", obstack_finish (&output_obstack)); XFREE (base); } @@ -898,7 +898,7 @@ output_table (void) { output_table_data (&output_obstack, table, table[0], 1, high + 1); - macro_insert ("table", obstack_finish (&output_obstack)); + muscle_insert ("table", obstack_finish (&output_obstack)); XFREE (table); } @@ -908,7 +908,7 @@ output_check (void) { output_table_data (&output_obstack, check, check[0], 1, high + 1); - macro_insert ("check", obstack_finish (&output_obstack)); + muscle_insert ("check", obstack_finish (&output_obstack)); XFREE (check); } @@ -983,21 +983,21 @@ output_parser (void) } else if ((c = getc (fskel)) == '%') { - /* Read the macro. */ - const char *macro_key = 0; - const char *macro_value = 0; + /* Read the muscle. */ + const char *muscle_key = 0; + const char *muscle_value = 0; while (isalnum (c = getc (fskel)) || c == '_') - obstack_1grow (¯o_obstack, c); - obstack_1grow (¯o_obstack, 0); + obstack_1grow (&muscle_obstack, c); + obstack_1grow (&muscle_obstack, 0); /* 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) - obstack_sgrow (&table_obstack, macro_value); - else if (!strcmp (macro_key, "line")) + muscle_key = obstack_finish (&muscle_obstack); + muscle_value = muscle_find (muscle_key); + if (muscle_value) + obstack_sgrow (&table_obstack, muscle_value); + else if (!strcmp (muscle_key, "line")) obstack_fgrow1 (&table_obstack, "%d", line + 1); - else if (!strcmp (macro_key, "action")) + else if (!strcmp (muscle_key, "action")) { size_t size = obstack_object_size (&action_obstack); obstack_grow (&table_obstack, @@ -1006,7 +1006,7 @@ output_parser (void) else { obstack_sgrow (&table_obstack, "%%"); - obstack_sgrow (&table_obstack, macro_key); + obstack_sgrow (&table_obstack, muscle_key); } } else @@ -1033,49 +1033,49 @@ free_itemsets (void) /* FIXME. */ -#define MACRO_INSERT_INT(Key, Value) \ -{ \ - obstack_fgrow1 (¯o_obstack, "%d", Value); \ - obstack_1grow (¯o_obstack, 0); \ - macro_insert (Key, obstack_finish (¯o_obstack)); \ +#define MUSCLE_INSERT_INT(Key, Value) \ +{ \ + obstack_fgrow1 (&muscle_obstack, "%d", Value); \ + obstack_1grow (&muscle_obstack, 0); \ + muscle_insert (Key, obstack_finish (&muscle_obstack)); \ } -#define MACRO_INSERT_STRING(Key, Value) \ -{ \ - obstack_sgrow (¯o_obstack, Value); \ - obstack_1grow (¯o_obstack, 0); \ - macro_insert (Key, obstack_finish (¯o_obstack)); \ +#define MUSCLE_INSERT_STRING(Key, Value) \ +{ \ + obstack_sgrow (&muscle_obstack, Value); \ + obstack_1grow (&muscle_obstack, 0); \ + muscle_insert (Key, obstack_finish (&muscle_obstack)); \ } -#define MACRO_INSERT_PREFIX(Key, Value) \ +#define MUSCLE_INSERT_PREFIX(Key, Value) \ { \ - obstack_fgrow2 (¯o_obstack, "%s%s", spec_name_prefix, Value); \ - obstack_1grow (¯o_obstack, 0); \ - macro_insert (Key, obstack_finish (¯o_obstack)); \ + obstack_fgrow2 (&muscle_obstack, "%s%s", spec_name_prefix, Value); \ + obstack_1grow (&muscle_obstack, 0); \ + muscle_insert (Key, obstack_finish (&muscle_obstack)); \ } static void prepare (void) { - MACRO_INSERT_INT ("last", high); - MACRO_INSERT_INT ("flag", MINSHORT); - MACRO_INSERT_INT ("pure", pure_parser); - MACRO_INSERT_INT ("nsym", nsyms); - MACRO_INSERT_INT ("debug", debug_flag); - MACRO_INSERT_INT ("final", final_state); - MACRO_INSERT_INT ("maxtok", max_user_token_number); - MACRO_INSERT_INT ("ntbase", ntokens); - MACRO_INSERT_INT ("verbose", 0); - - 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); + MUSCLE_INSERT_INT ("last", high); + MUSCLE_INSERT_INT ("flag", MINSHORT); + MUSCLE_INSERT_INT ("pure", pure_parser); + MUSCLE_INSERT_INT ("nsym", nsyms); + MUSCLE_INSERT_INT ("debug", debug_flag); + MUSCLE_INSERT_INT ("final", final_state); + MUSCLE_INSERT_INT ("maxtok", max_user_token_number); + MUSCLE_INSERT_INT ("ntbase", ntokens); + MUSCLE_INSERT_INT ("verbose", 0); + + MUSCLE_INSERT_INT ("nnts", nvars); + MUSCLE_INSERT_INT ("nrules", nrules); + MUSCLE_INSERT_INT ("nstates", nstates); + MUSCLE_INSERT_INT ("ntokens", ntokens); + + MUSCLE_INSERT_INT ("locations_flag", locations_flag); if (spec_name_prefix) - MACRO_INSERT_STRING ("prefix", spec_name_prefix); + MUSCLE_INSERT_STRING ("prefix", spec_name_prefix); } /*----------------------------------------------------------. @@ -1106,9 +1106,9 @@ output (void) #endif prepare (); /* Copy definitions in directive. */ - macro_insert ("prologue", obstack_finish (&attrs_obstack)); + muscle_insert ("prologue", obstack_finish (&attrs_obstack)); output_parser (); - obstack_free (¯o_obstack, 0); + obstack_free (&muscle_obstack, 0); obstack_free (&output_obstack, 0); } diff --git a/src/reader.c b/src/reader.c index 49e5158e..3f3a3a34 100644 --- a/src/reader.c +++ b/src/reader.c @@ -34,7 +34,7 @@ #include "output.h" #include "reader.h" #include "conflicts.h" -#include "macrotab.h" +#include "muscle_tab.h" /* Number of slots allocated (but not necessarily used yet) in `rline' */ static int rline_allocated; @@ -750,7 +750,7 @@ parse_union_decl (void) if (!no_lines_flag) obstack_fgrow2 (&attrs_obstack, "\n#line %d %s\n", lineno, quotearg_style (c_quoting_style, - macro_find("filename"))); + muscle_find("filename"))); else obstack_1grow (&attrs_obstack, '\n'); @@ -903,11 +903,11 @@ parse_thong_decl (void) /* FIXME. */ static void -parse_macro_decl (void) +parse_muscle_decl (void) { int ch = ungetc (skip_white_space (), finput); - char* macro_key; - char* macro_value; + char* muscle_key; + char* muscle_value; /* Read key. */ if (!isalpha (ch) && ch != '_') @@ -916,9 +916,9 @@ parse_macro_decl (void) skip_to_char ('%'); return; } - copy_identifier (finput, ¯o_obstack); - obstack_1grow (¯o_obstack, 0); - macro_key = obstack_finish (¯o_obstack); + copy_identifier (finput, &muscle_obstack); + obstack_1grow (&muscle_obstack, 0); + muscle_key = obstack_finish (&muscle_obstack); /* Read value. */ ch = skip_white_space (); @@ -934,12 +934,12 @@ parse_macro_decl (void) else fatal (_("Premature EOF after %s"), "\""); } - copy_string2 (finput, ¯o_obstack, '"', 0); - obstack_1grow (¯o_obstack, 0); - macro_value = obstack_finish (¯o_obstack); + copy_string2 (finput, &muscle_obstack, '"', 0); + obstack_1grow (&muscle_obstack, 0); + muscle_value = obstack_finish (&muscle_obstack); /* Store the (key, value) pair in the environment. */ - macro_insert (macro_key, macro_value); + muscle_insert (muscle_key, muscle_value); } @@ -1061,7 +1061,7 @@ read_declarations (void) break; case tok_define: - parse_macro_decl (); + parse_muscle_decl (); break; case tok_skel: @@ -1113,7 +1113,7 @@ copy_action (symbol_list *rule, int stack_offset) { sprintf (buf, "#line %d %s\n", lineno, quotearg_style (c_quoting_style, - macro_find ("filename"))); + muscle_find ("filename"))); obstack_grow (&action_obstack, buf, strlen (buf)); } obstack_1grow (&action_obstack, '{'); @@ -1202,7 +1202,7 @@ copy_guard (symbol_list *rule, int stack_offset) if (!no_lines_flag) obstack_fgrow2 (&guard_obstack, "#line %d %s\n", lineno, quotearg_style (c_quoting_style, - macro_find ("filename"))); + muscle_find ("filename"))); obstack_1grow (&guard_obstack, '{'); count = 0; @@ -1683,7 +1683,7 @@ read_additionnal_code (void) obstack_1grow (&el_obstack, c); obstack_1grow (&el_obstack, 0); - macro_insert ("epilogue", obstack_finish (&el_obstack)); + muscle_insert ("epilogue", obstack_finish (&el_obstack)); } @@ -1853,7 +1853,7 @@ packsymbols (void) output_token_defines (&output_obstack); obstack_1grow (&output_obstack, 0); - macro_insert ("tokendef", obstack_finish (&output_obstack)); + muscle_insert ("tokendef", obstack_finish (&output_obstack)); #if 0 if (!no_parser_flag) @@ -2005,8 +2005,8 @@ reader (void) init_lex (); lineno = 1; - /* Initialize the macro obstack. */ - obstack_init (¯o_obstack); + /* Initialize the muscle obstack. */ + obstack_init (&muscle_obstack); /* Initialize the symbol table. */ tabinit (); diff --git a/src/reader.h b/src/reader.h index 7cdd6941..4a721ba7 100644 --- a/src/reader.h +++ b/src/reader.h @@ -36,6 +36,6 @@ extern int lineno; extern char **tags; extern short *user_toknums; -extern struct obstack macro_obstack; +extern struct obstack muscle_obstack; #endif /* !READER_H_ */ -- 2.47.2