From: ceriel Date: Thu, 7 Dec 1989 16:28:05 +0000 (+0000) Subject: better error checking X-Git-Tag: release-5-5~2016 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=a8033da29e76d5ce497c504e2942310bf86be80a;p=ack.git better error checking --- diff --git a/lang/m2/comp/LLlex.c b/lang/m2/comp/LLlex.c index e13405611..895904943 100644 --- a/lang/m2/comp/LLlex.c +++ b/lang/m2/comp/LLlex.c @@ -233,6 +233,20 @@ CheckForLineDirective() LineNumber = i; } +STATIC +CheckForLet() +{ + register int ch; + + LoadChar(ch); + if (ch != EOI) { + if (class(ch) == STIDF) { + lexerror("token separator required between identifier and number"); + } + PushBack(); + } +} + int LLlex() { @@ -507,6 +521,7 @@ again: tk->TOK_INT < 0) { lexwarning(W_ORDINARY, "character constant out of range"); } + CheckForLet(); return tk->tk_symb = INTEGER; } if (ch == 'D' && base == 10) { @@ -528,6 +543,7 @@ lexwarning(W_ORDINARY, "character constant out of range"); } if (ovfl) lexwarning(W_ORDINARY, "overflow in constant"); + CheckForLet(); return tk->tk_symb = INTEGER; } @@ -602,6 +618,7 @@ lexwarning(W_ORDINARY, "overflow in constant"); lexerror("real constant too long"); } else tk->TOK_REL = Salloc(buf, (unsigned) (np - buf)) + 1; + CheckForLet(); return tk->tk_symb = REAL; /*NOTREACHED*/ diff --git a/lang/m2/comp/make.tokcase b/lang/m2/comp/make.tokcase index 56d104ae2..2a74ca34b 100755 --- a/lang/m2/comp/make.tokcase +++ b/lang/m2/comp/make.tokcase @@ -9,8 +9,8 @@ symbol2str(tok) { #define SIZBUF 8 /* allow for a few invocations in f.i. an argument list */ - static char buf[SIZBUF]; - static int index; + static char buf[SIZBUF] = { '\'', 0, '\'', 0, '\'', 0, '\'', 0}; + static int index = 1; switch (tok) { --EOT-- @@ -27,15 +27,9 @@ cat <<'--EOT--' if (tok < 040 || tok >= 0177) { return "bad token"; } - /* fall through */ - case '\n': - case '\f': - case '\v': - case '\r': - case '\t': - index = (index+2) & (SIZBUF-1); + index = (index+4) & (SIZBUF-1); buf[index] = tok; - return &buf[index]; + return &buf[index-1]; } } --EOT--