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