Commit 4beeb166 authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[torque] Fix column numbers in source positions

The recent introduction of 'end' positions incorrectly tracked column
positions. This CL fixes that.

R=tebbi@chromium.org

Bug: v8:7793
Change-Id: I2170ebb2dda062c9842dad657c3c516e0550b459
Reviewed-on: https://chromium-review.googlesource.com/c/1482830Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59794}
parent 852dd802
......@@ -119,21 +119,23 @@ LexerResult Lexer::RunLexer(const std::string& input) {
LineAndColumnTracker line_column_tracker;
match_whitespace_(&pos);
line_column_tracker.Advance(token_start, pos);
while (pos != end) {
line_column_tracker.Advance(token_start, pos);
token_start = pos;
Symbol* symbol = MatchToken(&pos, end);
InputPosition token_end = pos;
line_column_tracker.Advance(token_start, token_end);
if (!symbol) {
ReportError("Lexer Error: unknown token " +
StringLiteralQuote(std::string(
token_start, token_start + std::min<ptrdiff_t>(
end - token_start, 10))));
}
line_column_tracker.Advance(token_start, pos);
result.token_symbols.push_back(symbol);
result.token_contents.push_back(
{token_start, pos, line_column_tracker.ToSourcePosition()});
match_whitespace_(&pos);
line_column_tracker.Advance(token_end, pos);
}
// Add an additional token position to simplify corner cases.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment