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

Parse an EOF.

Implementors