diff options
-rw-r--r-- | Cargo.lock | 3 | ||||
-rw-r--r-- | helix-parsec/Cargo.toml | 1 | ||||
-rw-r--r-- | helix-parsec/src/lib.rs | 28 |
3 files changed, 0 insertions, 32 deletions
@@ -1152,9 +1152,6 @@ dependencies = [ [[package]] name = "helix-parsec" version = "0.6.0" -dependencies = [ - "regex", -] [[package]] name = "helix-term" diff --git a/helix-parsec/Cargo.toml b/helix-parsec/Cargo.toml index 562df8dd..505a4247 100644 --- a/helix-parsec/Cargo.toml +++ b/helix-parsec/Cargo.toml @@ -11,4 +11,3 @@ homepage = "https://helix-editor.com" include = ["src/**/*", "README.md"] [dependencies] -regex = "1" 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(®ex); -/// 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 |