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