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