summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index fc91cb1..e0be671 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -740,6 +740,36 @@ where
}
}
+struct Not<P> {
+ parser: P,
+}
+
+impl<I, P> Parser<I> for Not<P>
+where
+ I: Input,
+ P: Parser<I>,
+{
+ type Output = ();
+
+ fn run<OM: Mode, EM: Mode, T: Trace<I>>(
+ &mut self,
+ it: InputIter<I>,
+ ) -> ParserResult<I, Self::Output, OM, EM> {
+ match self.parser.check(it.clone()) {
+ Ok(_) => Ok((it, OM::bind(|| ()))),
+ Err(rest) => Err(EM::bind(|| rest)),
+ }
+ }
+}
+
+pub fn not<I, P>(parser: P) -> impl Parser<I, Output = ()>
+where
+ I: Input,
+ P: Parser<I>,
+{
+ Not { parser }
+}
+
pub fn alpha<I>() -> impl Parser<I, Output = I>
where
I: Input,