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

Method parseIfStatement

src/parser.ts:2121–2143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2119 }
2120
2121 parseIfStatement(): Node.IfStatement {
2122 const node = this.createNode();
2123 let consequent: Node.Statement;
2124 let alternate: Node.Statement | null = null;
2125
2126 this.expectKeyword('if');
2127 this.expect('(');
2128 const test = this.parseExpression();
2129
2130 if (!this.match(')') && this.config.tolerant) {
2131 this.tolerateUnexpectedToken(this.nextToken());
2132 consequent = this.finalize(this.createNode(), new Node.EmptyStatement());
2133 } else {
2134 this.expect(')');
2135 consequent = this.parseIfClause();
2136 if (this.matchKeyword('else')) {
2137 this.nextToken();
2138 alternate = this.parseIfClause();
2139 }
2140 }
2141
2142 return this.finalize(node, new Node.IfStatement(test, consequent, alternate));
2143 }
2144
2145 // https://tc39.github.io/ecma262/#sec-do-while-statement
2146

Callers 1

parseStatementMethod · 0.95

Calls 10

createNodeMethod · 0.95
expectKeywordMethod · 0.95
expectMethod · 0.95
parseExpressionMethod · 0.95
matchMethod · 0.95
nextTokenMethod · 0.95
finalizeMethod · 0.95
parseIfClauseMethod · 0.95
matchKeywordMethod · 0.95

Tested by

no test coverage detected