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