()
| 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 |
no test coverage detected