on master help sign in
Remove now unused the pattern combinator
3f90dafUrgau
Cargo.lock−3
@@ -1152,9 +1152,6 @@ dependencies = [
1152[[package]]
1152[[package]]
1153name = "helix-parsec"
1153name = "helix-parsec"
1154version = "0.6.0"
1154version = "0.6.0"
1155−dependencies = [
1156− "regex",
1157−]
1158
1155
1159[[package]]
1156[[package]]
1160name = "helix-term"
1157name = "helix-term"
helix-parsec/Cargo.toml−1
@@ -11,4 +11,3 @@ homepage = "https://helix-editor.com"
11include = ["src/**/*", "README.md"]
11include = ["src/**/*", "README.md"]
12
12
13[dependencies]
13[dependencies]
14−regex = "1"
helix-parsec/src/lib.rs−28
@@ -3,8 +3,6 @@
3//! This module provides parsers and parser combinators which can be used
3//! This module provides parsers and parser combinators which can be used
4//! together to build parsers by functional composition.
4//! together to build parsers by functional composition.
5
5
6−use regex::Regex;
7−
8// This module implements parser combinators following https://bodil.lol/parser-combinators/.
6// This module implements parser combinators following https://bodil.lol/parser-combinators/.
9// `sym` (trait implementation for `&'static str`), `map`, `pred` (filter), `one_or_more`,
7// `sym` (trait implementation for `&'static str`), `map`, `pred` (filter), `one_or_more`,
10// `zero_or_more`, as well as the `Parser` trait originate mostly from that post.
8// `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> {
104 literal
102 literal
105}
103}
106
104
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−
133/// A parser which matches all values until the specified pattern is found.
105/// A parser which matches all values until the specified pattern is found.
134///
106///
135/// If the pattern is not found, this parser does not match. The input up to the
107/// If the pattern is not found, this parser does not match. The input up to the