uses `isspace' to recognize space characters

This commit is contained in:
Roberto Ierusalimschy
2002-06-03 17:12:21 -03:00
parent ad7103ea3a
commit c398a02110

52
llex.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: llex.c,v 1.102 2002/05/16 18:39:46 roberto Exp roberto $ ** $Id: llex.c,v 1.103 2002/06/03 14:09:57 roberto Exp roberto $
** Lexical Analyzer ** Lexical Analyzer
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -306,15 +306,11 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
for (;;) { for (;;) {
switch (LS->current) { switch (LS->current) {
case ' ': case '\t': case '\r': /* `\r' to avoid problems with DOS */ case '\n': {
next(LS);
continue;
case '\n':
inclinenumber(LS); inclinenumber(LS);
continue; continue;
}
case '-': case '-': {
next(LS); next(LS);
if (LS->current != '-') return '-'; if (LS->current != '-') return '-';
/* else is a comment */ /* else is a comment */
@@ -325,41 +321,41 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
while (LS->current != '\n' && LS->current != EOZ) while (LS->current != '\n' && LS->current != EOZ)
next(LS); next(LS);
continue; continue;
}
case '[': case '[': {
next(LS); next(LS);
if (LS->current != '[') return '['; if (LS->current != '[') return '[';
else { else {
read_long_string(LS, seminfo); read_long_string(LS, seminfo);
return TK_STRING; return TK_STRING;
} }
}
case '=': case '=': {
next(LS); next(LS);
if (LS->current != '=') return '='; if (LS->current != '=') return '=';
else { next(LS); return TK_EQ; } else { next(LS); return TK_EQ; }
}
case '<': case '<': {
next(LS); next(LS);
if (LS->current != '=') return '<'; if (LS->current != '=') return '<';
else { next(LS); return TK_LE; } else { next(LS); return TK_LE; }
}
case '>': case '>': {
next(LS); next(LS);
if (LS->current != '=') return '>'; if (LS->current != '=') return '>';
else { next(LS); return TK_GE; } else { next(LS); return TK_GE; }
}
case '~': case '~': {
next(LS); next(LS);
if (LS->current != '=') return '~'; if (LS->current != '=') return '~';
else { next(LS); return TK_NE; } else { next(LS); return TK_NE; }
}
case '"': case '"':
case '\'': case '\'': {
read_string(LS, LS->current, seminfo); read_string(LS, LS->current, seminfo);
return TK_STRING; return TK_STRING;
}
case '.': case '.': {
next(LS); next(LS);
if (LS->current == '.') { if (LS->current == '.') {
next(LS); next(LS);
@@ -374,12 +370,16 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
read_number(LS, 1, seminfo); read_number(LS, 1, seminfo);
return TK_NUMBER; return TK_NUMBER;
} }
}
case EOZ: case EOZ: {
return TK_EOS; return TK_EOS;
}
default: { default: {
if (isdigit(LS->current)) { if (isspace(LS->current)) {
next(LS);
continue;
}
else if (isdigit(LS->current)) {
read_number(LS, 0, seminfo); read_number(LS, 0, seminfo);
return TK_NUMBER; return TK_NUMBER;
} }