[][src]Struct oak_runtime::parse_state::ParseState

pub struct ParseState<S, T> {
    pub farthest_read: S,
    pub expected: Vec<&'static str>,
    pub failed: bool,
    pub current: S,
    pub data: Option<T>,
}

ParseState<S, T> reads value from the stream S and build an AST of type T. Error strategy: Even in case of success, we keep error information in case we fail later. Think about parsing "abaa" with "ab"* "c", it will directly fails on "c", so it is better to report an error such as expected "ab" but got "aa" since the input partially matches "ab"`.

Fields

farthest_read: S

The farthest read into the stream at which we encountered an error.

expected: Vec<&'static str>

Expected items at position farthest_read. Duplicate entries are possible.

failed: boolcurrent: S

The current stream that can be partially or fully consumed.

data: Option<T>

Contains the AST if the current state is successful and None if it is erroneous.

Implementations

impl<S, T> ParseState<S, T> where
    S: Ord + Clone + HasNext
[src]

pub fn new(stream: S) -> ParseState<S, T>

Notable traits for ParseState<S, T>

impl<S, T, I> Iterator for ParseState<S, T> where
    S: Iterator<Item = I>, 
type Item = I;
[src]

pub fn is_failed(&self) -> bool[src]

pub fn is_successful(&self) -> bool[src]

pub fn error(&mut self, expect: &'static str)[src]

pub fn success<U>(self, data: U) -> ParseState<S, U>

Notable traits for ParseState<S, T>

impl<S, T, I> Iterator for ParseState<S, T> where
    S: Iterator<Item = I>, 
type Item = I;
[src]

pub fn failure<U>(self) -> ParseState<S, U>

Notable traits for ParseState<S, T>

impl<S, T, I> Iterator for ParseState<S, T> where
    S: Iterator<Item = I>, 
type Item = I;
[src]

pub fn mark(&self) -> S[src]

pub fn restore_from_failure(self, mark: S) -> ParseState<S, ()>

Notable traits for ParseState<S, T>

impl<S, T, I> Iterator for ParseState<S, T> where
    S: Iterator<Item = I>, 
type Item = I;
[src]

pub fn restore(self, mark: S) -> ParseState<S, ()>

Notable traits for ParseState<S, T>

impl<S, T, I> Iterator for ParseState<S, T> where
    S: Iterator<Item = I>, 
type Item = I;
[src]

pub fn into_result(self) -> ParseResult<S, T>[src]

Transforms self into a more usable ParseResult value. It is useful when the state is terminal or if the state will not be further transformed.

pub fn extract_data(self) -> (ParseState<S, ()>, T)[src]

pub fn unwrap_data(self) -> T[src]

impl<S> ParseState<S, ()>[src]

pub fn discard_data(&mut self)[src]

Trait Implementations

impl<S, T, P> ConsumePrefix<P> for ParseState<S, T> where
    S: ConsumePrefix<P>, 
[src]

impl<S, T, I> Iterator for ParseState<S, T> where
    S: Iterator<Item = I>, 
[src]

type Item = I

The type of the elements being iterated over.

Auto Trait Implementations

impl<S, T> RefUnwindSafe for ParseState<S, T> where
    S: RefUnwindSafe,
    T: RefUnwindSafe
[src]

impl<S, T> Send for ParseState<S, T> where
    S: Send,
    T: Send
[src]

impl<S, T> Sync for ParseState<S, T> where
    S: Sync,
    T: Sync
[src]

impl<S, T> Unpin for ParseState<S, T> where
    S: Unpin,
    T: Unpin
[src]

impl<S, T> UnwindSafe for ParseState<S, T> where
    S: UnwindSafe,
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.