better error checking
This commit is contained in:
parent
2f5b25269e
commit
a8033da29e
|
@ -233,6 +233,20 @@ CheckForLineDirective()
|
||||||
LineNumber = i;
|
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
|
int
|
||||||
LLlex()
|
LLlex()
|
||||||
{
|
{
|
||||||
|
@ -507,6 +521,7 @@ again:
|
||||||
tk->TOK_INT < 0) {
|
tk->TOK_INT < 0) {
|
||||||
lexwarning(W_ORDINARY, "character constant out of range");
|
lexwarning(W_ORDINARY, "character constant out of range");
|
||||||
}
|
}
|
||||||
|
CheckForLet();
|
||||||
return tk->tk_symb = INTEGER;
|
return tk->tk_symb = INTEGER;
|
||||||
}
|
}
|
||||||
if (ch == 'D' && base == 10) {
|
if (ch == 'D' && base == 10) {
|
||||||
|
@ -528,6 +543,7 @@ lexwarning(W_ORDINARY, "character constant out of range");
|
||||||
}
|
}
|
||||||
if (ovfl)
|
if (ovfl)
|
||||||
lexwarning(W_ORDINARY, "overflow in constant");
|
lexwarning(W_ORDINARY, "overflow in constant");
|
||||||
|
CheckForLet();
|
||||||
return tk->tk_symb = INTEGER;
|
return tk->tk_symb = INTEGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,6 +618,7 @@ lexwarning(W_ORDINARY, "overflow in constant");
|
||||||
lexerror("real constant too long");
|
lexerror("real constant too long");
|
||||||
}
|
}
|
||||||
else tk->TOK_REL = Salloc(buf, (unsigned) (np - buf)) + 1;
|
else tk->TOK_REL = Salloc(buf, (unsigned) (np - buf)) + 1;
|
||||||
|
CheckForLet();
|
||||||
return tk->tk_symb = REAL;
|
return tk->tk_symb = REAL;
|
||||||
|
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
|
|
@ -9,8 +9,8 @@ symbol2str(tok)
|
||||||
{
|
{
|
||||||
#define SIZBUF 8
|
#define SIZBUF 8
|
||||||
/* allow for a few invocations in f.i. an argument list */
|
/* allow for a few invocations in f.i. an argument list */
|
||||||
static char buf[SIZBUF];
|
static char buf[SIZBUF] = { '\'', 0, '\'', 0, '\'', 0, '\'', 0};
|
||||||
static int index;
|
static int index = 1;
|
||||||
|
|
||||||
switch (tok) {
|
switch (tok) {
|
||||||
--EOT--
|
--EOT--
|
||||||
|
@ -27,15 +27,9 @@ cat <<'--EOT--'
|
||||||
if (tok < 040 || tok >= 0177) {
|
if (tok < 040 || tok >= 0177) {
|
||||||
return "bad token";
|
return "bad token";
|
||||||
}
|
}
|
||||||
/* fall through */
|
index = (index+4) & (SIZBUF-1);
|
||||||
case '\n':
|
|
||||||
case '\f':
|
|
||||||
case '\v':
|
|
||||||
case '\r':
|
|
||||||
case '\t':
|
|
||||||
index = (index+2) & (SIZBUF-1);
|
|
||||||
buf[index] = tok;
|
buf[index] = tok;
|
||||||
return &buf[index];
|
return &buf[index-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--EOT--
|
--EOT--
|
||||||
|
|
Loading…
Reference in a new issue