summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-10-25 17:29:09 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-10-25 17:29:09 -0400
commit1426e5b7e3bee4ddc569e4cce5abfd59523b9ee8 (patch)
tree1fa916c35150fd5c250419c28d2b488ed29c0003
parent6b7268a53df5404ab58223c13203eb873db61f1a (diff)
downloadmon-1426e5b7e3bee4ddc569e4cce5abfd59523b9ee8.tar.gz
impl Eof parser
-rw-r--r--src/lib.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index d0b9cb3..930acfe 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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,