![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/node_modules/lop/lib/ |
var StringSource = module.exports = function(string, description) {
var self = {
asString: function() {
return string;
},
range: function(startIndex, endIndex) {
return new StringSourceRange(string, description, startIndex, endIndex);
}
};
return self;
};
var StringSourceRange = function(string, description, startIndex, endIndex) {
this._string = string;
this._description = description;
this._startIndex = startIndex;
this._endIndex = endIndex;
};
StringSourceRange.prototype.to = function(otherRange) {
// TODO: Assert that tokens are the same across both iterators
return new StringSourceRange(this._string, this._description, this._startIndex, otherRange._endIndex);
};
StringSourceRange.prototype.describe = function() {
var position = this._position();
var description = this._description ? this._description + "\n" : "";
return description + "Line number: " + position.lineNumber + "\nCharacter number: " + position.characterNumber;
};
StringSourceRange.prototype.lineNumber = function() {
return this._position().lineNumber;
};
StringSourceRange.prototype.characterNumber = function() {
return this._position().characterNumber;
};
StringSourceRange.prototype._position = function() {
var self = this;
var index = 0;
var nextNewLine = function() {
return self._string.indexOf("\n", index);
};
var lineNumber = 1;
while (nextNewLine() !== -1 && nextNewLine() < this._startIndex) {
index = nextNewLine() + 1;
lineNumber += 1;
}
var characterNumber = this._startIndex - index + 1;
return {lineNumber: lineNumber, characterNumber: characterNumber};
};