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