(opts)
| 7511 | } |
| 7512 | |
| 7513 | function parseForStatement(opts) { |
| 7514 | var init, test, update, left, right, body, operator, oldInIteration, |
| 7515 | marker = markerCreate(); |
| 7516 | init = test = update = null; |
| 7517 | expectKeyword('for'); |
| 7518 | |
| 7519 | // http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators&s=each |
| 7520 | if (matchContextualKeyword('each')) { |
| 7521 | throwError({}, Messages.EachNotAllowed); |
| 7522 | } |
| 7523 | |
| 7524 | expect('('); |
| 7525 | |
| 7526 | if (match(';')) { |
| 7527 | lex(); |
| 7528 | } else { |
| 7529 | if (matchKeyword('var') || matchKeyword('let') || matchKeyword('const')) { |
| 7530 | state.allowIn = false; |
| 7531 | init = parseForVariableDeclaration(); |
| 7532 | state.allowIn = true; |
| 7533 | |
| 7534 | if (init.declarations.length === 1) { |
| 7535 | if (matchKeyword('in') || matchContextualKeyword('of')) { |
| 7536 | operator = lookahead; |
| 7537 | if (!((operator.value === 'in' || init.kind !== 'var') && init.declarations[0].init)) { |
| 7538 | lex(); |
| 7539 | left = init; |
| 7540 | right = parseExpression(); |
| 7541 | init = null; |
| 7542 | } |
| 7543 | } |
| 7544 | } |
| 7545 | } else { |
| 7546 | state.allowIn = false; |
| 7547 | init = parseExpression(); |
| 7548 | state.allowIn = true; |
| 7549 | |
| 7550 | if (matchContextualKeyword('of')) { |
| 7551 | operator = lex(); |
| 7552 | left = init; |
| 7553 | right = parseExpression(); |
| 7554 | init = null; |
| 7555 | } else if (matchKeyword('in')) { |
| 7556 | // LeftHandSideExpression |
| 7557 | if (!isAssignableLeftHandSide(init)) { |
| 7558 | throwError({}, Messages.InvalidLHSInForIn); |
| 7559 | } |
| 7560 | operator = lex(); |
| 7561 | left = init; |
| 7562 | right = parseExpression(); |
| 7563 | init = null; |
| 7564 | } |
| 7565 | } |
| 7566 | |
| 7567 | if (typeof left === 'undefined') { |
| 7568 | expect(';'); |
| 7569 | } |
| 7570 | } |
no test coverage detected