on master help sign in
Remove now unused the pattern combinator
commit3f90dafa3c4875cb33f404392552edc2381e6bf7 authorUrgau <urgau@numericable.fr> dateThu 16 Feb 2023, 11:21 (4 years ago) parente973b71
3 files changed−32
Cargo.lock−3 helix-parsec/Cargo.toml−1 helix-parsec/src/lib.rs−28
Cargo.lock−3
@@ -1152,9 +1152,6 @@ dependencies = [
11521152[[package]]
11531153name = "helix-parsec"
11541154version = "0.6.0"
1155−dependencies = [
1156− "regex",
1157−]
11581155
11591156[[package]]
11601157name = "helix-term"
helix-parsec/Cargo.toml−1
@@ -11,4 +11,3 @@ homepage = "https://helix-editor.com"
1111include = ["src/**/*", "README.md"]
1212
1313[dependencies]
14−regex = "1"
helix-parsec/src/lib.rs−28
@@ -3,8 +3,6 @@
33//! This module provides parsers and parser combinators which can be used
44//! together to build parsers by functional composition.
55
6−use regex::Regex;
7−
86// This module implements parser combinators following https://bodil.lol/parser-combinators/.
97// `sym` (trait implementation for `&'static str`), `map`, `pred` (filter), `one_or_more`,
108// `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> {
104102 literal
105103}
106104
107−/// A parser which matches the pattern described by the given regular expression.
108−///
109−/// The pattern must match from the beginning of the input as if the regular expression
110−/// included the `^` anchor. Using a `^` anchor in the regular expression is
111−/// recommended in order to reduce any work done by the regex on non-matching input.
112−///
113−/// # Examples
114−///
115−/// ```
116−/// use helix_parsec::{pattern, Parser};
117−/// use regex::Regex;
118−/// let regex = Regex::new(r"Hello, \w+!").unwrap();
119−/// let parser = pattern(&regex);
120−/// assert_eq!(Ok(("", "Hello, world!")), parser.parse("Hello, world!"));
121−/// assert_eq!(Err("Hey, you!"), parser.parse("Hey, you!"));
122−/// assert_eq!(Err("Oh Hello, world!"), parser.parse("Oh Hello, world!"));
123−/// ```
124−pub fn pattern<'a>(regex: &'a Regex) -> impl Parser<'a, Output = &'a str> {
125− move |input: &'a str| match regex.find(input) {
126− Some(match_) if match_.start() == 0 => {
127− Ok((&input[match_.end()..], &input[0..match_.end()]))
128− }
129− _ => Err(input),
130− }
131−}
132−
133105/// A parser which matches all values until the specified pattern is found.
134106///
135107/// If the pattern is not found, this parser does not match. The input up to the