Pass 0-based indexes to CompilerError

This commit is contained in:
Demian Ferreiro
2013-02-25 15:12:25 -03:00
parent caacd892cc
commit 7e5f1b14a3
6 changed files with 10 additions and 10 deletions

View File

@@ -180,7 +180,7 @@
loc = _arg.loc, token = _arg.token;
message = "unexpected " + token;
first_line = loc.first_line, first_column = loc.first_column, last_line = loc.last_line, last_column = loc.last_column;
throw new CompilerError(message, first_line + 1, first_column + 1, last_line + 1, last_column + 1);
throw new CompilerError(message, first_line, first_column, last_line, last_column);
};
}).call(this);

View File

@@ -25,11 +25,11 @@
CompilerError.prototype.prettyMessage = function(fileName, code) {
var errorLength, errorLine, marker, message;
message = "" + fileName + ":" + this.startLine + ":" + this.startColumn + ": error: " + this.message;
message = "" + fileName + ":" + (this.startLine + 1) + ":" + (this.startColumn + 1) + ": error: " + this.message;
if (this.startLine === this.endLine) {
errorLine = code.split('\n')[this.startLine - 1];
errorLine = code.split('\n')[this.startLine];
errorLength = this.endColumn - this.startColumn + 1;
marker = (repeat(' ', this.startColumn - 1)) + (repeat('^', errorLength));
marker = (repeat(' ', this.startColumn)) + (repeat('^', errorLength));
message += "\n" + errorLine + "\n" + marker;
} else {
void 0;

View File

@@ -788,7 +788,7 @@
};
Lexer.prototype.error = function(message) {
throw new CompilerError(message, this.chunkLine + 1, this.chunkColumn + 1);
throw new CompilerError(message, this.chunkLine, this.chunkColumn);
};
return Lexer;