aboutsummaryrefslogtreecommitdiff
path: root/helix-parsec/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-parsec/src/lib.rs')
-rw-r--r--helix-parsec/src/lib.rs28
1 files changed, 0 insertions, 28 deletions
diff --git a/helix-parsec/src/lib.rs b/helix-parsec/src/lib.rs
index bfa981e5..e09814b8 100644
--- a/helix-parsec/src/lib.rs
+++ b/helix-parsec/src/lib.rs
@@ -3,8 +3,6 @@
//! This module provides parsers and parser combinators which can be used
//! together to build parsers by functional composition.
-use regex::Regex;
-
// This module implements parser combinators following https://bodil.lol/parser-combinators/.
// `sym` (trait implementation for `&'static str`), `map`, `pred` (filter), `one_or_more`,
// `zero_or_more`, as well as the `Parser` trait originate mostly from that post.
@@ -104,32 +102,6 @@ pub fn token<'a>(literal: &'static str) -> impl Parser<'a, Output = &'a str> {
literal
}
-/// A parser which matches the pattern described by the given regular expression.
-///
-/// The pattern must match from the beginning of the input as if the regular expression
-/// included the `^` anchor. Using a `^` anchor in the regular expression is
-/// recommended in order to reduce any work done by the regex on non-matching input.
-///
-/// # Examples
-///
-/// ```
-/// use helix_parsec::{pattern, Parser};
-/// use regex::Regex;
-/// let regex = Regex::new(r"Hello, \w+!").unwrap();
-/// let parser = pattern(&regex);
-/// assert_eq!(Ok(("", "Hello, world!")), parser.parse("Hello, world!"));
-/// assert_eq!(Err("Hey, you!"), parser.parse("Hey, you!"));
-/// assert_eq!(Err("Oh Hello, world!"), parser.parse("Oh Hello, world!"));
-/// ```
-pub fn pattern<'a>(regex: &'a Regex) -> impl Parser<'a, Output = &'a str> {
- move |input: &'a str| match regex.find(input) {
- Some(match_) if match_.start() == 0 => {
- Ok((&input[match_.end()..], &input[0..match_.end()]))
- }
- _ => Err(input),
- }
-}
-
/// A parser which matches all values until the specified pattern is found.
///
/// If the pattern is not found, this parser does not match. The input up to the