aboutsummaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-08-01 14:11:33 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-08-01 14:11:33 -0300
commit35a28a58b38fb90cbe7c9596d60af2b3c1bd52a3 (patch)
tree3a323f342005878651b3989a82339b9b8aa7fa07 /llex.c
parent223bb04090344b1972dc2a7910a54b46210f0d40 (diff)
downloadlua-35a28a58b38fb90cbe7c9596d60af2b3c1bd52a3.tar.gz
lua-35a28a58b38fb90cbe7c9596d60af2b3c1bd52a3.tar.bz2
lua-35a28a58b38fb90cbe7c9596d60af2b3c1bd52a3.zip
Details
- removed rule about RCS from makefile - comments and nitpicking in 'llex.c'
Diffstat (limited to 'llex.c')
-rw-r--r--llex.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/llex.c b/llex.c
index d99d9015..f88057fe 100644
--- a/llex.c
+++ b/llex.c
@@ -211,8 +211,16 @@ static int check_next2 (LexState *ls, const char *set) {
211 211
212/* LUA_NUMBER */ 212/* LUA_NUMBER */
213/* 213/*
214** this function is quite liberal in what it accepts, as 'luaO_str2num' 214** This function is quite liberal in what it accepts, as 'luaO_str2num'
215** will reject ill-formed numerals. 215** will reject ill-formed numerals. Roughly, it accepts the following
216** pattern:
217**
218** %d(%x|%.|([Ee][+-]?))* | 0[Xx](%x|%.|([Pp][+-]?))*
219**
220** The only tricky part is to accept [+-] only after a valid exponent
221** mark, to avoid reading '3-4' or '0xe+1' as a single number.
222**
223** The caller might have already read an initial dot.
216*/ 224*/
217static int read_numeral (LexState *ls, SemInfo *seminfo) { 225static int read_numeral (LexState *ls, SemInfo *seminfo) {
218 TValue obj; 226 TValue obj;
@@ -223,15 +231,13 @@ static int read_numeral (LexState *ls, SemInfo *seminfo) {
223 if (first == '0' && check_next2(ls, "xX")) /* hexadecimal? */ 231 if (first == '0' && check_next2(ls, "xX")) /* hexadecimal? */
224 expo = "Pp"; 232 expo = "Pp";
225 for (;;) { 233 for (;;) {
226 if (check_next2(ls, expo)) /* exponent part? */ 234 if (check_next2(ls, expo)) /* exponent mark? */
227 check_next2(ls, "-+"); /* optional exponent sign */ 235 check_next2(ls, "-+"); /* optional exponent sign */
228 if (lisxdigit(ls->current)) 236 else if (lisxdigit(ls->current) || ls->current == '.') /* '%x|%.' */
229 save_and_next(ls);
230 else if (ls->current == '.')
231 save_and_next(ls); 237 save_and_next(ls);
232 else break; 238 else break;
233 } 239 }
234 if (lislalnum(ls->current)) /* is numeral touching an alpha num? */ 240 if (lislalpha(ls->current)) /* is numeral touching a letter? */
235 save_and_next(ls); /* force an error */ 241 save_and_next(ls); /* force an error */
236 save(ls, '\0'); 242 save(ls, '\0');
237 if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */ 243 if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */