Struct moore_common::lexer::BufferedLexer
source · [−]pub struct BufferedLexer<T> { /* private fields */ }
Expand description
A buffered lexer that allows tokens to be peeked at before they are actually consumed.
Implementations
sourceimpl<T: Clone + PartialEq> BufferedLexer<T>
impl<T: Clone + PartialEq> BufferedLexer<T>
sourcepub fn new(inner: Box<dyn Lexer<T>>, eof: T) -> BufferedLexer<T>
pub fn new(inner: Box<dyn Lexer<T>>, eof: T) -> BufferedLexer<T>
Create a new buffered lexer.
sourcepub fn peek<'td>(&mut self, offset: usize) -> DiagResult<'td, &T>
pub fn peek<'td>(&mut self, offset: usize) -> DiagResult<'td, &T>
Peek at a token not yet consumed. This function merely returns a
reference to said token. Use pop()
to advance the lexer.
sourcepub fn push(&mut self, token: T)
pub fn push(&mut self, token: T)
Insert a token in front of the stream such that it becomes the next
token to be returned from peek(0)
or pop()
.
sourcepub fn pop<'td>(&mut self) -> DiagResult<'td, T>
pub fn pop<'td>(&mut self) -> DiagResult<'td, T>
Consume and return the current token. This is the same token that would
be returned by peek(0)
.
pub fn inner(&self) -> &dyn Lexer<T>
pub fn inner_mut(&mut self) -> &mut dyn Lexer<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for BufferedLexer<T>
impl<T> !Send for BufferedLexer<T>
impl<T> !Sync for BufferedLexer<T>
impl<T> Unpin for BufferedLexer<T> where
T: Unpin,
impl<T> !UnwindSafe for BufferedLexer<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more