pub trait ParseIter<'parse> {
type RawOutput;
fn match_end(&self) -> usize;
fn backtrack(
&mut self,
context: &mut ParseContext<'parse>
) -> Result<(), Reported>;
fn into_raw_output(self) -> Self::RawOutput;
}Expand description
A parser in action. Some parsers can match in several different ways (for
example, in foo* bar backtracking is accomplished by foo* first
matching as much as possible, then backing off one match at a time), so
this is an iterator.
This doesn’t return a RawOutput value from next_parse but instead waits
until you’re sure you have a complete, successful parse, and are thus ready
to destroy the iterator. This helps us avoid building values only to drop
them later when some downstream parser fails to match, so it makes
backtracking faster. It also means we don’t call .map closures until
there is a successful overall match and the values are actually needed.
Required Associated Types§
Required Methods§
sourcefn backtrack(
&mut self,
context: &mut ParseContext<'parse>
) -> Result<(), Reported>
fn backtrack(
&mut self,
context: &mut ParseContext<'parse>
) -> Result<(), Reported>
Reject the current match and find the next-most-preferable match. Returns true if another match was found, false if not.
Once this returns false, no more method calls should be made.
sourcefn into_raw_output(self) -> Self::RawOutput
fn into_raw_output(self) -> Self::RawOutput
Consume this iterator to extract data.