From b68e774421d1896baa27a022842b0fc62c2f06ed Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 29 Dec 2001 14:17:43 +0000 Subject: [PATCH] * 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. --- ChangeLog | 8 ++++++++ src/reader.c | 33 +++++++++++++++++---------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index c0d5aa94..df10e43f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-12-29 Akim Demaille + + * 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 * tests/regression.at (Web2c Report): Catch up: the rule 0 is now diff --git a/src/reader.c b/src/reader.c index fcfb2c94..bebbc153 100644 --- a/src/reader.c +++ b/src/reader.c @@ -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; } -- 2.45.2