Skip to main content

AtomStream

Struct AtomStream 

Source
pub struct AtomStream { /* private fields */ }
Expand description

A parse source over an eagerly lexed token vector.

Backtracking runs through syan’s Tape, which owns the pushback and the checkpoint scopes, so this is a thin forwarding shim and nothing more.

Implementations§

Source§

impl AtomStream

Source

pub fn new(atoms: Vec<Atom>) -> Self

Trait Implementations§

Source§

impl ParseStream for AtomStream

Source§

type Atom = WithSpan<Token, Span>

The unit of input this stream serves.
Source§

type Error = Infallible

What the underlying source reports when it fails; see get_error.
Source§

fn next(&mut self) -> Option<Self::Atom>

Consume and return the next atom, or None at end of input.
Source§

fn peek(&mut self) -> Option<&Self::Atom>

The atom next would return, without consuming it.
Source§

fn push(&mut self, atom: Self::Atom)

Hand an atom back; it is served before anything still unread.
Source§

fn checkpoint_raw(&mut self) -> u64

Open a transaction; the returned token identifies it. Read more
Source§

fn rollback_raw(&mut self, raw: u64)

Undo everything consumed since raw was taken, and close that scope.
Source§

fn commit_raw(&mut self, raw: u64)

Keep everything consumed since raw was taken, and close that scope.
Source§

fn get_error(&mut self) -> Result<(), Self::Error>

Report an error the source has accumulated (a lexer that failed mid-stream, say), as opposed to a parse failure. Ok(()) for a source that cannot fail.
Source§

fn skip_sep(&mut self) -> bool

Skip the separator atoms if exists. Returns whether we skipped some separators. Read more
Source§

fn validate_spacing<S>(&mut self, is_joint: bool) -> Result<(), ParseError<S>>
where S: Span, Self: Sized, Self::Atom: Spanned<Span = S>,

Check the spacing before the next atom: is_joint demands no separator here, false demands one. Fails with ParseError::Spacing if the input disagrees.
Source§

fn dup<T, E, F>(&mut self, f: F) -> Result<T, E>
where F: FnOnce(&mut Self) -> Result<T, E>, Self: Sized,

Run a sub-parser as a transaction on this stream. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoParseStream for T
where T: ParseStream,

Source§

type Atom = <T as ParseStream>::Atom

The unit of input the resulting stream serves.
Source§

type Output = T

The stream this becomes.
Source§

fn into_parse_stream(self) -> <T as IntoParseStream>::Output

Build the stream.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.