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

View File

@@ -1,5 +1,5 @@
/*
** $Id: lparser.c,v 2.131 2013/04/16 18:46:28 roberto Exp roberto $
** $Id: lparser.c,v 2.132 2013/04/25 19:35:19 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -1005,6 +1005,7 @@ static BinOpr getbinopr (int op) {
case '-': return OPR_SUB;
case '*': return OPR_MUL;
case '/': return OPR_DIV;
case TK_IDIV: return OPR_IDIV;
case '%': return OPR_MOD;
case '^': return OPR_POW;
case TK_CONCAT: return OPR_CONCAT;
@@ -1025,7 +1026,8 @@ static const struct {
lu_byte left; /* left priority for each binary operator */
lu_byte right; /* right priority */
} priority[] = { /* ORDER OPR */
{6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `*' `/' `%' */
{6, 6}, {6, 6}, /* '+' '-' */
{7, 7}, {7, 7}, {7, 7}, {7, 7}, /* '*' '/' '//' '%' */
{10, 9}, {5, 4}, /* ^, .. (right associative) */
{3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */
{3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */