new operation '//' (integer division)

This commit is contained in:
Roberto Ierusalimschy
2013-04-26 10:08:29 -03:00
parent a80a2b5e56
commit a2f5c28a80
14 changed files with 56 additions and 27 deletions

9
llex.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: llex.c,v 2.63 2013/03/16 21:10:18 roberto Exp roberto $
** $Id: llex.c,v 2.64 2013/04/16 18:46:28 roberto Exp roberto $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -38,7 +38,7 @@ 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>"
};
@@ -464,6 +464,11 @@ static int llex (LexState *ls, SemInfo *seminfo) {
if (ls->current != '=') return '>';
else { next(ls); return TK_GE; }
}
case '/': {
next(ls);
if (ls->current != '/') return '/';
else { next(ls); return TK_IDIV; }
}
case '~': {
next(ls);
if (ls->current != '=') return '~';