-
Notifications
You must be signed in to change notification settings - Fork 853
Commit
Remove need for acorn_csp.js
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
acorn.js |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,20 @@ import {getOptions} from "./options" | |
// Registered plugins | ||
export const plugins = {} | ||
|
||
function keywordRegexp(words) { | ||
return new RegExp("^(" + words.replace(/ /g, "|") + ")$") | ||
} | ||
|
||
export class Parser { | ||
constructor(options, input, startPos) { | ||
this.options = getOptions(options) | ||
this.sourceFile = this.options.sourceFile | ||
this.isKeyword = keywords[this.options.ecmaVersion >= 6 ? 6 : 5] | ||
this.isReservedWord = reservedWords[this.options.ecmaVersion] | ||
this.keywords = keywordRegexp(keywords[this.options.ecmaVersion >= 6 ? 6 : 5]) | ||
let reserved = this.options.allowReserved ? "" : reservedWords[this.options.ecmaVersion] | ||
this.reservedWords = keywordRegexp(reserved) | ||
let reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict | ||
this.reservedWordsStrict = keywordRegexp(reservedStrict) | ||
this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind) | ||
this.input = String(input) | ||
|
||
// Used to signal to callers of `readWord1` whether the word | ||
|
@@ -71,6 +79,10 @@ export class Parser { | |
this.skipLineComment(2) | ||
} | ||
|
||
// DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
marijnh
Author
Member
|
||
isKeyword(word) { return this.keywords.test(word) } | ||
isReservedWord(word) { return this.reservedWords.test(word) } | ||
|
||
extend(name, f) { | ||
this[name] = f(this[name]) | ||
} | ||
|
@marijnh I would rather keep those generic APIs around so that should we want to change behavior again / optimize using Sets / whatever in the future, API wouldn't break and plugins could continue to work. It costs nothing to us to keep them, but hides implementation details in a good way. (And, well, such small functions are inlined in any engine anyway)