Struct syntax::parse::lexer::StringReader [−] [src]

pub struct StringReader<'a> {
    pub span_diagnostic: &'a SpanHandler,
    pub pos: BytePos,
    pub last_pos: BytePos,
    pub col: CharPos,
    pub curr: Option<char>,
    pub filemap: Rc<FileMap>,
    pub peek_tok: Token,
    pub peek_span: Span,
    // some fields omitted
}
Unstable

Fields

span_diagnostic
Unstable
pos
Unstable

The absolute offset within the codemap of the next character to read

last_pos
Unstable

The absolute offset within the codemap of the last character read(curr)

col
Unstable

The column of the next character to read

curr
Unstable

The last character to be read

filemap
Unstable
peek_tok
Unstable
peek_span
Unstable

Methods

impl<'a> StringReader<'a>

fn new_raw<'b>(span_diagnostic: &'b SpanHandler, filemap: Rc<FileMap>) -> StringReader<'b>

Unstable

For comments.rs, which hackily pokes into pos and curr

fn new<'b>(span_diagnostic: &'b SpanHandler, filemap: Rc<FileMap>) -> StringReader<'b>

Unstable

fn curr_is(&self, c: char) -> bool

Unstable

fn fatal_span(&self, sp: Span, m: &str) -> !

Unstable

Report a fatal lexical error with a given span.

fn err_span(&self, sp: Span, m: &str)

Unstable

Report a lexical error with a given span.

fn with_str_from<T, F>(&self, start: BytePos, f: F) -> T where F: FnOnce(&str) -> T

Unstable

Calls f with a string slice of the source text spanning from start up to but excluding self.last_pos, meaning the slice does not include the character self.curr.

fn name_from(&self, start: BytePos) -> Name

Unstable

Create a Name from a given offset to the current offset, each adjusted 1 towards each other (assumes that on either side there is a single-byte delimiter).

fn name_from_to(&self, start: BytePos, end: BytePos) -> Name

Unstable

As name_from, with an explicit endpoint.

fn bump(&mut self)

Unstable

Advance the StringReader by one character. If a newline is discovered, add it to the FileMap's list of line start offsets.

fn nextch(&self) -> Option<char>

Unstable

fn nextch_is(&self, c: char) -> bool

Unstable

fn nextnextch(&self) -> Option<char>

Unstable

fn nextnextch_is(&self, c: char) -> bool

Unstable

Trait Implementations

impl<'a> Reader for StringReader<'a>

fn is_eof(&self) -> bool

fn next_token(&mut self) -> TokenAndSpan

fn fatal(&self, m: &str) -> !

fn err(&self, m: &str)

fn peek(&self) -> TokenAndSpan

fn real_token(&mut self) -> TokenAndSpan