aboutsummaryrefslogtreecommitdiff
path: root/lib/parse.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-09-21 14:38:52 +0300
committerMihai Bazon <mihai@bazon.net>2012-09-21 14:44:25 +0300
commitec7f895b54924e90e17d828cfd7db4c62830f93d (patch)
tree9fcfd0d402e7f8aa4274740c9fd226d890d8996b /lib/parse.js
parent5491e1d7b11e363c79bdd352883e92fa3b711e69 (diff)
downloadtracifyjs-ec7f895b54924e90e17d828cfd7db4c62830f93d.tar.gz
tracifyjs-ec7f895b54924e90e17d828cfd7db4c62830f93d.zip
log filename in parse errors / compressor warnings
Diffstat (limited to 'lib/parse.js')
-rw-r--r--lib/parse.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/parse.js b/lib/parse.js
index f04b7c6a..75d948a4 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -254,9 +254,13 @@ JS_Parse_Error.prototype.toString = function() {
return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack;
};
-function js_error(message, line, col, pos) {
- console.log("***", message);
- console.log("*** LINE:", line, "COL:", col, "POS:", pos);
+function js_error(message, filename, line, col, pos) {
+ AST_Node.warn("ERROR: {message} [{file}:{line},{col}]", {
+ message: message,
+ file: filename,
+ line: line,
+ col: col
+ });
throw new JS_Parse_Error(message, line, col, pos);
};
@@ -270,6 +274,7 @@ function tokenizer($TEXT, filename) {
var S = {
text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''),
+ filename : filename,
pos : 0,
tokpos : 0,
line : 0,
@@ -354,7 +359,7 @@ function tokenizer($TEXT, filename) {
};
function parse_error(err) {
- js_error(err, S.tokline, S.tokcol, S.tokpos);
+ js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
};
function read_num(prefix) {
@@ -718,6 +723,7 @@ function parse($TEXT, options) {
function croak(msg, line, col, pos) {
var ctx = S.input.context();
js_error(msg,
+ ctx.filename,
line != null ? line : ctx.tokline,
col != null ? col : ctx.tokcol,
pos != null ? pos : ctx.tokpos);