use exclusive ranges

This commit is contained in:
Julian Rosse 2018-08-24 02:58:28 -04:00 committed by Geoffrey Booth
parent b2669abecc
commit 6ce1d36acd
2 changed files with 5 additions and 3 deletions

View File

@ -1304,7 +1304,7 @@
}
makeLocationData({offsetInChunk, length}) {
var lastCharacter, locationData;
var endOffset, lastCharacter, locationData;
locationData = {
range: []
};
@ -1312,7 +1312,8 @@
// Use length - 1 for the final offset - were supplying the last_line and the last_column,
// so if last_column == first_column, then were looking at a character of length 1.
lastCharacter = length > 0 ? length - 1 : 0;
[locationData.last_line, locationData.last_column, locationData.range[1]] = this.getLineAndColumnFromChunk(offsetInChunk + lastCharacter);
[locationData.last_line, locationData.last_column, endOffset] = this.getLineAndColumnFromChunk(offsetInChunk + lastCharacter);
locationData.range[1] = endOffset + 1;
return locationData;
}

View File

@ -936,8 +936,9 @@ exports.Lexer = class Lexer
# Use length - 1 for the final offset - were supplying the last_line and the last_column,
# so if last_column == first_column, then were looking at a character of length 1.
lastCharacter = if length > 0 then (length - 1) else 0
[locationData.last_line, locationData.last_column, locationData.range[1]] =
[locationData.last_line, locationData.last_column, endOffset] =
@getLineAndColumnFromChunk offsetInChunk + lastCharacter
locationData.range[1] = endOffset + 1
locationData