Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.O_function = 0;
this.O_async = false;
this.O_generator = false;
this.strict = true;
this.enterScope(SCOPE_FUNCTION | SCOPE_ASYNC | SCOPE_GENERATOR);
// An import?
if (token.type === tt._import && lookahead.getToken().type !== tt.parenL) {
body = this.parseImport(this.startNode());
}
// A non-empty cell?
else if (token.type !== tt.eof && token.type !== tt.semi) {
// A named cell?
if (token.type === tt.name) {
if (token.value === "viewof" || token.value === "mutable") {
token = lookahead.getToken();
if (token.type !== tt.name) {
lookahead.unexpected();
}
}
token = lookahead.getToken();
if (token.type === tt.eq) {
id =
this.parseMaybeKeywordExpression("viewof", "ViewExpression") ||
this.parseMaybeKeywordExpression("mutable", "MutableExpression") ||
this.parseIdent();
token = lookahead.getToken();
this.expect(tt.eq);
}
}
this.O_generator = false;
this.strict = true;
this.enterScope(SCOPE_FUNCTION | SCOPE_ASYNC | SCOPE_GENERATOR);
// An import?
if (token.type === tt._import && lookahead.getToken().type !== tt.parenL) {
body = this.parseImport(this.startNode());
}
// A non-empty cell?
else if (token.type !== tt.eof && token.type !== tt.semi) {
// A named cell?
if (token.type === tt.name) {
if (token.value === "viewof" || token.value === "mutable") {
token = lookahead.getToken();
if (token.type !== tt.name) {
lookahead.unexpected();
}
}
token = lookahead.getToken();
if (token.type === tt.eq) {
id =
this.parseMaybeKeywordExpression("viewof", "ViewExpression") ||
this.parseMaybeKeywordExpression("mutable", "MutableExpression") ||
this.parseIdent();
token = lookahead.getToken();
this.expect(tt.eq);
}
}
// A block?
if (token.type === tt.braceL) {
while (pos < this.input.length && !isSpace(this.input.charCodeAt(pos))) ++pos
} else if (/character escape|expected hexadecimal/i.test(msg)) {
while (pos < this.input.length) {
let ch = this.input.charCodeAt(pos++)
if (ch === 34 || ch === 39 || isNewLine(ch)) break
}
} else if (/unexpected character/i.test(msg)) {
pos++
replace = false
} else if (/regular expression/i.test(msg)) {
replace = true
} else {
throw e
}
this.resetTo(pos)
if (replace === true) replace = {start: pos, end: pos, type: tt.name, value: "✖"}
if (replace) {
if (this.options.locations)
replace.loc = new SourceLocation(
this.toks,
getLineInfo(this.input, replace.start),
getLineInfo(this.input, replace.end))
return replace
}
}
}
}
eatContextual(name) {
return this.tok.value === name && this.eat(tt.name)
}
switch (this.tok.type) {
case tt._this:
case tt._super:
let type = this.tok.type === tt._this ? "ThisExpression" : "Super"
node = this.startNode()
this.next()
return this.finishNode(node, type)
case tt.name:
let start = this.storeCurrentPos()
let id = this.parseIdent()
let isAsync = false
if (id.name === "async" && !this.canInsertSemicolon()) {
if (this.eat(tt._function))
return this.parseFunction(this.startNodeAt(start), false, true)
if (this.tok.type === tt.name) {
id = this.parseIdent()
isAsync = true
}
}
return this.eat(tt.arrow) ? this.parseArrowExpression(this.startNodeAt(start), [id], isAsync) : id
case tt.regexp:
node = this.startNode()
let val = this.tok.value
node.regex = {pattern: val.pattern, flags: val.flags}
node.value = val.value
node.raw = this.input.slice(this.tok.start, this.tok.end)
this.next()
return this.finishNode(node, "Literal")
case tt.num: case tt.string:
lp.parsePropertyAccessor = function() {
if (this.tok.type === tt.name || this.tok.type.keyword) return this.parseIdent()
}
isContextual(name) {
return this.tok.type === tt.name && this.tok.value === name
}