diff options
author | Mike Pall <mike> | 2010-04-24 20:23:02 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2010-04-24 20:23:02 +0200 |
commit | 3a32bbc7cb5c2287e8d4e24e362281c165f50976 (patch) | |
tree | fb60a663197010c4e2c966fde543621424a8d2e8 /src | |
parent | 28a6284642c81c9d100011dad999f5467db31974 (diff) | |
download | luajit-3a32bbc7cb5c2287e8d4e24e362281c165f50976.tar.gz luajit-3a32bbc7cb5c2287e8d4e24e362281c165f50976.tar.bz2 luajit-3a32bbc7cb5c2287e8d4e24e362281c165f50976.zip |
Simplify lexer a bit.
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_lex.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/lj_lex.c b/src/lj_lex.c index 95adb212..a808b88d 100644 --- a/src/lj_lex.c +++ b/src/lj_lex.c | |||
@@ -58,14 +58,6 @@ static void save(LexState *ls, int c) | |||
58 | ls->sb.buf[ls->sb.n++] = cast(char, c); | 58 | ls->sb.buf[ls->sb.n++] = cast(char, c); |
59 | } | 59 | } |
60 | 60 | ||
61 | static int check_next(LexState *ls, const char *set) | ||
62 | { | ||
63 | if (!strchr(set, ls->current)) | ||
64 | return 0; | ||
65 | save_and_next(ls); | ||
66 | return 1; | ||
67 | } | ||
68 | |||
69 | static void inclinenumber(LexState *ls) | 61 | static void inclinenumber(LexState *ls) |
70 | { | 62 | { |
71 | int old = ls->current; | 63 | int old = ls->current; |
@@ -85,8 +77,12 @@ static void read_numeral(LexState *ls, TValue *tv) | |||
85 | do { | 77 | do { |
86 | save_and_next(ls); | 78 | save_and_next(ls); |
87 | } while (lj_ctype_isdigit(ls->current) || ls->current == '.'); | 79 | } while (lj_ctype_isdigit(ls->current) || ls->current == '.'); |
88 | if (check_next(ls, "Ee")) /* `E'? */ | 80 | if (ls->current == 'e' || ls->current == 'E' || |
89 | check_next(ls, "+-"); /* optional exponent sign */ | 81 | ls->current == 'p' || ls->current == 'P') { |
82 | save_and_next(ls); | ||
83 | if (ls->current == '+' || ls->current == '-') | ||
84 | save_and_next(ls); | ||
85 | } | ||
90 | while (lj_ctype_isident(ls->current)) | 86 | while (lj_ctype_isident(ls->current)) |
91 | save_and_next(ls); | 87 | save_and_next(ls); |
92 | save(ls, '\0'); | 88 | save(ls, '\0'); |
@@ -277,11 +273,13 @@ static int llex(LexState *ls, TValue *tv) | |||
277 | return TK_string; | 273 | return TK_string; |
278 | case '.': | 274 | case '.': |
279 | save_and_next(ls); | 275 | save_and_next(ls); |
280 | if (check_next(ls, ".")) { | 276 | if (ls->current == '.') { |
281 | if (check_next(ls, ".")) | 277 | next(ls); |
278 | if (ls->current == '.') { | ||
279 | next(ls); | ||
282 | return TK_dots; /* ... */ | 280 | return TK_dots; /* ... */ |
283 | else | 281 | } |
284 | return TK_concat; /* .. */ | 282 | return TK_concat; /* .. */ |
285 | } else if (!lj_ctype_isdigit(ls->current)) { | 283 | } else if (!lj_ctype_isdigit(ls->current)) { |
286 | return '.'; | 284 | return '.'; |
287 | } else { | 285 | } else { |