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