diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-10-25 17:29:09 -0400 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-10-25 17:29:09 -0400 |
| commit | 1426e5b7e3bee4ddc569e4cce5abfd59523b9ee8 (patch) | |
| tree | 1fa916c35150fd5c250419c28d2b488ed29c0003 /src | |
| parent | 6b7268a53df5404ab58223c13203eb873db61f1a (diff) | |
| download | mon-1426e5b7e3bee4ddc569e4cce5abfd59523b9ee8.tar.gz | |
impl Eof parser
Diffstat (limited to 'src')
| -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, |
