* src/reader.c (record_rule_lines, rline, rline_allocated): Remove.
* src/output.c: Adjust.
+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...
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.
extern short *sprec;
extern short *sassoc;
-extern short *rline; /* Source line number of each rule */
extern int start_symbol;
short prec;
short precsym;
short assoc;
+ short line;
} rule_t;
extern struct rule_s *rule_table;
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++)
}
\f
-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. |
nrules++;
nitems++;
- record_rule_line ();
-
p = XCALLOC (symbol_list, 1);
p->sym = lhs;
just read can belong to it. */
nrules++;
nitems++;
- record_rule_line ();
p = XCALLOC (symbol_list, 1);
if (crule1)
crule1->next = p;
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++;
{
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;
nvars = 0;
nrules = 0;
nitems = 0;
- rline_allocated = 10;
- rline = XCALLOC (short, rline_allocated);
typed = 0;
lastprec = 0;
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];
res->user_token_number = SUNDEF;
res->alias = NULL;
res->class = unknown_sym;
+ res->line = lineno;
nsyms++;
struct bucket *link;
struct bucket *next;
+ /* The line it was found in. */
+ short line;
+
/* The key, name of the symbol. */
char *tag;
/* Its type. */