summaryrefslogtreecommitdiff
path: root/src/llex.c
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2012-03-21 12:00:00 +0000
committerrepogen <>2012-03-21 12:00:00 +0000
commit1cb937cf2d4583482aadaff45b6628b39fdcd91e (patch)
tree614eba453350c41305e41d647e9e03d779314f89 /src/llex.c
parent6ee889a587f9b600b564d5c0ba0350faab0387cd (diff)
downloadlua-github-5.2.1-work1.tar.gz
Lua 5.2.1-work15.2.1-work1
Diffstat (limited to 'src/llex.c')
-rw-r--r--src/llex.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/llex.c b/src/llex.c
index 74deebb9..c4d8c65b 100644
--- a/src/llex.c
+++ b/src/llex.c
@@ -1,5 +1,5 @@
/*
-** $Id: llex.c,v 2.59 2011/11/30 12:43:51 roberto Exp $
+** $Id: llex.c,v 2.61 2012/01/23 23:05:51 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -67,7 +67,7 @@ void luaX_init (lua_State *L) {
for (i=0; i<NUM_RESERVED; i++) {
TString *ts = luaS_new(L, luaX_tokens[i]);
luaS_fix(ts); /* reserved words are never collected */
- ts->tsv.reserved = cast_byte(i+1); /* reserved word */
+ ts->tsv.extra = cast_byte(i+1); /* reserved word */
}
}
@@ -222,13 +222,24 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) {
/* LUA_NUMBER */
+/*
+** this function is quite liberal in what it accepts, as 'luaO_str2d'
+** will reject ill-formed numerals.
+*/
static void read_numeral (LexState *ls, SemInfo *seminfo) {
+ const char *expo = "Ee";
+ int first = ls->current;
lua_assert(lisdigit(ls->current));
- do {
- save_and_next(ls);
- if (check_next(ls, "EePp")) /* exponent part? */
+ save_and_next(ls);
+ if (first == '0' && check_next(ls, "Xx")) /* hexadecimal? */
+ expo = "Pp";
+ for (;;) {
+ if (check_next(ls, expo)) /* exponent part? */
check_next(ls, "+-"); /* optional exponent sign */
- } while (lislalnum(ls->current) || ls->current == '.');
+ if (lisxdigit(ls->current) || ls->current == '.')
+ save_and_next(ls);
+ else break;
+ }
save(ls, '\0');
buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
if (!buff2d(ls->buff, &seminfo->r)) /* format error? */
@@ -480,8 +491,8 @@ static int llex (LexState *ls, SemInfo *seminfo) {
ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
luaZ_bufflen(ls->buff));
seminfo->ts = ts;
- if (ts->tsv.reserved > 0) /* reserved word? */
- return ts->tsv.reserved - 1 + FIRST_RESERVED;
+ if (isreserved(ts)) /* reserved word? */
+ return ts->tsv.extra - 1 + FIRST_RESERVED;
else {
return TK_NAME;
}