Trait parsell::Committed
[−]
[src]
pub trait Committed<Ch, Str, Output>: Uncommitted<Ch, Str, Output> { fn empty(&self) -> Output; }
A trait for committed parsers.
A parser is committed if it is guaranteed only to backtrack on empty input. CommittedInfer parsers are typically constructed by calling the methods of the library, for example:
let parser = character(char::is_alphanumeric).star(String::new);
Here, parser
is a Committed<char, Chars<'a>, String>
.
The reason for distinguishing between committed and uncommitted parsers
is that the library is designed for LL(1) grammars, that only use one token
of lookahead. This means that the sequence of two parsers
p.and_then(q)
is only well-defined when q
is committed,
since if p
commits, then q
cannot backtrack.
Semantically, a parser with input S and output T is a partial function S* → T whose domain is prefix-closed (that is, if s·t is in the domain, then s is in the domain) and non-empty.
Required Methods
fn empty(&self) -> Output
Parse an EOF.
Implementors
impl<P, F, Ch, Str, Output> Committed<Ch, Str, Output> for Map<P, F> where P: CommittedInfer<Ch, Str>, F: 'static + Copy + Function<P::Output, Output=Output>
impl<P, Q, Ch, Str, POutput, PStaticOutput, QOutput> Committed<Ch, Str, (POutput, QOutput)> for AndThen<P, Q> where P: Committed<Ch, Str, POutput>, Q: 'static + Copy + Committed<Ch, Str, QOutput>, POutput: ToStatic<Static=PStaticOutput> + Downcast<PStaticOutput>
impl<P, Q, Ch, Str, Output> Committed<Ch, Str, Output> for OrElse<P, Q> where P: Uncommitted<Ch, Str, Output>, Q: Committed<Ch, Str, Output>
impl<P, F, Ch, Str> Committed<Ch, Str, F::Output> for Star<P, F> where P: 'static + Copy + UncommittedInfer<Ch, Str>, F: 'static + Factory, Str: PeekableIterator, P::State: Stateful<Ch, Str, P::Output>, F::Output: Consumer<P::Output>
impl<P, Ch, Str, Output> Committed<Ch, Str, Option<Output>> for Opt<P> where Str: PeekableIterator, P: Uncommitted<Ch, Str, Output>
impl<F, Ch, Str> Committed<Ch, Str, F::Output> for Emit<F> where Str: PeekableIterator, F: 'static + Copy + Factory
impl<Ch, Str> Committed<Ch, Str, Option<Ch>> for AnyCharacter where Str: Iterator<Item=Ch>
impl<'a, P> Committed<char, Chars<'a>, Cow<'a, str>> for Buffered<P> where P: CommittedInfer<char, Chars<'a>>
impl<P, F, Ch, Str, Output> Committed<Ch, Str, Output> for Boxed<P, F> where P: Committed<Ch, Str, Output>, F: Function<BoxableState<P::State>>, F::Output: 'static + Stateful<Ch, Str, Output>