* src/reader.c (readgram): Don't add the rule 0 if there were no

rules read.  In other words, add it _after_ having performed
grammar sanity checks.
Fixes the `tests/regression.at (Invalid input: 1)' Failure.
This commit is contained in:
Akim Demaille
2001-12-29 14:17:43 +00:00
parent 78d5bae94e
commit b68e774421
2 changed files with 25 additions and 16 deletions

View File

@@ -1,3 +1,11 @@
2001-12-29 Akim Demaille <akim@epita.fr>
* src/reader.c (readgram): Don't add the rule 0 if there were no
rules read. In other words, add it _after_ having performed
grammar sanity checks.
Fixes the `tests/regression.at (Invalid input: 1)' Failure.
2001-12-29 Akim Demaille <akim@epita.fr>
* tests/regression.at (Web2c Report): Catch up: the rule 0 is now

View File

@@ -1451,6 +1451,23 @@ readgram (void)
t = lex ();
}
/* grammar has been read. Do some checking */
if (nrules == 0)
fatal (_("no rules in the input grammar"));
/* Report any undefined symbols and consider them nonterminals. */
for (bp = firstsymbol; bp; bp = bp->next)
if (bp->class == unknown_sym)
{
complain (_
("symbol %s is used, but is not defined as a token and has no rules"),
bp->tag);
bp->class = nterm_sym;
bp->value = nvars++;
}
/* Insert the initial rule, which line is that of the first rule
(not that of the start symbol):
@@ -1466,25 +1483,9 @@ readgram (void)
grammar = p;
startval = axiom;
/* grammar has been read. Do some checking */
if (nsyms > MAXSHORT)
fatal (_("too many symbols (tokens plus nonterminals); maximum %d"),
MAXSHORT);
if (nrules == 0)
fatal (_("no rules in the input grammar"));
/* Report any undefined symbols and consider them nonterminals. */
for (bp = firstsymbol; bp; bp = bp->next)
if (bp->class == unknown_sym)
{
complain (_
("symbol %s is used, but is not defined as a token and has no rules"),
bp->tag);
bp->class = nterm_sym;
bp->value = nvars++;
}
ntokens = nsyms - nvars;
}