Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

add startLine option #346

Merged
merged 1 commit into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Significant diversions are expected to occur in the future such as streaming, EB

- **sourceFilename**: Correlate output AST nodes with their source filename. Useful when generating code and source maps from the ASTs of multiple input files.

- **startLine**: By default, the first line of code parsed is treated as line 1. You can provide a line number to alternatively start with. Useful for integration with other source tools.

- **plugins**: Array containing the plugins that you want to enable.

### Output
Expand Down
4 changes: 4 additions & 0 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export const defaultOptions: {
sourceType: string,
sourceFilename: any,
startLine: number,
allowReturnOutsideFunction: boolean,
allowImportExportEverywhere: boolean,
allowSuperOutsideMethod: boolean,
Expand All @@ -14,6 +15,9 @@ export const defaultOptions: {
sourceType: "script",
// Source filename.
sourceFilename: undefined,
// Line from which to start counting source. Useful for
// integration with other tools.
startLine: 1,
// When enabled, a return at the top level is not considered an
// error.
allowReturnOutsideFunction: false,
Expand Down
2 changes: 1 addition & 1 deletion src/tokenizer/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class State {
this.commentStack = [];

this.pos = this.lineStart = 0;
this.curLine = 1;
this.curLine = options.startLine;

this.type = tt.eof;
this.value = null;
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/core/categorized/startline-specified/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
call(1);
run(2);
Loading