* src/symtab.h, src/symtab.c: line' is a new member of bucket'.

* src/reader.c (record_rule_lines, rline, rline_allocated): Remove.
* src/output.c: Adjust.
This commit is contained in:
Akim Demaille
2001-11-19 10:26:16 +00:00
parent 652a871c29
commit e41dc70020
6 changed files with 31 additions and 25 deletions

View File

@@ -1,3 +1,10 @@
2001-11-19 Akim Demaille <akim@epita.fr>
* src/symtab.h, src/symtab.c: `line' is a new member of `bucket'.
* src/reader.c (record_rule_lines, rline, rline_allocated): Remove.
* src/output.c: Adjust.
2001-11-19 Akim Demaille <akim@epita.fr>
* src/gram.h (rprec, rprecsym, rassoc): Remove, now part of...

View File

@@ -55,7 +55,9 @@
RULE_TABLE[R].precsym -- the symbol-number of the symbol in %prec
for R (if any).
RULE_TABLE[R].assoc -- the associativity of the rule.
RULE_TABLE[R].assoc -- the associativity of R.
RULE_TABLE[R].line -- the line where R was defined.
The right hand side is stored as symbol numbers in a portion of
RITEM.
@@ -97,7 +99,6 @@ extern short *ritem;
extern short *sprec;
extern short *sassoc;
extern short *rline; /* Source line number of each rule */
extern int start_symbol;
@@ -117,6 +118,7 @@ typedef struct rule_s
short prec;
short precsym;
short assoc;
short line;
} rule_t;
extern struct rule_s *rule_table;

View File

@@ -225,9 +225,16 @@ output_rule_data (void)
int j;
short *short_tab = NULL;
output_table_data (&output_obstack, rline,
0, 1, nrules + 1);
muscle_insert ("rline", obstack_finish (&output_obstack));
{
short *values = XCALLOC (short, nrules + 1);
for (i = 0; i < nrules + 1; ++i)
values[i] = rule_table[i].line;
output_table_data (&output_obstack, values,
0, 1, nrules + 1);
muscle_insert ("rline", obstack_finish (&output_obstack));
XFREE (values);
}
j = 0;
for (i = 0; i < nsyms; i++)

View File

@@ -1251,20 +1251,6 @@ copy_guard (symbol_list *rule, int stack_offset)
}
static void
record_rule_line (void)
{
/* Record each rule's source line number in rline table. */
if (nrules >= rline_allocated)
{
rline_allocated = nrules * 2;
rline = XREALLOC (rline, short, rline_allocated);
}
rline[nrules] = lineno;
}
/*-------------------------------------------------------------------.
| Generate a dummy symbol, a nonterminal, whose name cannot conflict |
| with the user's names. |
@@ -1407,8 +1393,6 @@ readgram (void)
nrules++;
nitems++;
record_rule_line ();
p = XCALLOC (symbol_list, 1);
p->sym = lhs;
@@ -1486,7 +1470,6 @@ readgram (void)
just read can belong to it. */
nrules++;
nitems++;
record_rule_line ();
p = XCALLOC (symbol_list, 1);
if (crule1)
crule1->next = p;
@@ -1494,9 +1477,10 @@ readgram (void)
grammar = p;
p->sym = sdummy;
crule1 = XCALLOC (symbol_list, 1);
p->next = crule1;
crule1->next = crule;
p->next = crule1;
/* Insert the dummy generated by that rule into this
rule. */
nitems++;
@@ -1932,6 +1916,7 @@ packgram (void)
{
rule_table[ruleno].lhs = p->sym->value;
rule_table[ruleno].rhs = itemno;
rule_table[ruleno].line = p->sym->line;
ruleprec = p->ruleprec;
p = p->next;
@@ -1986,8 +1971,6 @@ reader (void)
nvars = 0;
nrules = 0;
nitems = 0;
rline_allocated = 10;
rline = XCALLOC (short, rline_allocated);
typed = 0;
lastprec = 0;

View File

@@ -49,6 +49,9 @@ hash (const char *key)
static bucket *
bucket_new (const char *tag, int hashval)
{
/* Hack, until we have a Bison parser. */
extern int lineno;
bucket *res = XMALLOC (bucket, 1);
res->link = symtab[hashval];
@@ -61,6 +64,7 @@ bucket_new (const char *tag, int hashval)
res->user_token_number = SUNDEF;
res->alias = NULL;
res->class = unknown_sym;
res->line = lineno;
nsyms++;

View File

@@ -42,6 +42,9 @@ typedef struct bucket
struct bucket *link;
struct bucket *next;
/* The line it was found in. */
short line;
/* The key, name of the symbol. */
char *tag;
/* Its type. */