** subexpr -> (simpleexp | unop subexpr) { binop subexpr } ** where `binop' is any binary operator with a priority higher than `limit' */
| 872 | ** where `binop' is any binary operator with a priority higher than `limit' |
| 873 | */ |
| 874 | static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { |
| 875 | BinOpr op; |
| 876 | UnOpr uop; |
| 877 | enterlevel(ls); |
| 878 | uop = getunopr(ls->t.token); |
| 879 | if (uop != OPR_NOUNOPR) { |
| 880 | luaX_next(ls); |
| 881 | subexpr(ls, v, UNARY_PRIORITY); |
| 882 | luaK_prefix(ls->fs, uop, v); |
| 883 | } |
| 884 | else simpleexp(ls, v); |
| 885 | /* expand while operators have priorities higher than `limit' */ |
| 886 | op = getbinopr(ls->t.token); |
| 887 | while (op != OPR_NOBINOPR && priority[op].left > limit) { |
| 888 | expdesc v2; |
| 889 | BinOpr nextop; |
| 890 | luaX_next(ls); |
| 891 | luaK_infix(ls->fs, op, v); |
| 892 | /* read sub-expression with higher priority */ |
| 893 | nextop = subexpr(ls, &v2, priority[op].right); |
| 894 | luaK_posfix(ls->fs, op, v, &v2); |
| 895 | op = nextop; |
| 896 | } |
| 897 | leavelevel(ls); |
| 898 | return op; /* return first untreated operator */ |
| 899 | } |
| 900 | |
| 901 | |
| 902 | static void expr (LexState *ls, expdesc *v) { |
no test coverage detected