summaryrefslogtreecommitdiff
path: root/lparser.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-12-16 17:06:52 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-12-16 17:06:52 -0200
commita948054a1951cd526c732d6a0e16d99cae837d49 (patch)
treed13984803c85e83eda285a285bd3de2e05a603af /lparser.c
parenta8f8c7fd80a5c7e630fd4bf7f858d05024f6b434 (diff)
downloadlua-github-a948054a1951cd526c732d6a0e16d99cae837d49.tar.gz
new order for binary operations (grouping them by type of result)
Diffstat (limited to 'lparser.c')
-rw-r--r--lparser.c20
1 files changed, 11 insertions, 9 deletions
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 */