From 34ba1850b94ba4047f3b8acdc8f41862ed861447 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 15 Apr 2012 04:19:52 -0700 Subject: [PATCH] syntax: Some minor lexer refactoring --- src/librustsyntax/codemap.rs | 2 +- src/librustsyntax/parse/lexer.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/librustsyntax/codemap.rs b/src/librustsyntax/codemap.rs index 8e034690167..8ea7faf5191 100644 --- a/src/librustsyntax/codemap.rs +++ b/src/librustsyntax/codemap.rs @@ -47,7 +47,7 @@ fn mk_substr_filename(cm: codemap, sp: span) -> str } fn next_line(file: filemap, chpos: uint, byte_pos: uint) { - file.lines += [{ch: chpos, byte: byte_pos}]; + file.lines += [{ch: chpos, byte: byte_pos + file.start_pos.byte}]; } type lookup_fn = fn@(file_pos) -> uint; diff --git a/src/librustsyntax/parse/lexer.rs b/src/librustsyntax/parse/lexer.rs index d5c1c776c0e..7d0a573a448 100644 --- a/src/librustsyntax/parse/lexer.rs +++ b/src/librustsyntax/parse/lexer.rs @@ -33,8 +33,7 @@ impl reader for reader { self.col += 1u; self.chpos += 1u; if self.curr == '\n' { - codemap::next_line(self.filemap, self.chpos, self.pos + - self.filemap.start_pos.byte); + codemap::next_line(self.filemap, self.chpos, self.pos); self.col = 0u; } let next = str::char_range_at(*self.src, self.pos);