first implementation of '<<', '>>', and '~' (bitwise not)

This commit is contained in:
Roberto Ierusalimschy
2013-12-30 18:47:58 -02:00
parent f5133aa1a5
commit 1ea2d20f74
15 changed files with 139 additions and 49 deletions

15
llex.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: llex.c,v 2.68 2013/08/21 20:09:51 roberto Exp roberto $
** $Id: llex.c,v 2.69 2013/08/30 16:01:37 roberto Exp roberto $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -39,7 +39,8 @@ static const char *const luaX_tokens [] = {
"end", "false", "for", "function", "goto", "if",
"in", "local", "nil", "not", "or", "repeat",
"return", "then", "true", "until", "while",
"//", "..", "...", "==", ">=", "<=", "~=", "::", "<eof>",
"//", "..", "...", "==", ">=", "<=", "~=",
"<<", ">>", "::", "<eof>",
"<number>", "<number>", "<name>", "<string>"
};
@@ -462,13 +463,15 @@ static int llex (LexState *ls, SemInfo *seminfo) {
}
case '<': {
next(ls);
if (ls->current != '=') return '<';
else { next(ls); return TK_LE; }
if (ls->current == '=') { next(ls); return TK_LE; }
if (ls->current == '<') { next(ls); return TK_SHL; }
return '<';
}
case '>': {
next(ls);
if (ls->current != '=') return '>';
else { next(ls); return TK_GE; }
if (ls->current == '=') { next(ls); return TK_GE; }
if (ls->current == '>') { next(ls); return TK_SHR; }
return '>';
}
case '/': {
next(ls);