pub struct StringReader {
span_diagnostic: @SpanHandler,
- src: @str,
// The absolute offset within the codemap of the next character to read
pos: Cell<BytePos>,
// The absolute offset within the codemap of the last character read(curr)
let initial_char = '\n';
let r = @StringReader {
span_diagnostic: span_diagnostic,
- src: filemap.src,
pos: Cell::new(filemap.start_pos),
last_pos: Cell::new(filemap.start_pos),
col: Cell::new(CharPos(0)),
fn dup_string_reader(r: @StringReader) -> @StringReader {
@StringReader {
span_diagnostic: r.span_diagnostic,
- src: r.src,
pos: Cell::new(r.pos.get()),
last_pos: Cell::new(r.last_pos.get()),
col: Cell::new(r.col.get()),
-> ! {
let mut m = m;
m.push_str(": ");
- let s = rdr.src.slice(
+ let s = rdr.filemap.src.slice(
byte_offset(rdr, from_pos).to_uint(),
byte_offset(rdr, to_pos).to_uint());
m.push_str(s);
end: BytePos,
f: |s: &str| -> T)
-> T {
- f(rdr.src.slice(
+ f(rdr.filemap.src.slice(
byte_offset(rdr, start).to_uint(),
byte_offset(rdr, end).to_uint()))
}
pub fn bump(rdr: &StringReader) {
rdr.last_pos.set(rdr.pos.get());
let current_byte_offset = byte_offset(rdr, rdr.pos.get()).to_uint();
- if current_byte_offset < (rdr.src).len() {
+ if current_byte_offset < (rdr.filemap.src).len() {
assert!(rdr.curr.get() != unsafe {
transmute(-1u32)
}); // FIXME: #8971: unsound
let last_char = rdr.curr.get();
- let next = rdr.src.char_range_at(current_byte_offset);
+ let next = rdr.filemap.src.char_range_at(current_byte_offset);
let byte_offset_diff = next.next - current_byte_offset;
rdr.pos.set(rdr.pos.get() + Pos::from_uint(byte_offset_diff));
rdr.curr.set(next.ch);
}
pub fn nextch(rdr: @StringReader) -> char {
let offset = byte_offset(rdr, rdr.pos.get()).to_uint();
- if offset < (rdr.src).len() {
- return rdr.src.char_at(offset);
+ if offset < (rdr.filemap.src).len() {
+ return rdr.filemap.src.char_at(offset);
} else { return unsafe { transmute(-1u32) }; } // FIXME: #8971: unsound
}