(this: Parser)
| 153 | |
| 154 | // Convenience method to parse an Expression only |
| 155 | getExpression(this: Parser): N.Expression & N.ParserOutput { |
| 156 | this.enterInitialScopes(); |
| 157 | this.nextToken(); |
| 158 | if (this.match(tt.eof)) { |
| 159 | throw this.raise(Errors.ParseExpressionEmptyInput, this.state.startLoc); |
| 160 | } |
| 161 | const expr = this.parseExpression() as N.Expression & N.ParserOutput; |
| 162 | if (!this.match(tt.eof)) { |
| 163 | throw this.raise(Errors.ParseExpressionExpectsEOF, this.state.startLoc, { |
| 164 | unexpected: this.input.codePointAt(this.state.start)!, |
| 165 | }); |
| 166 | } |
| 167 | // Unlike parseTopLevel, we need to drain remaining commentStacks |
| 168 | // because the top level node is _not_ Program. |
| 169 | this.finalizeRemainingComments(); |
| 170 | expr.comments = this.comments; |
| 171 | expr.errors = this.state.errors; |
| 172 | if (this.optionFlags & OptionFlags.Tokens) { |
| 173 | expr.tokens = createExportedTokens(this.tokens); |
| 174 | } |
| 175 | return expr; |
| 176 | } |
| 177 | |
| 178 | // ### Expression parsing |
| 179 |
nothing calls this directly
no test coverage detected