Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (this.tok.type === tt.num && node.raw.charCodeAt(node.raw.length - 1) === 110) node.bigint = node.raw.slice(0, -1)
this.next()
return this.finishNode(node, "Literal")
case tt._null: case tt._true: case tt._false:
node = this.startNode()
node.value = this.tok.type === tt._null ? null : this.tok.type === tt._true
node.raw = this.tok.type.keyword
this.next()
return this.finishNode(node, "Literal")
case tt.parenL:
let parenStart = this.storeCurrentPos()
this.next()
let inner = this.parseExpression()
this.expect(tt.parenR)
if (this.eat(tt.arrow)) {
// (a,)=>a // SequenceExpression makes dummy in the last hole. Drop the dummy.
let params = inner.expressions || [inner]
if (params.length && isDummy(params[params.length - 1]))
params.pop()
return this.parseArrowExpression(this.startNodeAt(parenStart), params)
}
if (this.options.preserveParens) {
let par = this.startNodeAt(parenStart)
par.expression = inner
inner = this.finishNode(par, "ParenthesizedExpression")
}
return inner
case tt.bracketL:
node = this.startNode()
lp.parseFor = function(node, init) {
node.init = init
node.test = node.update = null
if (this.eat(tt.semi) && this.tok.type !== tt.semi) node.test = this.parseExpression()
if (this.eat(tt.semi) && this.tok.type !== tt.parenR) node.update = this.parseExpression()
this.popCx()
this.expect(tt.parenR)
node.body = this.parseStatement()
return this.finishNode(node, "ForStatement")
}
lp.parseForIn = function(node, init) {
let type = this.tok.type === tt._in ? "ForInStatement" : "ForOfStatement"
this.next()
node.left = init
node.right = this.parseExpression()
this.popCx()
this.expect(tt.parenR)
node.body = this.parseStatement()
return this.finishNode(node, type)
}
lp.parseDynamicImport = function(node) {
node.source = this.parseExprList(tt.parenR)[0] || this.dummyString()
return this.finishNode(node, "ImportExpression")
}
function parseImportCall(parser) {
const node = parser.startNode();
const {start} = parser;
const callExpr = parser.startNode();
const callee = parser.parseExprAtom();
parser.expect(tt.parenL);
callExpr.arguments = [parser.parseMaybeAssign()];
callExpr.callee = callee;
parser.finishNode(callExpr, "CallExpression");
parser.expect(tt.parenR);
const expr = parser.parseSubscripts(callExpr, start);
return parser.parseExpressionStatement(node, expr);
}
lp.parseFor = function(node, init) {
node.init = init
node.test = node.update = null
if (this.eat(tt.semi) && this.tok.type !== tt.semi) node.test = this.parseExpression()
if (this.eat(tt.semi) && this.tok.type !== tt.parenR) node.update = this.parseExpression()
this.popCx()
this.expect(tt.parenR)
node.body = this.parseStatement()
return this.finishNode(node, "ForStatement")
}
lp.parseFor = function(node, init) {
node.init = init
node.test = node.update = null
if (this.eat(tt.semi) && this.tok.type !== tt.semi) node.test = this.parseExpression()
if (this.eat(tt.semi) && this.tok.type !== tt.parenR) node.update = this.parseExpression()
this.popCx()
this.expect(tt.parenR)
node.body = this.parseStatement()
return this.finishNode(node, "ForStatement")
}
lp.parseParenExpression = function() {
this.pushCx()
this.expect(tt.parenL)
let val = this.parseExpression()
this.popCx()
this.expect(tt.parenR)
return val
}