* 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 09:13:12 +00:00
parent 9291f914de
commit 35f61cb998
6 changed files with 31 additions and 26 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> 2001-11-19 Akim Demaille <akim@epita.fr>
* src/gram.h (rprec, rprecsym, rassoc): Remove, now part of... * 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 RULE_TABLE[R].precsym -- the symbol-number of the symbol in %prec
for R (if any). 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 The right hand side is stored as symbol numbers in a portion of
RITEM. RITEM.
@@ -97,7 +99,6 @@ extern short *ritem;
extern short *sprec; extern short *sprec;
extern short *sassoc; extern short *sassoc;
extern short *rline; /* Source line number of each rule */
extern int start_symbol; extern int start_symbol;
@@ -117,6 +118,7 @@ typedef struct rule_s
short prec; short prec;
short precsym; short precsym;
short assoc; short assoc;
short line;
} rule_t; } rule_t;
extern struct rule_s *rule_table; extern struct rule_s *rule_table;

View File

@@ -375,10 +375,16 @@ output_rule_data (void)
obstack_sgrow (&table_obstack, "\n\ obstack_sgrow (&table_obstack, "\n\
#if YYDEBUG != 0\n"); #if YYDEBUG != 0\n");
output_short_table (&table_obstack, {
"YYRLINE[YYN] -- source line where rule number YYN was defined", short *values = XCALLOC (short, nrules + 1);
"yyrline", rline, for (i = 0; i < nrules + 1; ++i)
0, 1, nrules + 1); values[i] = rule_table[i].line;
output_short_table (&table_obstack,
"YYRLINE[YYN] -- source line where rule number YYN was defined",
"yyrline", values,
0, 1, nrules + 1);
XFREE (values);
}
obstack_sgrow (&table_obstack, "#endif\n\n"); obstack_sgrow (&table_obstack, "#endif\n\n");

View File

@@ -1215,20 +1215,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 | | Generate a dummy symbol, a nonterminal, whose name cannot conflict |
| with the user's names. | | with the user's names. |
@@ -1371,8 +1357,6 @@ readgram (void)
nrules++; nrules++;
nitems++; nitems++;
record_rule_line ();
p = XCALLOC (symbol_list, 1); p = XCALLOC (symbol_list, 1);
p->sym = lhs; p->sym = lhs;
@@ -1450,7 +1434,6 @@ readgram (void)
just read can belong to it. */ just read can belong to it. */
nrules++; nrules++;
nitems++; nitems++;
record_rule_line ();
p = XCALLOC (symbol_list, 1); p = XCALLOC (symbol_list, 1);
if (crule1) if (crule1)
crule1->next = p; crule1->next = p;
@@ -1458,9 +1441,10 @@ readgram (void)
grammar = p; grammar = p;
p->sym = sdummy; p->sym = sdummy;
crule1 = XCALLOC (symbol_list, 1); crule1 = XCALLOC (symbol_list, 1);
p->next = crule1;
crule1->next = crule; crule1->next = crule;
p->next = crule1;
/* Insert the dummy generated by that rule into this /* Insert the dummy generated by that rule into this
rule. */ rule. */
nitems++; nitems++;
@@ -1884,6 +1868,7 @@ packgram (void)
{ {
rule_table[ruleno].lhs = p->sym->value; rule_table[ruleno].lhs = p->sym->value;
rule_table[ruleno].rhs = itemno; rule_table[ruleno].rhs = itemno;
rule_table[ruleno].line = p->sym->line;
ruleprec = p->ruleprec; ruleprec = p->ruleprec;
p = p->next; p = p->next;
@@ -1938,8 +1923,6 @@ reader (void)
nvars = 0; nvars = 0;
nrules = 0; nrules = 0;
nitems = 0; nitems = 0;
rline_allocated = 10;
rline = XCALLOC (short, rline_allocated);
typed = 0; typed = 0;
lastprec = 0; lastprec = 0;

View File

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

View File

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