syntax: Some minor lexer refactoring

This commit is contained in:
Brian Anderson 2012-04-15 04:19:52 -07:00
parent 4b4f064315
commit 34ba1850b9
2 changed files with 2 additions and 3 deletions

View File

@ -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;

View File

@ -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);