1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1 1 12210 12210 1 1926331 12571823 477352 477352 12094471 1 60410 60410 49866 10544 | module.exports = Position; function Position() { this.line = 1; this.column = 0; } Position.prototype.push = function (str) { for (var i = 0; i < str.length; i++) { if (str[i] === "\n") { this.line++; this.column = 0; } else { this.column++; } } }; Position.prototype.unshift = function (str) { for (var i = 0; i < str.length; i++) { if (str[i] === "\n") { this.line--; } else { this.column--; } } }; |