symbol is kept, only the line of the first occurrence is kept too.
* src/symtab.h, src/symtab.c (bucket): Remove the line member.
* src/reader.c (rline_allocated): Remove, unused.
(symbol_list): Have a `line' member.
(symbol_list_new): New.
(readgram): Use it.
* src/print.c (print_grammar): Output the rule line numbers.
* tests/regression.at (Solved SR Conflicts)
(Unresolved SR Conflicts): Adjust.
Reported by Hans Aberg.
+2001-11-23 Akim Demaille <akim@epita.fr>
+
+ Attaching lineno to buckets is stupid, since only one copy of each
+ symbol is kept, only the line of the first occurrence is kept too.
+
+ * src/symtab.h, src/symtab.c (bucket): Remove the line member.
+ * src/reader.c (rline_allocated): Remove, unused.
+ (symbol_list): Have a `line' member.
+ (symbol_list_new): New.
+ (readgram): Use it.
+ * src/print.c (print_grammar): Output the rule line numbers.
+ * tests/regression.at (Solved SR Conflicts)
+ (Unresolved SR Conflicts): Adjust.
+ Reported by Hans Aberg.
+
2001-11-22 Marc Autret <autret_m@epita.fr>
* src/bison.simple [YYERROR_VERBOSE]: Force its value to be 1 or 0.
2001-11-22 Marc Autret <autret_m@epita.fr>
* src/bison.simple [YYERROR_VERBOSE]: Force its value to be 1 or 0.
/* rule # : LHS -> RHS */
fprintf (out, "\n%s\n\n", _("Grammar"));
/* rule # : LHS -> RHS */
fprintf (out, "\n%s\n\n", _("Grammar"));
+ fprintf (out, " %s\n", _("Number, Line, Rule"));
for (i = 1; i <= nrules; i++)
/* Don't print rules disabled in reduce_grammar_tables. */
if (rule_table[i].lhs >= 0)
{
for (i = 1; i <= nrules; i++)
/* Don't print rules disabled in reduce_grammar_tables. */
if (rule_table[i].lhs >= 0)
{
- fprintf (out, _("rule %-4d %s ->"), i, tags[rule_table[i].lhs]);
+ fprintf (out, _(" %3d %3d %s ->"),
+ i, rule_table[i].line, tags[rule_table[i].lhs]);
rule = &ritem[rule_table[i].rhs];
if (*rule > 0)
while (*rule > 0)
fprintf (out, " %s", tags[*rule++]);
else
rule = &ritem[rule_table[i].rhs];
if (*rule > 0)
while (*rule > 0)
fprintf (out, " %s", tags[*rule++]);
else
- fprintf (out, " /* %s */", _("empty"));
+ fprintf (out, " /* %s */", _("empty"));
#include "conflicts.h"
#include "muscle_tab.h"
#include "conflicts.h"
#include "muscle_tab.h"
-/* Number of slots allocated (but not necessarily used yet) in `rline' */
-static int rline_allocated;
-
typedef struct symbol_list
{
struct symbol_list *next;
bucket *sym;
typedef struct symbol_list
{
struct symbol_list *next;
bucket *sym;
bucket *ruleprec;
}
symbol_list;
bucket *ruleprec;
}
symbol_list;
static bucket *errtoken;
static bucket *undeftoken;
static bucket *errtoken;
static bucket *undeftoken;
+
+
+symbol_list *
+symbol_list_new (bucket *sym)
+{
+ symbol_list *res = XMALLOC (symbol_list, 1);
+ res->next = NULL;
+ res->sym = sym;
+ res->line = lineno;
+ res->ruleprec = NULL;
+ return res;
+}
+
\f
/*===================\
\f
/*===================\
`--------------------------------------------------------------*/
static char *
`--------------------------------------------------------------*/
static char *
-get_type_name (int n, symbol_list * rule)
+get_type_name (int n, symbol_list *rule)
{
int i;
symbol_list *rp;
{
int i;
symbol_list *rp;
else
{
complain (_("`%s' is invalid in %s"),
else
{
complain (_("`%s' is invalid in %s"),
- token_buffer, (what_is == token_sym) ? "%token" : "%nterm");
+ token_buffer,
+ (what_is == token_sym) ? "%token" : "%nterm");
- p = XCALLOC (symbol_list, 1);
- p->sym = lhs;
+ p = symbol_list_new (lhs);
non-terminal. */
if (action_flag)
{
non-terminal. */
if (action_flag)
{
/* Since the action was written out with this rule's
number, we must give the new rule this number by
inserting the new rule before it. */
/* Make a dummy nonterminal, a gensym. */
/* Since the action was written out with this rule's
number, we must give the new rule this number by
inserting the new rule before it. */
/* Make a dummy nonterminal, a gensym. */
+ bucket *sdummy = gensym ();
/* Make a new rule, whose body is empty,
before the current one, so that the action
just read can belong to it. */
nrules++;
nitems++;
/* Make a new rule, whose body is empty,
before the current one, so that the action
just read can belong to it. */
nrules++;
nitems++;
- p = XCALLOC (symbol_list, 1);
+ p = symbol_list_new (sdummy);
if (crule1)
crule1->next = p;
else
grammar = p;
if (crule1)
crule1->next = p;
else
grammar = p;
- p->sym = sdummy;
- crule1 = XCALLOC (symbol_list, 1);
+ /* End of the rule. */
+ crule1 = symbol_list_new (NULL);
crule1->next = crule;
p->next = crule1;
crule1->next = crule;
p->next = crule1;
/* Insert the dummy generated by that rule into this
rule. */
nitems++;
/* Insert the dummy generated by that rule into this
rule. */
nitems++;
- p = XCALLOC (symbol_list, 1);
- p->sym = sdummy;
+ p = symbol_list_new (sdummy);
if (t == tok_identifier)
{
nitems++;
if (t == tok_identifier)
{
nitems++;
- p = XCALLOC (symbol_list, 1);
- p->sym = symval;
+ p = symbol_list_new (symval);
} /* end of read rhs of rule */
/* Put an empty link in the list to mark the end of this rule */
} /* end of read rhs of rule */
/* Put an empty link in the list to mark the end of this rule */
- p = XCALLOC (symbol_list, 1);
+ p = symbol_list_new (NULL);
int ruleno;
symbol_list *p;
int ruleno;
symbol_list *p;
ritem = XCALLOC (short, nitems + 1);
rule_table = XCALLOC (rule_t, nrules) - 1;
ritem = XCALLOC (short, nitems + 1);
rule_table = XCALLOC (rule_t, nrules) - 1;
+ bucket *ruleprec = p->ruleprec;
rule_table[ruleno].lhs = p->sym->value;
rule_table[ruleno].rhs = itemno;
rule_table[ruleno].lhs = p->sym->value;
rule_table[ruleno].rhs = itemno;
- rule_table[ruleno].line = p->sym->line;
- ruleprec = p->ruleprec;
+ rule_table[ruleno].line = p->line;
p = p->next;
while (p && p->sym)
p = p->next;
while (p && p->sym)
static bucket *
bucket_new (const char *tag, int hashval)
{
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];
bucket *res = XMALLOC (bucket, 1);
res->link = symtab[hashval];
res->user_token_number = SUNDEF;
res->alias = NULL;
res->class = unknown_sym;
res->user_token_number = SUNDEF;
res->alias = NULL;
res->class = unknown_sym;
struct bucket *link;
struct bucket *next;
struct bucket *link;
struct bucket *next;
- /* The line it was found in. */
- short line;
-
/* The key, name of the symbol. */
char *tag;
/* Its type. */
/* The key, name of the symbol. */
char *tag;
/* Its type. */
-rule 1 exp -> exp OP exp
-rule 2 exp -> NUM
+ Number, Line, Rule
+ 1 3 exp -> exp OP exp
+ 2 3 exp -> NUM
Terminals, with rules where they appear
Terminals, with rules where they appear
-rule 1 exp -> exp OP exp
-rule 2 exp -> NUM
+ Number, Line, Rule
+ 1 4 exp -> exp OP exp
+ 2 4 exp -> NUM
Terminals, with rules where they appear
Terminals, with rules where they appear