From a948054a1951cd526c732d6a0e16d99cae837d49 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy <roberto@inf.puc-rio.br> Date: Mon, 16 Dec 2013 17:06:52 -0200 Subject: new order for binary operations (grouping them by type of result) --- lparser.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lparser.c') diff --git a/lparser.c b/lparser.c index 0f53ff7c..c23b2dde 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.134 2013/08/16 18:55:49 roberto Exp roberto $ +** $Id: lparser.c,v 2.135 2013/08/30 16:01:37 roberto Exp roberto $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -990,10 +990,10 @@ static BinOpr getbinopr (int op) { case '+': return OPR_ADD; 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 '/': return OPR_DIV; + case TK_IDIV: return OPR_IDIV; case TK_CONCAT: return OPR_CONCAT; case TK_NE: return OPR_NE; case TK_EQ: return OPR_EQ; @@ -1012,12 +1012,14 @@ 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}, {7, 7}, /* '*' '/' '//' '%' */ - {10, 9}, {5, 4}, /* ^, .. (right associative) */ - {3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */ - {3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */ - {2, 2}, {1, 1} /* and, or */ + {6, 6}, {6, 6}, /* '+' '-' */ + {7, 7}, {7, 7}, /* '*' '%' */ + {10, 9}, /* '^' (right associative) */ + {7, 7}, {7, 7}, /* '/' '//' */ + {5, 4}, /* '..' (right associative) */ + {3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */ + {3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */ + {2, 2}, {1, 1} /* and, or */ }; #define UNARY_PRIORITY 8 /* priority for unary operators */ -- cgit v1.2.3-55-g6feb