** subexpr -> (simpleexp | unop subexpr) { binop subexpr } ** where 'binop' is any binary operator with a priority higher than 'limit' */
| 1372 | ** where 'binop' is any binary operator with a priority higher than 'limit' |
| 1373 | */ |
| 1374 | static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { |
| 1375 | BinOpr op; |
| 1376 | UnOpr uop; |
| 1377 | enterlevel(ls); |
| 1378 | uop = getunopr(ls->t.token); |
| 1379 | if (uop != OPR_NOUNOPR) { /* prefix (unary) operator? */ |
| 1380 | int line = ls->linenumber; |
| 1381 | luaX_next(ls); /* skip operator */ |
| 1382 | subexpr(ls, v, UNARY_PRIORITY); |
| 1383 | luaK_prefix(ls->fs, uop, v, line); |
| 1384 | } |
| 1385 | else simpleexp(ls, v); |
| 1386 | /* expand while operators have priorities higher than 'limit' */ |
| 1387 | op = getbinopr(ls->t.token); |
| 1388 | while (op != OPR_NOBINOPR && priority[op].left > limit) { |
| 1389 | expdesc v2; |
| 1390 | BinOpr nextop; |
| 1391 | int line = ls->linenumber; |
| 1392 | luaX_next(ls); /* skip operator */ |
| 1393 | luaK_infix(ls->fs, op, v); |
| 1394 | /* read sub-expression with higher priority */ |
| 1395 | nextop = subexpr(ls, &v2, priority[op].right); |
| 1396 | luaK_posfix(ls->fs, op, v, &v2, line); |
| 1397 | op = nextop; |
| 1398 | } |
| 1399 | leavelevel(ls); |
| 1400 | return op; /* return first untreated operator */ |
| 1401 | } |
| 1402 | |
| 1403 | |
| 1404 | static void expr (LexState *ls, expdesc *v) { |
no test coverage detected