MCPcopy Index your code
hub / github.com/BloombergGraphics/whatiscode / parseForStatement

Function parseForStatement

scripts/libs/esprima.js:3442–3534  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

3440 }
3441
3442 function parseForStatement(node) {
3443 var init, test, update, left, right, kind, declarations,
3444 body, oldInIteration, previousAllowIn = state.allowIn;
3445
3446 init = test = update = null;
3447
3448 expectKeyword('for');
3449
3450 expect('(');
3451
3452 if (match(';')) {
3453 lex();
3454 } else {
3455 if (matchKeyword('var')) {
3456 init = new Node();
3457 lex();
3458
3459 state.allowIn = false;
3460 init = init.finishVariableDeclaration(parseVariableDeclarationList());
3461 state.allowIn = previousAllowIn;
3462
3463 if (init.declarations.length === 1 && matchKeyword('in')) {
3464 lex();
3465 left = init;
3466 right = parseExpression();
3467 init = null;
3468 } else {
3469 expect(';');
3470 }
3471 } else if (matchKeyword('const') || matchKeyword('let')) {
3472 init = new Node();
3473 kind = lex().value;
3474
3475 state.allowIn = false;
3476 declarations = parseBindingList(kind, {inFor: true});
3477 state.allowIn = previousAllowIn;
3478
3479 if (declarations.length === 1 && declarations[0].init === null && matchKeyword('in')) {
3480 init = init.finishLexicalDeclaration(declarations, kind);
3481 lex();
3482 left = init;
3483 right = parseExpression();
3484 init = null;
3485 } else {
3486 consumeSemicolon();
3487 init = init.finishLexicalDeclaration(declarations, kind);
3488 }
3489 } else {
3490 state.allowIn = false;
3491 init = parseExpression();
3492 state.allowIn = previousAllowIn;
3493
3494 if (matchKeyword('in')) {
3495 // LeftHandSideExpression
3496 if (!isLeftHandSide(init)) {
3497 tolerateError(Messages.InvalidLHSInForIn);
3498 }
3499

Callers 1

parseStatementFunction · 0.85

Calls 12

expectKeywordFunction · 0.85
expectFunction · 0.85
matchFunction · 0.85
lexFunction · 0.85
matchKeywordFunction · 0.85
parseExpressionFunction · 0.85
parseBindingListFunction · 0.85
consumeSemicolonFunction · 0.85
isLeftHandSideFunction · 0.85
tolerateErrorFunction · 0.85
parseStatementFunction · 0.85

Tested by

no test coverage detected