From bcccf333ab728539bf63ed773e6182f9da33683e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 15 Nov 2012 14:34:23 -0800 Subject: Add some comments to codemap and lexer --- src/libsyntax/codemap.rs | 5 +++++ src/libsyntax/parse/lexer.rs | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index e1c5eb07eb8..a54c41e8552 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -2,6 +2,9 @@ * in a crate. This to make it possible to represent the positions * with single-word things, rather than passing records all over the * compiler. + * + * All represented positions are *absolute* positions within the codemap, + * not relative positions within a single file. */ use dvec::DVec; @@ -142,6 +145,8 @@ pub struct Loc { file: @FileMap, line: uint, col: A } +/// An absolute offset within the CodeMap (not a relative offset within a +/// a single FileMap) pub struct FilePos { ch: CharPos, byte: BytePos } diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 459935def67..1eadaec1fcd 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -21,9 +21,13 @@ trait reader { type string_reader = @{ span_diagnostic: span_handler, src: @~str, + // The absolute offset within the codemap of the next character to read mut pos: FilePos, + // The absolute offset within the codemap of the last character to be read (curr) mut last_pos: FilePos, + // The column of the next character to read mut col: CharPos, + // The last character to be read mut curr: char, filemap: @codemap::FileMap, interner: @token::ident_interner, -- cgit 1.4.1-3-g733a5