(
this: Parser,
program: Undone<N.Program>,
end: TokenType,
sourceType: SourceType,
)
| 219 | } |
| 220 | |
| 221 | parseProgram( |
| 222 | this: Parser, |
| 223 | program: Undone<N.Program>, |
| 224 | end: TokenType, |
| 225 | sourceType: SourceType, |
| 226 | ): N.Program { |
| 227 | program.sourceType = sourceType; |
| 228 | program.interpreter = this.parseInterpreterDirective(); |
| 229 | this.parseBlockBody(program, true, true, end); |
| 230 | if (this.inModule) { |
| 231 | if ( |
| 232 | !(this.optionFlags & OptionFlags.AllowUndeclaredExports) && |
| 233 | this.scope.undefinedExports.size > 0 |
| 234 | ) { |
| 235 | for (const [localName, at] of Array.from(this.scope.undefinedExports)) { |
| 236 | this.raise(Errors.ModuleExportUndefined, at, { localName }); |
| 237 | } |
| 238 | } |
| 239 | this.addExtra(program, "topLevelAwait", this.state.hasTopLevelAwait); |
| 240 | } |
| 241 | let finishedProgram: N.Program; |
| 242 | if (end === tt.eof) { |
| 243 | // finish at eof for top level program |
| 244 | finishedProgram = this.finishNode(program, "Program"); |
| 245 | } else { |
| 246 | // finish immediately before the end token |
| 247 | finishedProgram = this.finishNodeAt( |
| 248 | program, |
| 249 | "Program", |
| 250 | createPositionWithColumnOffset(this.state.startLoc, -1), |
| 251 | ); |
| 252 | } |
| 253 | return finishedProgram; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * cast a Statement to a Directive. This method mutates input statement. |
nothing calls this directly
no test coverage detected