MCPcopy
hub / github.com/jquery/esprima / parseWhileStatement

Method parseWhileStatement

src/parser.ts:2174–2195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2172 // https://tc39.github.io/ecma262/#sec-while-statement
2173
2174 parseWhileStatement(): Node.WhileStatement {
2175 const node = this.createNode();
2176 let body;
2177
2178 this.expectKeyword('while');
2179 this.expect('(');
2180 const test = this.parseExpression();
2181
2182 if (!this.match(')') && this.config.tolerant) {
2183 this.tolerateUnexpectedToken(this.nextToken());
2184 body = this.finalize(this.createNode(), new Node.EmptyStatement());
2185 } else {
2186 this.expect(')');
2187
2188 const previousInIteration = this.context.inIteration;
2189 this.context.inIteration = true;
2190 body = this.parseStatement();
2191 this.context.inIteration = previousInIteration;
2192 }
2193
2194 return this.finalize(node, new Node.WhileStatement(test, body));
2195 }
2196
2197 // https://tc39.github.io/ecma262/#sec-for-statement
2198 // https://tc39.github.io/ecma262/#sec-for-in-and-for-of-statements

Callers 1

parseStatementMethod · 0.95

Calls 9

createNodeMethod · 0.95
expectKeywordMethod · 0.95
expectMethod · 0.95
parseExpressionMethod · 0.95
matchMethod · 0.95
nextTokenMethod · 0.95
finalizeMethod · 0.95
parseStatementMethod · 0.95

Tested by

no test coverage detected