diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-12-30 18:47:58 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-12-30 18:47:58 -0200 |
| commit | 1ea2d20f74cea9c61817d4a5ed67c4fc47cafb51 (patch) | |
| tree | bdedb3205963f8db43391aaef5be853cdeb59df4 /llex.c | |
| parent | f5133aa1a55cee96b535ff788764437deacdc26a (diff) | |
| download | lua-1ea2d20f74cea9c61817d4a5ed67c4fc47cafb51.tar.gz lua-1ea2d20f74cea9c61817d4a5ed67c4fc47cafb51.tar.bz2 lua-1ea2d20f74cea9c61817d4a5ed67c4fc47cafb51.zip | |
first implementation of '<<', '>>', and '~' (bitwise not)
Diffstat (limited to 'llex.c')
| -rw-r--r-- | llex.c | 15 |
1 files changed, 9 insertions, 6 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.c,v 2.68 2013/08/21 20:09:51 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 2.69 2013/08/30 16:01:37 roberto Exp roberto $ |
| 3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -39,7 +39,8 @@ static const char *const luaX_tokens [] = { | |||
| 39 | "end", "false", "for", "function", "goto", "if", | 39 | "end", "false", "for", "function", "goto", "if", |
| 40 | "in", "local", "nil", "not", "or", "repeat", | 40 | "in", "local", "nil", "not", "or", "repeat", |
| 41 | "return", "then", "true", "until", "while", | 41 | "return", "then", "true", "until", "while", |
| 42 | "//", "..", "...", "==", ">=", "<=", "~=", "::", "<eof>", | 42 | "//", "..", "...", "==", ">=", "<=", "~=", |
| 43 | "<<", ">>", "::", "<eof>", | ||
| 43 | "<number>", "<number>", "<name>", "<string>" | 44 | "<number>", "<number>", "<name>", "<string>" |
| 44 | }; | 45 | }; |
| 45 | 46 | ||
| @@ -462,13 +463,15 @@ static int llex (LexState *ls, SemInfo *seminfo) { | |||
| 462 | } | 463 | } |
| 463 | case '<': { | 464 | case '<': { |
| 464 | next(ls); | 465 | next(ls); |
| 465 | if (ls->current != '=') return '<'; | 466 | if (ls->current == '=') { next(ls); return TK_LE; } |
| 466 | else { next(ls); return TK_LE; } | 467 | if (ls->current == '<') { next(ls); return TK_SHL; } |
| 468 | return '<'; | ||
| 467 | } | 469 | } |
| 468 | case '>': { | 470 | case '>': { |
| 469 | next(ls); | 471 | next(ls); |
| 470 | if (ls->current != '=') return '>'; | 472 | if (ls->current == '=') { next(ls); return TK_GE; } |
| 471 | else { next(ls); return TK_GE; } | 473 | if (ls->current == '>') { next(ls); return TK_SHR; } |
| 474 | return '>'; | ||
| 472 | } | 475 | } |
| 473 | case '/': { | 476 | case '/': { |
| 474 | next(ls); | 477 | next(ls); |
