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 315 315 1 20152 20152 60435 3312 3312 57123 1 618 618 618 438 180 | 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--; } }); }; |