summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-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,