** Parse and compile a multiple assignment. The first "variable" ** (a 'suffixedexp') was already read by the caller. ** ** assignment -> suffixedexp restassign ** restassign -> ',' suffixedexp restassign | '=' explist */
| 1496 | ** restassign -> ',' suffixedexp restassign | '=' explist |
| 1497 | */ |
| 1498 | static void restassign (LexState *ls, struct LHS_assign *lh, int nvars) { |
| 1499 | expdesc e; |
| 1500 | check_condition(ls, vkisvar(lh->v.k), "syntax error"); |
| 1501 | check_readonly(ls, &lh->v); |
| 1502 | if (testnext(ls, ',')) { /* restassign -> ',' suffixedexp restassign */ |
| 1503 | struct LHS_assign nv; |
| 1504 | nv.prev = lh; |
| 1505 | suffixedexp(ls, &nv.v); |
| 1506 | if (!vkisindexed(nv.v.k)) |
| 1507 | check_conflict(ls, lh, &nv.v); |
| 1508 | enterlevel(ls); /* control recursion depth */ |
| 1509 | restassign(ls, &nv, nvars+1); |
| 1510 | leavelevel(ls); |
| 1511 | } |
| 1512 | else { /* restassign -> '=' explist */ |
| 1513 | int nexps; |
| 1514 | checknext(ls, '='); |
| 1515 | nexps = explist(ls, &e); |
| 1516 | if (nexps != nvars) |
| 1517 | adjust_assign(ls, nvars, nexps, &e); |
| 1518 | else { |
| 1519 | luaK_setoneret(ls->fs, &e); /* close last expression */ |
| 1520 | luaK_storevar(ls->fs, &lh->v, &e); |
| 1521 | return; /* avoid default */ |
| 1522 | } |
| 1523 | } |
| 1524 | storevartop(ls->fs, &lh->v); /* default assignment */ |
| 1525 | } |
| 1526 | |
| 1527 | |
| 1528 | static int cond (LexState *ls) { |
no test coverage detected