diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-08-01 14:11:33 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-08-01 14:11:33 -0300 |
| commit | 35a28a58b38fb90cbe7c9596d60af2b3c1bd52a3 (patch) | |
| tree | 3a323f342005878651b3989a82339b9b8aa7fa07 | |
| parent | 223bb04090344b1972dc2a7910a54b46210f0d40 (diff) | |
| download | lua-35a28a58b38fb90cbe7c9596d60af2b3c1bd52a3.tar.gz lua-35a28a58b38fb90cbe7c9596d60af2b3c1bd52a3.tar.bz2 lua-35a28a58b38fb90cbe7c9596d60af2b3c1bd52a3.zip | |
Details
- removed rule about RCS from makefile
- comments and nitpicking in 'llex.c'
| -rw-r--r-- | llex.c | 20 | ||||
| -rw-r--r-- | makefile | 1 |
2 files changed, 13 insertions, 8 deletions
| @@ -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 | */ |
| 217 | static int read_numeral (LexState *ls, SemInfo *seminfo) { | 225 | static 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? */ |
| @@ -107,7 +107,6 @@ $(LUAC_T): $(LUAC_O) $(CORE_T) | |||
| 107 | $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(CORE_T) $(LIBS) $(MYLIBS) | 107 | $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(CORE_T) $(LIBS) $(MYLIBS) |
| 108 | 108 | ||
| 109 | clean: | 109 | clean: |
| 110 | rcsclean -u | ||
| 111 | $(RM) $(ALL_T) $(ALL_O) | 110 | $(RM) $(ALL_T) $(ALL_O) |
| 112 | 111 | ||
| 113 | depend: | 112 | depend: |
