|
@@ -1,11 +1,10 @@
|
|
|
/*
|
|
|
-** $Id: llex.c,v 2.29 2008/12/26 11:55:57 roberto Exp roberto $
|
|
|
+** $Id: llex.c,v 2.30 2009/02/11 18:25:20 roberto Exp roberto $
|
|
|
** Lexical Analyzer
|
|
|
** See Copyright Notice in lua.h
|
|
|
*/
|
|
|
|
|
|
|
|
|
-#include <ctype.h>
|
|
|
#include <locale.h>
|
|
|
#include <string.h>
|
|
|
|
|
@@ -14,6 +13,7 @@
|
|
|
|
|
|
#include "lua.h"
|
|
|
|
|
|
+#include "lctype.h"
|
|
|
#include "ldo.h"
|
|
|
#include "llex.h"
|
|
|
#include "lobject.h"
|
|
@@ -77,7 +77,7 @@ void luaX_init (lua_State *L) {
|
|
|
const char *luaX_token2str (LexState *ls, int token) {
|
|
|
if (token < FIRST_RESERVED) {
|
|
|
lua_assert(token == cast(unsigned char, token));
|
|
|
- return (isprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) :
|
|
|
+ return (lisprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) :
|
|
|
luaO_pushfstring(ls->L, "char(%d)", token);
|
|
|
}
|
|
|
else {
|
|
@@ -200,13 +200,13 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) {
|
|
|
|
|
|
/* LUA_NUMBER */
|
|
|
static void read_numeral (LexState *ls, SemInfo *seminfo) {
|
|
|
- lua_assert(isdigit(ls->current));
|
|
|
+ lua_assert(lisdigit(ls->current));
|
|
|
do {
|
|
|
save_and_next(ls);
|
|
|
- } while (isdigit(ls->current) || ls->current == '.');
|
|
|
+ } while (lisdigit(ls->current) || ls->current == '.');
|
|
|
if (check_next(ls, "Ee")) /* `E'? */
|
|
|
check_next(ls, "+-"); /* optional exponent sign */
|
|
|
- while (isalnum(ls->current) || ls->current == '_')
|
|
|
+ while (lisalnum(ls->current) || ls->current == '_')
|
|
|
save_and_next(ls);
|
|
|
save(ls, '\0');
|
|
|
buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
|
|
@@ -290,7 +290,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) {
|
|
|
case '\r': save(ls, '\n'); inclinenumber(ls); continue;
|
|
|
case EOZ: continue; /* will raise an error next loop */
|
|
|
default: {
|
|
|
- if (!isdigit(ls->current))
|
|
|
+ if (!lisdigit(ls->current))
|
|
|
save_and_next(ls); /* handles \\, \", \', and \? */
|
|
|
else { /* \xxx */
|
|
|
int i = 0;
|
|
@@ -298,7 +298,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) {
|
|
|
do {
|
|
|
c = 10*c + (ls->current-'0');
|
|
|
next(ls);
|
|
|
- } while (++i<3 && isdigit(ls->current));
|
|
|
+ } while (++i<3 && lisdigit(ls->current));
|
|
|
if (c > UCHAR_MAX)
|
|
|
lexerror(ls, "escape sequence too large", TK_STRING);
|
|
|
save(ls, c);
|
|
@@ -389,7 +389,7 @@ static int llex (LexState *ls, SemInfo *seminfo) {
|
|
|
return TK_DOTS; /* ... */
|
|
|
else return TK_CONCAT; /* .. */
|
|
|
}
|
|
|
- else if (!isdigit(ls->current)) return '.';
|
|
|
+ else if (!lisdigit(ls->current)) return '.';
|
|
|
else {
|
|
|
read_numeral(ls, seminfo);
|
|
|
return TK_NUMBER;
|
|
@@ -399,21 +399,21 @@ static int llex (LexState *ls, SemInfo *seminfo) {
|
|
|
return TK_EOS;
|
|
|
}
|
|
|
default: {
|
|
|
- if (isspace(ls->current)) {
|
|
|
+ if (lisspace(ls->current)) {
|
|
|
lua_assert(!currIsNewline(ls));
|
|
|
next(ls);
|
|
|
continue;
|
|
|
}
|
|
|
- else if (isdigit(ls->current)) {
|
|
|
+ else if (lisdigit(ls->current)) {
|
|
|
read_numeral(ls, seminfo);
|
|
|
return TK_NUMBER;
|
|
|
}
|
|
|
- else if (isalpha(ls->current) || ls->current == '_') {
|
|
|
+ else if (lisalpha(ls->current) || ls->current == '_') {
|
|
|
/* identifier or reserved word */
|
|
|
TString *ts;
|
|
|
do {
|
|
|
save_and_next(ls);
|
|
|
- } while (isalnum(ls->current) || ls->current == '_');
|
|
|
+ } while (lisalnum(ls->current) || ls->current == '_');
|
|
|
ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
|
|
|
luaZ_bufflen(ls->buff));
|
|
|
if (ts->tsv.reserved > 0) /* reserved word? */
|