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 29 30 31 32 33 34 | 1 1 1 437 437 1 52550 52550 162559 7895 7895 154664 1 1340 1340 1340 922 418 | module.exports = Position; var _ = require("lodash"); function Position() { this.line = 1; this.column = 0; } Position.prototype.push = function (str) { var self = this; _.each(str, function (cha) { if (cha === "\n") { self.line++; self.column = 0; } else { self.column++; } }); }; Position.prototype.unshift = function (str) { var self = this; _.each(str, function (cha) { if (cha === "\n") { self.line--; } else { self.column--; } }); }; |