better error checking

This commit is contained in:
ceriel 1989-12-07 16:28:05 +00:00
parent 2f5b25269e
commit a8033da29e
2 changed files with 21 additions and 10 deletions

View file

@ -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*/

View file

@ -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--