Use 1-based line numbers instead of 0-based line numbers in nodes toString().
This commit is contained in:
parent
b9ebcbf555
commit
bdcd77d8e6
|
@ -122,16 +122,19 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
Base.prototype.toString = function(idt, name) {
|
Base.prototype.toString = function(idt, name) {
|
||||||
var firstLine, lastLine, location, tree, _ref2, _ref3;
|
var firstLine, lastLine, location, tree;
|
||||||
if (idt == null) {
|
if (idt == null) {
|
||||||
idt = '';
|
idt = '';
|
||||||
}
|
}
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
name = this.constructor.name;
|
name = this.constructor.name;
|
||||||
}
|
}
|
||||||
firstLine = ((_ref2 = this.locationData) != null ? _ref2.first_line : void 0) || "unknown";
|
location = "";
|
||||||
lastLine = ((_ref3 = this.locationData) != null ? _ref3.last_line : void 0) || "unknown";
|
if (this.locationData) {
|
||||||
location = firstLine + (lastLine !== firstLine ? "-" + lastLine : "") + ": ";
|
firstLine = this.locationData.first_line + 1;
|
||||||
|
lastLine = this.locationData.last_line + 1;
|
||||||
|
location = firstLine + (lastLine !== firstLine ? "-" + lastLine : "") + ": ";
|
||||||
|
}
|
||||||
tree = '\n' + idt + location + name;
|
tree = '\n' + idt + location + name;
|
||||||
if (this.soak) {
|
if (this.soak) {
|
||||||
tree += '?';
|
tree += '?';
|
||||||
|
|
|
@ -108,9 +108,11 @@ exports.Base = class Base
|
||||||
# `toString` representation of the node, for inspecting the parse tree.
|
# `toString` representation of the node, for inspecting the parse tree.
|
||||||
# This is what `coffee --nodes` prints out.
|
# This is what `coffee --nodes` prints out.
|
||||||
toString: (idt = '', name = @constructor.name) ->
|
toString: (idt = '', name = @constructor.name) ->
|
||||||
firstLine = @locationData?.first_line || "unknown"
|
location = ""
|
||||||
lastLine = @locationData?.last_line || "unknown"
|
if @locationData
|
||||||
location = firstLine + (if lastLine != firstLine then "-" + lastLine else "") + ": "
|
firstLine = @locationData.first_line + 1
|
||||||
|
lastLine = @locationData.last_line + 1
|
||||||
|
location = firstLine + (if lastLine != firstLine then "-" + lastLine else "") + ": "
|
||||||
tree = '\n' + idt + location + name
|
tree = '\n' + idt + location + name
|
||||||
tree += '?' if @soak
|
tree += '?' if @soak
|
||||||
@eachChild (node) -> tree += node.toString idt + TAB
|
@eachChild (node) -> tree += node.toString idt + TAB
|
||||||
|
|
Loading…
Reference in New Issue