** subexpr -> (simpleexp | unop subexpr) { binop subexpr } ** where `binop' is any binary operator with a priority higher than `limit' */
| 830 | ** where `binop' is any binary operator with a priority higher than `limit' |
| 831 | */ |
| 832 | static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { |
| 833 | BinOpr op; |
| 834 | UnOpr uop; |
| 835 | enterlevel(ls); |
| 836 | uop = getunopr(ls->t.token); |
| 837 | if (uop != OPR_NOUNOPR) { |
| 838 | luaX_next(ls); |
| 839 | subexpr(ls, v, UNARY_PRIORITY); |
| 840 | luaK_prefix(ls->fs, uop, v); |
| 841 | } |
| 842 | else simpleexp(ls, v); |
| 843 | /* expand while operators have priorities higher than `limit' */ |
| 844 | op = getbinopr(ls->t.token); |
| 845 | while (op != OPR_NOBINOPR && priority[op].left > limit) { |
| 846 | expdesc v2; |
| 847 | BinOpr nextop; |
| 848 | luaX_next(ls); |
| 849 | luaK_infix(ls->fs, op, v); |
| 850 | /* read sub-expression with higher priority */ |
| 851 | nextop = subexpr(ls, &v2, priority[op].right); |
| 852 | luaK_posfix(ls->fs, op, v, &v2); |
| 853 | op = nextop; |
| 854 | } |
| 855 | leavelevel(ls); |
| 856 | return op; /* return first untreated operator */ |
| 857 | } |
| 858 | |
| 859 | |
| 860 | static void expr (LexState *ls, expdesc *v) { |
no test coverage detected