Struct syntex_syntax::parse::lexer::StringReader
[−]
[src]
pub struct StringReader<'a> { pub span_diagnostic: &'a Handler, pub next_pos: BytePos, pub pos: BytePos, pub col: CharPos, pub ch: Option<char>, pub filemap: Rc<FileMap>, pub terminator: Option<BytePos>, pub save_new_lines: bool, pub peek_tok: Token, pub peek_span: Span, pub fatal_errs: Vec<DiagnosticBuilder<'a>>, // some fields omitted }
Fields
span_diagnostic: &'a Handler
next_pos: BytePos
The absolute offset within the codemap of the next character to read
pos: BytePos
The absolute offset within the codemap of the current character
col: CharPos
The column of the next character to read
ch: Option<char>
The current character (which has been read from self.pos)
filemap: Rc<FileMap>
terminator: Option<BytePos>
If Some, stop reading the source at this position (inclusive).
save_new_lines: bool
Whether to record new-lines in filemap. This is only necessary the first time a filemap is lexed. If part of a filemap is being re-lexed, this should be set to false.
peek_tok: Token
peek_span: Span
fatal_errs: Vec<DiagnosticBuilder<'a>>
Methods
impl<'a> StringReader<'a>
[src]
fn new_raw<'b>(span_diagnostic: &'b Handler, filemap: Rc<FileMap>) -> StringReader<'b>
For comments.rs, which hackily pokes into next_pos and ch
fn new<'b>(span_diagnostic: &'b Handler, filemap: Rc<FileMap>) -> StringReader<'b>
fn ch_is(&self, c: char) -> bool
fn fatal_span(&self, sp: Span, m: &str) -> FatalError
Report a fatal lexical error with a given span.
fn err_span(&self, sp: Span, m: &str)
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
Calls f
with a string slice of the source text spanning from start
up to but excluding self.pos
, meaning the slice does not include
the character self.ch
.
fn name_from(&self, start: BytePos) -> Name
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
As name_from, with an explicit endpoint.
fn bump(&mut self)
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>
fn nextch_is(&self, c: char) -> bool
fn nextnextch(&self) -> Option<char>
fn nextnextch_is(&self, c: char) -> bool
Trait Implementations
impl<'a> Reader for StringReader<'a>
[src]
fn is_eof(&self) -> bool
fn try_next_token(&mut self) -> Result<TokenAndSpan, ()>
Return the next token. EFFECT: advances the string_reader.
fn fatal(&self, m: &str) -> FatalError
Report a fatal error with the current span.
fn err(&self, m: &str)
Report a non-fatal error with the current span.
fn emit_fatal_errors(&mut self)
fn peek(&self) -> TokenAndSpan
fn next_token(&mut self) -> TokenAndSpan where Self: Sized
fn unwrap_or_abort(&mut self, res: Result<TokenAndSpan, ()>) -> TokenAndSpan
fn try_real_token(&mut self) -> Result<TokenAndSpan, ()>
Get a token the parser cares about.