** subexpr -> (simpleexp | unop subexpr) { binop subexpr } ** where 'binop' is any binary operator with a priority higher than 'limit' */
| 1258 | ** where 'binop' is any binary operator with a priority higher than 'limit' |
| 1259 | */ |
| 1260 | static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { |
| 1261 | BinOpr op; |
| 1262 | UnOpr uop; |
| 1263 | enterlevel(ls); |
| 1264 | uop = getunopr(ls->t.token); |
| 1265 | if (uop != OPR_NOUNOPR) { /* prefix (unary) operator? */ |
| 1266 | int line = ls->linenumber; |
| 1267 | luaX_next(ls); /* skip operator */ |
| 1268 | subexpr(ls, v, UNARY_PRIORITY); |
| 1269 | luaK_prefix(ls->fs, uop, v, line); |
| 1270 | } |
| 1271 | else simpleexp(ls, v); |
| 1272 | /* expand while operators have priorities higher than 'limit' */ |
| 1273 | op = getbinopr(ls->t.token); |
| 1274 | while (op != OPR_NOBINOPR && priority[op].left > limit) { |
| 1275 | expdesc v2; |
| 1276 | BinOpr nextop; |
| 1277 | int line = ls->linenumber; |
| 1278 | luaX_next(ls); /* skip operator */ |
| 1279 | luaK_infix(ls->fs, op, v); |
| 1280 | /* read sub-expression with higher priority */ |
| 1281 | nextop = subexpr(ls, &v2, priority[op].right); |
| 1282 | luaK_posfix(ls->fs, op, v, &v2, line); |
| 1283 | op = nextop; |
| 1284 | } |
| 1285 | leavelevel(ls); |
| 1286 | return op; /* return first untreated operator */ |
| 1287 | } |
| 1288 | |
| 1289 | |
| 1290 | static void expr (LexState *ls, expdesc *v) { |
no test coverage detected