finish removal of ecmaVersion option
This commit is contained in:
@@ -42,21 +42,6 @@ pp.checkPropClash = function (prop, propHash) {
|
||||
if (propHash.proto) this.raise(key.start, "Redefinition of __proto__ property");
|
||||
propHash.proto = true;
|
||||
}
|
||||
|
||||
let other;
|
||||
if (propHash[name]) {
|
||||
other = propHash[name];
|
||||
let isGetSet = kind !== "init";
|
||||
if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init))
|
||||
this.raise(key.start, "Redefinition of property");
|
||||
} else {
|
||||
other = propHash[name] = {
|
||||
init: false,
|
||||
get: false,
|
||||
set: false
|
||||
};
|
||||
}
|
||||
other[kind] = true;
|
||||
};
|
||||
|
||||
// ### Expression parsing
|
||||
@@ -375,7 +360,7 @@ pp.parseExprAtom = function (refShorthandDefaultPos) {
|
||||
node = this.startNode();
|
||||
this.next();
|
||||
// check whether this is array comprehension or regular array
|
||||
if ((this.options.ecmaVersion >= 7 || this.options.features["es7.comprehensions"]) && this.type === tt._for) {
|
||||
if (this.options.features["es7.comprehensions"] && this.type === tt._for) {
|
||||
return this.parseComprehension(node, false);
|
||||
}
|
||||
node.elements = this.parseExprList(tt.bracketR, true, true, refShorthandDefaultPos);
|
||||
@@ -676,17 +661,15 @@ pp.parseObjPropValue = function (prop, startPos, startLoc, isGenerator, isAsync,
|
||||
};
|
||||
|
||||
pp.parsePropertyName = function (prop) {
|
||||
if (this.options.ecmaVersion >= 6) {
|
||||
if (this.eat(tt.bracketL)) {
|
||||
prop.computed = true;
|
||||
prop.key = this.parseMaybeAssign();
|
||||
this.expect(tt.bracketR);
|
||||
return prop.key;
|
||||
} else {
|
||||
prop.computed = false;
|
||||
}
|
||||
if (this.eat(tt.bracketL)) {
|
||||
prop.computed = true;
|
||||
prop.key = this.parseMaybeAssign();
|
||||
this.expect(tt.bracketR);
|
||||
return prop.key;
|
||||
} else {
|
||||
prop.computed = false;
|
||||
return prop.key = (this.type === tt.num || this.type === tt.string) ? this.parseExprAtom() : this.parseIdent(true);
|
||||
}
|
||||
return prop.key = (this.type === tt.num || this.type === tt.string) ? this.parseExprAtom() : this.parseIdent(true);
|
||||
};
|
||||
|
||||
// Initialize empty function node.
|
||||
|
||||
@@ -94,7 +94,6 @@ pp.parseRest = function () {
|
||||
// Parses lvalue (assignable) atom.
|
||||
|
||||
pp.parseBindingAtom = function () {
|
||||
if (this.options.ecmaVersion < 6) return this.parseIdent();
|
||||
switch (this.type) {
|
||||
case tt.name:
|
||||
return this.parseIdent();
|
||||
|
||||
@@ -5,11 +5,6 @@ import { SourceLocation } from "./location";
|
||||
// the parser process. These options are recognized:
|
||||
|
||||
export const defaultOptions = {
|
||||
// `ecmaVersion` indicates the ECMAScript version to parse. Must
|
||||
// be either 3, or 5, or 6. This influences support for strict
|
||||
// mode, the set of reserved words, support for getters and
|
||||
// setters and other features.
|
||||
ecmaVersion: 5,
|
||||
// Source type ("script" or "module") for different semantics
|
||||
sourceType: "script",
|
||||
// `onInsertedSemicolon` can be a callback that will be called
|
||||
|
||||
@@ -9,8 +9,7 @@ const pp = Parser.prototype;
|
||||
// Test whether a statement node is the string literal `"use strict"`.
|
||||
|
||||
pp.isUseStrict = function (stmt) {
|
||||
return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" &&
|
||||
stmt.expression.type === "Literal" && stmt.expression.raw.slice(1, -1) === "use strict";
|
||||
return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.raw.slice(1, -1) === "use strict";
|
||||
};
|
||||
|
||||
// Predicate that tests whether the next token is of the given
|
||||
|
||||
@@ -6,7 +6,7 @@ export function Parser(options, input, startPos) {
|
||||
this.options = options;
|
||||
this.sourceFile = this.options.sourceFile || null;
|
||||
this.isKeyword = keywords[6];
|
||||
this.isReservedWord = reservedWords[this.options.ecmaVersion];
|
||||
this.isReservedWord = reservedWords[6];
|
||||
this.input = input;
|
||||
this.loadPlugins(this.options.plugins);
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ pp.nextToken = function () {
|
||||
pp.readToken = function (code) {
|
||||
// Identifier or keyword. '\uXXXX' sequences are allowed in
|
||||
// identifiers, so '\' also dispatches to that.
|
||||
if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */)
|
||||
if (isIdentifierStart(code, true) || code === 92 /* '\' */)
|
||||
return this.readWord();
|
||||
|
||||
return this.getTokenFromCode(code);
|
||||
@@ -351,7 +351,6 @@ pp.getTokenFromCode = function (code) {
|
||||
case 64: ++this.pos; return this.finishToken(tt.at);
|
||||
|
||||
case 96: // '`'
|
||||
if (this.options.ecmaVersion < 6) break;
|
||||
++this.pos;
|
||||
return this.finishToken(tt.backQuote);
|
||||
|
||||
@@ -542,7 +541,6 @@ pp.readCodePoint = function () {
|
||||
let ch = this.input.charCodeAt(this.pos), code;
|
||||
|
||||
if (ch === 123) {
|
||||
if (this.options.ecmaVersion < 6) this.unexpected();
|
||||
let codePos = ++this.pos;
|
||||
code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
|
||||
++this.pos;
|
||||
|
||||
Reference in New Issue
Block a user