Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raise(pos, message) {
const loc = acorn.getLineInfo(this.input, pos);
const err = new SyntaxError(message);
err.index = pos;
err.lineNumber = loc.line;
err.column = loc.column + 1; // acorn uses 0-based columns
throw err;
}
}
} 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
}
}
}
}
function parseFileAttachments(cell, input) {
if (cell.body && cell.body.type !== "ImportDeclaration") {
try {
cell.fileAttachments = findFileAttachments(cell);
} catch (error) {
if (error.node) {
const loc = getLineInfo(input, error.node.start);
error.message += ` (${loc.line}:${loc.column})`;
error.pos = error.node.start;
error.loc = loc;
delete error.node;
}
throw error;
}
} else {
cell.fileAttachments = new Map();
}
return cell;
}
lp.parseTopLevel = function() {
let node = this.startNodeAt(this.options.locations ? [0, getLineInfo(this.input, 0)] : 0)
node.body = []
while (this.tok.type !== tt.eof) node.body.push(this.parseStatement())
this.last = this.tok
if (this.options.ecmaVersion >= 6) {
node.sourceType = this.options.sourceType
}
return this.finishNode(node, "Program")
}
lp.parseTopLevel = function() {
let node = this.startNodeAt(this.options.locations ? [0, getLineInfo(this.input, 0)] : 0)
node.body = []
while (this.tok.type !== tt.eof) node.body.push(this.parseStatement())
this.toks.adaptDirectivePrologue(node.body)
this.last = this.tok
node.sourceType = this.options.sourceType
return this.finishNode(node, "Program")
}
getImportStackDump()
{
if (this.compilerStateStack.length === 0)
return null;
let stack = "";
for (const state of this.compilerStateStack)
{
const
sourcePath = utils.getRelativeSourcePath(state.sourcePath),
line = acorn.getLineInfo(state.source, state.node.start).line;
stack += `In file imported from '${sourcePath}':${line}\n`;
}
return stack;
}