remove newline assurance and add optional Error constructor to File::errorWithNode

This commit is contained in:
Sebastian McKenzie
2014-11-07 13:51:31 +11:00
parent df70be4ebb
commit 56ac964e54

View File

@@ -81,16 +81,11 @@ File.prototype.addDeclaration = function (name) {
return uid;
};
File.prototype.errorWithNode = function (node, msg) {
var loc;
File.prototype.errorWithNode = function (node, msg, Error) {
Error = Error || SyntaxError;
if (node.loc) {
loc = node.loc.start;
} else {
loc = acorn.getLineInfo(this.code, node.start);
}
var err = new SyntaxError("Line " + loc.line + ": " + msg);
var loc = node.loc.start;
var err = new Error("Line " + loc.line + ": " + msg);
err.loc = loc;
return err;
};
@@ -98,9 +93,8 @@ File.prototype.errorWithNode = function (node, msg) {
File.prototype.parse = function (code) {
var self = this;
code = code.trimRight() + "\n";
this.code = code;
code = this.parseShebang(code);
return util.parse(this.opts, code, function (tree) {