** subexpr -> (simpleexp | unop subexpr) { binop subexpr } ** where 'binop' is any binary operator with a priority higher than 'limit' */
| 1047 | ** where 'binop' is any binary operator with a priority higher than 'limit' |
| 1048 | */ |
| 1049 | static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { |
| 1050 | BinOpr op; |
| 1051 | UnOpr uop; |
| 1052 | enterlevel(ls); |
| 1053 | uop = getunopr(ls->t.token); |
| 1054 | if (uop != OPR_NOUNOPR) { |
| 1055 | int line = ls->linenumber; |
| 1056 | luaX_next(ls); |
| 1057 | subexpr(ls, v, UNARY_PRIORITY); |
| 1058 | luaK_prefix(ls->fs, uop, v, line); |
| 1059 | } |
| 1060 | else simpleexp(ls, v); |
| 1061 | /* expand while operators have priorities higher than 'limit' */ |
| 1062 | op = getbinopr(ls->t.token); |
| 1063 | while (op != OPR_NOBINOPR && priority[op].left > limit) { |
| 1064 | expdesc v2; |
| 1065 | BinOpr nextop; |
| 1066 | int line = ls->linenumber; |
| 1067 | luaX_next(ls); |
| 1068 | luaK_infix(ls->fs, op, v); |
| 1069 | /* read sub-expression with higher priority */ |
| 1070 | nextop = subexpr(ls, &v2, priority[op].right); |
| 1071 | luaK_posfix(ls->fs, op, v, &v2, line); |
| 1072 | op = nextop; |
| 1073 | } |
| 1074 | leavelevel(ls); |
| 1075 | return op; /* return first untreated operator */ |
| 1076 | } |
| 1077 | |
| 1078 | |
| 1079 | static void expr (LexState *ls, expdesc *v) { |
no test coverage detected