fixing line numbers in errors printed prior to parsing
This commit is contained in:
parent
a5e3617015
commit
453b43992d
|
@ -252,7 +252,7 @@
|
|||
i += 1;
|
||||
}
|
||||
if (levels.length) {
|
||||
throw new Error("SyntaxError: Unterminated " + (delimited[levels.pop()][0]) + " starting on line " + this.line);
|
||||
throw new Error("SyntaxError: Unterminated " + (levels.pop()[0]) + " starting on line " + (this.line + 1));
|
||||
}
|
||||
if (i === 0) {
|
||||
return false;
|
||||
|
@ -441,12 +441,12 @@
|
|||
// Error for when you try to use a forbidden word in JavaScript as
|
||||
// an identifier.
|
||||
Lexer.prototype.identifier_error = function identifier_error(word) {
|
||||
throw new Error("SyntaxError: Reserved word \"" + word + "\" on line " + this.line);
|
||||
throw new Error("SyntaxError: Reserved word \"" + word + "\" on line " + (this.line + 1));
|
||||
};
|
||||
// Error for when you try to assign to a reserved word in JavaScript,
|
||||
// like "function" or "default".
|
||||
Lexer.prototype.assignment_error = function assignment_error() {
|
||||
throw new Error("SyntaxError: Reserved word \"" + (this.value()) + "\" on line " + this.line + " can't be assigned");
|
||||
throw new Error("SyntaxError: Reserved word \"" + (this.value()) + "\" on line " + (this.line + 1) + " can't be assigned");
|
||||
};
|
||||
// Expand variables and expressions inside double-quoted strings using
|
||||
// [ECMA Harmony's interpolation syntax](http://wiki.ecmascript.org/doku.php?id=strawman:string_interpolation).
|
||||
|
|
|
@ -292,7 +292,7 @@
|
|||
levels[open] -= 1;
|
||||
}
|
||||
if (levels[open] < 0) {
|
||||
throw new Error("too many " + (token[1]));
|
||||
throw new Error("too many " + (token[1]) + " on line " + (token[2] + 1));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -220,7 +220,7 @@ exports.Lexer: class Lexer
|
|||
break
|
||||
break unless levels.length
|
||||
i += 1
|
||||
throw new Error "SyntaxError: Unterminated ${delimited[levels.pop()][0]} starting on line $@line" if levels.length
|
||||
throw new Error "SyntaxError: Unterminated ${levels.pop()[0]} starting on line ${@line + 1}" if levels.length
|
||||
return false if i is 0
|
||||
return @chunk.substring(0, i)
|
||||
|
||||
|
@ -362,12 +362,12 @@ exports.Lexer: class Lexer
|
|||
# Error for when you try to use a forbidden word in JavaScript as
|
||||
# an identifier.
|
||||
identifier_error: (word) ->
|
||||
throw new Error "SyntaxError: Reserved word \"$word\" on line $@line"
|
||||
throw new Error "SyntaxError: Reserved word \"$word\" on line ${@line + 1}"
|
||||
|
||||
# Error for when you try to assign to a reserved word in JavaScript,
|
||||
# like "function" or "default".
|
||||
assignment_error: ->
|
||||
throw new Error "SyntaxError: Reserved word \"${@value()}\" on line $@line can't be assigned"
|
||||
throw new Error "SyntaxError: Reserved word \"${@value()}\" on line ${@line + 1} can't be assigned"
|
||||
|
||||
# Expand variables and expressions inside double-quoted strings using
|
||||
# [ECMA Harmony's interpolation syntax](http://wiki.ecmascript.org/doku.php?id=strawman:string_interpolation).
|
||||
|
|
|
@ -193,7 +193,7 @@ exports.Rewriter: class Rewriter
|
|||
levels[open] ||= 0
|
||||
levels[open] += 1 if token[0] is open
|
||||
levels[open] -= 1 if token[0] is close
|
||||
throw new Error("too many ${token[1]}") if levels[open] < 0
|
||||
throw new Error("too many ${token[1]} on line ${token[2] + 1}") if levels[open] < 0
|
||||
return 1
|
||||
unclosed: key for key, value of levels when value > 0
|
||||
throw new Error("unclosed ${unclosed[0]}") if unclosed.length
|
||||
|
|
Loading…
Reference in New Issue