* 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.
This commit is contained in:
Marc Autret
2001-09-02 15:43:29 +00:00
parent a0ed1cb86a
commit 11d82f03b4
6 changed files with 124 additions and 89 deletions

View File

@@ -1,3 +1,38 @@
2001-09-02 Marc Autret <autret_m@epita.fr>
* 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 <autret_m@epita.fr> 2001-09-02 Marc Autret <autret_m@epita.fr>
Now the files macro_tab.[ch] are named muscle_tab.[ch]. Now the files macro_tab.[ch] are named muscle_tab.[ch].

View File

@@ -13,19 +13,19 @@ bin_PROGRAMS = bison
bison_SOURCES = LR0.c closure.c complain.c conflicts.c \ bison_SOURCES = LR0.c closure.c complain.c conflicts.c \
derives.c \ derives.c \
files.c getargs.c gram.c lalr.c lex.c main.c nullable.c \ files.c getargs.c gram.c lalr.c lex.c main.c nullable.c \
output.c \ output.c print_graph.c \
macrotab.c \ muscle_tab.c \
print.c reader.c reduce.c symtab.c warshall.c vcg.c print_graph.c print.c reader.c reduce.c symtab.c warshall.c vcg.c
EXTRA_bison_SOURCES = vmsgetargs.c EXTRA_bison_SOURCES = vmsgetargs.c
noinst_HEADERS = LR0.h closure.h complain.h conflicts.h \ noinst_HEADERS = LR0.h closure.h complain.h conflicts.h \
derives.h \ derives.h \
files.h getargs.h gram.h lalr.h lex.h nullable.h \ files.h getargs.h gram.h lalr.h lex.h nullable.h \
output.h state.h \ output.h print_graph.h \
macrotab.h \ muscle_tab.h \
print.h reader.h reduce.h symtab.h warshall.h system.h types.h \ print.h reader.h reduce.h state.h symtab.h warshall.h system.h \
vcg.h vcg_defaults.h print_graph.h types.h vcg.h vcg_defaults.h
pkgdata_DATA = bison.simple bison.hairy pkgdata_DATA = bison.simple bison.hairy

View File

