Struct esparse::lex::Stream
[−]
[src]
pub struct Stream<'s> { /* fields omitted */ }
Generic stream structure for source code.
A Stream
advances over its input one character at a time, tracking line and column information and providing two characters of lookahead.
Methods
impl<'s> Stream<'s>
[src]
fn new(input: &'s str) -> Self
Creates a new Stream
on the given input.
fn is(&self, c: char) -> bool
true
if and only if the current character is c
.
fn eat(&mut self, c: char) -> bool
Advances to the next character if and only if the current character is c
.
fn eat2(&mut self, c: char, d: char) -> bool
Advances by two characters if and only if the current character is c
and the next character is d
.
fn skip_while<F>(&mut self, f: F) where
F: FnMut(char) -> bool,
F: FnMut(char) -> bool,
Advances to the next character until the stream ends or f
returns false
for the current character.
fn skip_bin_digits(&mut self)
Advances past any binary digits (0
or 1
).
fn skip_oct_digits(&mut self)
Advances past any octal digits (0
through 7
).
fn skip_dec_digits(&mut self)
Advances past any decimal digits (0
through 9
).
fn skip_hex_digits(&mut self)
Advances past any hexadecimal digits (0
through 9
and a
through f
, case insensitive).
fn skip_id_continue_chars(&mut self)
Advances past any characters in the Unicode category ID_Continue.
fn skip_ws(&mut self) -> (&'s str, bool)
Advances past any whitespace or JavaScript comments.
fn pos(&self) -> usize
The bytewise position of the current character.
fn loc(&self) -> Loc
The location of the current character.
fn here(&self) -> Option<char>
The current character, or None
if the stream has reached the end of its input.
fn next(&self) -> Option<char>
The next character, or None
if the stream has reached the end of its input.
fn input(&self) -> &'s str
The entire input source code.
fn str_from(&self, start: usize) -> &'s str
A slice of the input source code from the byte at start
up to, but not including the first byte of the current character.
fn str_range(&self, start: usize, end: usize) -> &'s str
A slice of the input source code from the byte at start
up to, but not including the byte at end
.
fn advance(&mut self) -> Option<char>
Advances the stream by one character, returning the character advanced past or None
if the stream was already at the end of its input.