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