diff options
| -rw-r--r-- | src/lib.rs | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -911,6 +911,33 @@ where } } +struct Eof; + +impl<I> Parser<I> for Eof +where + I: Input, +{ + type Output = (); + + fn run<OM: Mode, EM: Mode, Tracer: Trace<I>>( + &self, + it: InputIter<I>, + ) -> ParserResult<I, Self::Output, OM, EM> { + if it.is_finished() { + Ok((it, OM::bind(|| ()))) + } else { + Err(EM::bind(|| it)) + } + } +} + +pub fn eof<I>() -> impl Parser<I, Output = ()> +where + I: Input, +{ + Eof +} + pub fn alpha<I>() -> impl Parser<I, Output = I> where I: Input, |