@@ -34,7 +34,7 @@
#include "LR0.h" #include "LR0.h"
#include "conflicts.h" #include "conflicts.h"
#include "print_graph.h" #include "print_graph.h"
#include "macrotab.h" #include "muscle_tab.h"
/* The name this program was run with, for messages. */ /* The name this program was run with, for messages. */
char *program_name; char *program_name;
@@ -52,7 +52,7 @@ main (int argc, char *argv[])
lineno = 0; lineno = 0;
getargs (argc, argv); getargs (argc, argv);
macro_init (); muscle_init ();
open_files (); open_files ();
/* Read the input. Copy some parts of it to FGUARD, FACTION, FTABLE /* Read the input. Copy some parts of it to FGUARD, FACTION, FTABLE

View File

@@ -103,7 +103,7 @@
#include "lalr.h" #include "lalr.h"
#include "reader.h" #include "reader.h"
#include "conflicts.h" #include "conflicts.h"
#include "macrotab.h" #include "muscle_tab.h"
extern void berror PARAMS((const char *)); extern void berror PARAMS((const char *));
@@ -123,7 +123,7 @@ static short *check;
static int lowzero; static int lowzero;
static int high; static int high;
struct obstack macro_obstack; struct obstack muscle_obstack;
struct obstack output_obstack; struct obstack output_obstack;
/* FIXME. */ /* FIXME. */
@@ -160,7 +160,7 @@ output_token_translations (void)
{ {
output_table_data (&output_obstack, token_translations, output_table_data (&output_obstack, token_translations,
0, 1, max_user_token_number + 1); 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, output_table_data (&output_obstack, rrhs,
0, 1, nrules + 1); 0, 1, nrules + 1);
macro_insert ("prhs", obstack_finish (&output_obstack)); muscle_insert ("prhs", obstack_finish (&output_obstack));
{ {
size_t yyrhs_size = 1; size_t yyrhs_size = 1;
@@ -185,7 +185,7 @@ output_gram (void)
output_table_data (&output_obstack, yyrhs, output_table_data (&output_obstack, yyrhs,
ritem[0], 1, yyrhs_size); ritem[0], 1, yyrhs_size);
macro_insert ("rhs", obstack_finish (&output_obstack)); muscle_insert ("rhs", obstack_finish (&output_obstack));
XFREE (yyrhs); XFREE (yyrhs);
} }
@@ -202,7 +202,7 @@ output_stos (void)
{ {
output_table_data (&output_obstack, accessing_symbol, output_table_data (&output_obstack, accessing_symbol,
0, 1, nstates); 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, output_table_data (&output_obstack, rline,
0, 1, nrules + 1); 0, 1, nrules + 1);
macro_insert ("rline", obstack_finish (&output_obstack)); muscle_insert ("rline", obstack_finish (&output_obstack));
j = 0; j = 0;
for (i = 0; i < nsyms; i++) for (i = 0; i < nsyms; i++)
@@ -267,17 +267,17 @@ output_rule_data (void)
/* Finish table and store. */ /* Finish table and store. */
obstack_1grow (&output_obstack, 0); obstack_1grow (&output_obstack, 0);
macro_insert ("tname", obstack_finish (&output_obstack)); muscle_insert ("tname", obstack_finish (&output_obstack));
/* Output YYTOKNUM. */ /* Output YYTOKNUM. */
output_table_data (&output_obstack, user_toknums, output_table_data (&output_obstack, user_toknums,
0, 1, ntokens + 1); 0, 1, ntokens + 1);
macro_insert ("toknum", obstack_finish (&output_obstack)); muscle_insert ("toknum", obstack_finish (&output_obstack));
/* Output YYR1. */ /* Output YYR1. */
output_table_data (&output_obstack, rlhs, output_table_data (&output_obstack, rlhs,
0, 1, nrules + 1); 0, 1, nrules + 1);
macro_insert ("r1", obstack_finish (&output_obstack)); muscle_insert ("r1", obstack_finish (&output_obstack));
XFREE (rlhs + 1); XFREE (rlhs + 1);
/* Output YYR2. */ /* Output YYR2. */
@@ -287,7 +287,7 @@ output_rule_data (void)
short_tab[nrules] = nitems - rrhs[nrules] - 1; short_tab[nrules] = nitems - rrhs[nrules] - 1;
output_table_data (&output_obstack, short_tab, output_table_data (&output_obstack, short_tab,
0, 1, nrules + 1); 0, 1, nrules + 1);
macro_insert ("r2", obstack_finish (&output_obstack)); muscle_insert ("r2", obstack_finish (&output_obstack));
XFREE (short_tab); XFREE (short_tab);
XFREE (rrhs + 1); XFREE (rrhs + 1);
@@ -536,7 +536,7 @@ token_actions (void)
output_table_data (&output_obstack, yydefact, output_table_data (&output_obstack, yydefact,
yydefact[0], 1, nstates); yydefact[0], 1, nstates);
macro_insert ("defact", obstack_finish (&output_obstack)); muscle_insert ("defact", obstack_finish (&output_obstack));
XFREE (actrow); XFREE (actrow);
XFREE (yydefact); XFREE (yydefact);
@@ -677,7 +677,7 @@ goto_actions (void)
output_table_data (&output_obstack, yydefgoto, output_table_data (&output_obstack, yydefgoto,
yydefgoto[0], 1, nsyms - ntokens); yydefgoto[0], 1, nsyms - ntokens);
macro_insert ("defgoto", obstack_finish (&output_obstack)); muscle_insert ("defgoto", obstack_finish (&output_obstack));
XFREE (state_count); XFREE (state_count);
XFREE (yydefgoto); XFREE (yydefgoto);
@@ -882,12 +882,12 @@ output_base (void)
/* Output pact. */ /* Output pact. */
output_table_data (&output_obstack, base, output_table_data (&output_obstack, base,
base[0], 1, nstates); base[0], 1, nstates);
macro_insert ("pact", obstack_finish (&output_obstack)); muscle_insert ("pact", obstack_finish (&output_obstack));
/* Output pgoto. */ /* Output pgoto. */
output_table_data (&output_obstack, base, output_table_data (&output_obstack, base,
base[nstates], nstates + 1, nvectors); base[nstates], nstates + 1, nvectors);
macro_insert ("pgoto", obstack_finish (&output_obstack)); muscle_insert ("pgoto", obstack_finish (&output_obstack));
XFREE (base); XFREE (base);
} }
@@ -898,7 +898,7 @@ output_table (void)
{ {
output_table_data (&output_obstack, table, output_table_data (&output_obstack, table,
table[0], 1, high + 1); table[0], 1, high + 1);
macro_insert ("table", obstack_finish (&output_obstack)); muscle_insert ("table", obstack_finish (&output_obstack));
XFREE (table); XFREE (table);
} }
@@ -908,7 +908,7 @@ output_check (void)
{ {
output_table_data (&output_obstack, check, output_table_data (&output_obstack, check,
check[0], 1, high + 1); check[0], 1, high + 1);
macro_insert ("check", obstack_finish (&output_obstack)); muscle_insert ("check", obstack_finish (&output_obstack));
XFREE (check); XFREE (check);
} }
@@ -983,21 +983,21 @@ output_parser (void)
} }
else if ((c = getc (fskel)) == '%') else if ((c = getc (fskel)) == '%')
{ {
/* Read the macro. */ /* Read the muscle. */
const char *macro_key = 0; const char *muscle_key = 0;
const char *macro_value = 0; const char *muscle_value = 0;
while (isalnum (c = getc (fskel)) || c == '_') while (isalnum (c = getc (fskel)) || c == '_')
obstack_1grow (&macro_obstack, c); obstack_1grow (&muscle_obstack, c);
obstack_1grow (&macro_obstack, 0); obstack_1grow (&muscle_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 (&macro_obstack); muscle_key = obstack_finish (&muscle_obstack);
macro_value = macro_find (macro_key); muscle_value = muscle_find (muscle_key);
if (macro_value) if (muscle_value)
obstack_sgrow (&table_obstack, macro_value); obstack_sgrow (&table_obstack, muscle_value);
else if (!strcmp (macro_key, "line")) else if (!strcmp (muscle_key, "line"))
obstack_fgrow1 (&table_obstack, "%d", line + 1); 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); size_t size = obstack_object_size (&action_obstack);
obstack_grow (&table_obstack, obstack_grow (&table_obstack,
@@ -1006,7 +1006,7 @@ output_parser (void)
else else
{ {
obstack_sgrow (&table_obstack, "%%"); obstack_sgrow (&table_obstack, "%%");
obstack_sgrow (&table_obstack, macro_key); obstack_sgrow (&table_obstack, muscle_key);
} }
} }
else else
@@ -1033,49 +1033,49 @@ free_itemsets (void)
/* FIXME. */ /* FIXME. */
#define MACRO_INSERT_INT(Key, Value) \ #define MUSCLE_INSERT_INT(Key, Value) \
{ \ { \
obstack_fgrow1 (&macro_obstack, "%d", Value); \ obstack_fgrow1 (&muscle_obstack, "%d", Value); \
obstack_1grow (&macro_obstack, 0); \ obstack_1grow (&muscle_obstack, 0); \
macro_insert (Key, obstack_finish (&macro_obstack)); \ muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} }
#define MACRO_INSERT_STRING(Key, Value) \ #define MUSCLE_INSERT_STRING(Key, Value) \
{ \ { \
obstack_sgrow (&macro_obstack, Value); \ obstack_sgrow (&muscle_obstack, Value); \
obstack_1grow (&macro_obstack, 0); \ obstack_1grow (&muscle_obstack, 0); \
macro_insert (Key, obstack_finish (&macro_obstack)); \ muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} }
#define MACRO_INSERT_PREFIX(Key, Value) \ #define MUSCLE_INSERT_PREFIX(Key, Value) \
{ \ { \
obstack_fgrow2 (&macro_obstack, "%s%s", spec_name_prefix, Value); \ obstack_fgrow2 (&muscle_obstack, "%s%s", spec_name_prefix, Value); \
obstack_1grow (&macro_obstack, 0); \ obstack_1grow (&muscle_obstack, 0); \
macro_insert (Key, obstack_finish (&macro_obstack)); \ muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} }
static void static void
prepare (void) prepare (void)
{ {
MACRO_INSERT_INT ("last", high); MUSCLE_INSERT_INT ("last", high);
MACRO_INSERT_INT ("flag", MINSHORT); MUSCLE_INSERT_INT ("flag", MINSHORT);
MACRO_INSERT_INT ("pure", pure_parser); MUSCLE_INSERT_INT ("pure", pure_parser);
MACRO_INSERT_INT ("nsym", nsyms); MUSCLE_INSERT_INT ("nsym", nsyms);
MACRO_INSERT_INT ("debug", debug_flag); MUSCLE_INSERT_INT ("debug", debug_flag);
MACRO_INSERT_INT ("final", final_state); MUSCLE_INSERT_INT ("final", final_state);
MACRO_INSERT_INT ("maxtok", max_user_token_number); MUSCLE_INSERT_INT ("maxtok", max_user_token_number);
MACRO_INSERT_INT ("ntbase", ntokens); MUSCLE_INSERT_INT ("ntbase", ntokens);
MACRO_INSERT_INT ("verbose", 0); MUSCLE_INSERT_INT ("verbose", 0);
MACRO_INSERT_INT ("nnts", nvars); MUSCLE_INSERT_INT ("nnts", nvars);
MACRO_INSERT_INT ("nrules", nrules); MUSCLE_INSERT_INT ("nrules", nrules);
MACRO_INSERT_INT ("nstates", nstates); MUSCLE_INSERT_INT ("nstates", nstates);
MACRO_INSERT_INT ("ntokens", ntokens); MUSCLE_INSERT_INT ("ntokens", ntokens);
MACRO_INSERT_INT ("locations_flag", locations_flag); MUSCLE_INSERT_INT ("locations_flag", locations_flag);
if (spec_name_prefix) 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 #endif
prepare (); prepare ();
/* Copy definitions in directive. */ /* Copy definitions in directive. */
macro_insert ("prologue", obstack_finish (&attrs_obstack)); muscle_insert ("prologue", obstack_finish (&attrs_obstack));
output_parser (); output_parser ();
obstack_free (&macro_obstack, 0); obstack_free (&muscle_obstack, 0);
obstack_free (&output_obstack, 0); obstack_free (&output_obstack, 0);
} }

View File

@@ -34,7 +34,7 @@
#include "output.h" #include "output.h"
#include "reader.h" #include "reader.h"
#include "conflicts.h" #include "conflicts.h"
#include "macrotab.h" #include "muscle_tab.h"
/* Number of slots allocated (but not necessarily used yet) in `rline' */ /* Number of slots allocated (but not necessarily used yet) in `rline' */
static int rline_allocated; static int rline_allocated;
@@ -750,7 +750,7 @@ parse_union_decl (void)
if (!no_lines_flag) if (!no_lines_flag)
obstack_fgrow2 (&attrs_obstack, "\n#line %d %s\n", obstack_fgrow2 (&attrs_obstack, "\n#line %d %s\n",
lineno, quotearg_style (c_quoting_style, lineno, quotearg_style (c_quoting_style,
macro_find("filename"))); muscle_find("filename")));
else else
obstack_1grow (&attrs_obstack, '\n'); obstack_1grow (&attrs_obstack, '\n');
@@ -903,11 +903,11 @@ parse_thong_decl (void)
/* FIXME. */ /* FIXME. */
static void static void
parse_macro_decl (void) parse_muscle_decl (void)
{ {
int ch = ungetc (skip_white_space (), finput); int ch = ungetc (skip_white_space (), finput);
char* macro_key; char* muscle_key;
char* macro_value; char* muscle_value;
/* Read key. */ /* Read key. */
if (!isalpha (ch) && ch != '_') if (!isalpha (ch) && ch != '_')
@@ -916,9 +916,9 @@ parse_macro_decl (void)
skip_to_char ('%'); skip_to_char ('%');
return; return;
} }
copy_identifier (finput, &macro_obstack); copy_identifier (finput, &muscle_obstack);
obstack_1grow (&macro_obstack, 0); obstack_1grow (&muscle_obstack, 0);
macro_key = obstack_finish (&macro_obstack); muscle_key = obstack_finish (&muscle_obstack);
/* Read value. */ /* Read value. */
ch = skip_white_space (); ch = skip_white_space ();
@@ -934,12 +934,12 @@ parse_macro_decl (void)
else else
fatal (_("Premature EOF after %s"), "\""); fatal (_("Premature EOF after %s"), "\"");
} }
copy_string2 (finput, &macro_obstack, '"', 0); copy_string2 (finput, &muscle_obstack, '"', 0);
obstack_1grow (&macro_obstack, 0); obstack_1grow (&muscle_obstack, 0);
macro_value = obstack_finish (&macro_obstack); muscle_value = obstack_finish (&muscle_obstack);
/* Store the (key, value) pair in the environment. */ /* 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; break;
case tok_define: case tok_define:
parse_macro_decl (); parse_muscle_decl ();
break; break;
case tok_skel: case tok_skel:
@@ -1113,7 +1113,7 @@ copy_action (symbol_list *rule, int stack_offset)
{ {
sprintf (buf, "#line %d %s\n", sprintf (buf, "#line %d %s\n",
lineno, quotearg_style (c_quoting_style, lineno, quotearg_style (c_quoting_style,
macro_find ("filename"))); muscle_find ("filename")));
obstack_grow (&action_obstack, buf, strlen (buf)); obstack_grow (&action_obstack, buf, strlen (buf));
} }
obstack_1grow (&action_obstack, '{'); obstack_1grow (&action_obstack, '{');
@@ -1202,7 +1202,7 @@ copy_guard (symbol_list *rule, int stack_offset)
if (!no_lines_flag) if (!no_lines_flag)
obstack_fgrow2 (&guard_obstack, "#line %d %s\n", obstack_fgrow2 (&guard_obstack, "#line %d %s\n",
lineno, quotearg_style (c_quoting_style, lineno, quotearg_style (c_quoting_style,
macro_find ("filename"))); muscle_find ("filename")));
obstack_1grow (&guard_obstack, '{'); obstack_1grow (&guard_obstack, '{');
count = 0; count = 0;
@@ -1683,7 +1683,7 @@ read_additionnal_code (void)
obstack_1grow (&el_obstack, c); obstack_1grow (&el_obstack, c);
obstack_1grow (&el_obstack, 0); 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); output_token_defines (&output_obstack);
obstack_1grow (&output_obstack, 0); obstack_1grow (&output_obstack, 0);
macro_insert ("tokendef", obstack_finish (&output_obstack)); muscle_insert ("tokendef", obstack_finish (&output_obstack));
#if 0 #if 0
if (!no_parser_flag) if (!no_parser_flag)
@@ -2005,8 +2005,8 @@ reader (void)
init_lex (); init_lex ();
lineno = 1; lineno = 1;
/* Initialize the macro obstack. */ /* Initialize the muscle obstack. */
obstack_init (&macro_obstack); obstack_init (&muscle_obstack);
/* Initialize the symbol table. */ /* Initialize the symbol table. */
tabinit (); tabinit ();

View File

@@ -36,6 +36,6 @@ extern int lineno;
extern char **tags; extern char **tags;
extern short *user_toknums; extern short *user_toknums;
extern struct obstack macro_obstack; extern struct obstack muscle_obstack;
#endif /* !READER_H_ */ #endif /* !READER_H_ */