diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-11-20 23:12:54 +0000 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-11-20 23:12:54 +0000 |
| commit | 7fa1e34c22f4c5bfa99925560be9c23bb2d6d670 (patch) | |
| tree | 5f43249b9561e68eed045dc7889e49dffbc5f54b /src/lib.rs | |
| parent | 438ade86160efc42ecab98322ceec8ef8d73aacf (diff) | |
| download | mon-7fa1e34c22f4c5bfa99925560be9c23bb2d6d670.tar.gz | |
impl ascii alternatives to alphabetic, numeric and whitespace methods and parsers
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 76 |
1 files changed, 76 insertions, 0 deletions
@@ -965,6 +965,14 @@ where r#if(|c: &I::Item| c.is_alphabetic()) } +pub fn ascii_alpha<I>() -> impl Parser<I, Output = I::Item> +where + I: Input, + I::Item: Character, +{ + r#if(|c: &I::Item| c.is_ascii_alphabetic()) +} + pub fn alpha1<I>() -> impl Parser<I, Output = I> where I: Input, @@ -976,6 +984,17 @@ where .recognize() } +pub fn ascii_alpha1<I>() -> impl Parser<I, Output = I> +where + I: Input, + I::Item: Character, +{ + r#if(|c: &I::Item| c.is_ascii_alphabetic()) + .repeated() + .at_least(1) + .recognize() +} + pub fn numeric<I>() -> impl Parser<I, Output = I::Item> where I: Input, @@ -984,6 +1003,14 @@ where r#if(|c: &I::Item| c.is_numeric()) } +pub fn ascii_numeric<I>() -> impl Parser<I, Output = I::Item> +where + I: Input, + I::Item: Character, +{ + r#if(|c: &I::Item| c.is_ascii() && c.is_numeric()) +} + pub fn numeric1<I>() -> impl Parser<I, Output = I> where I: Input, @@ -995,6 +1022,17 @@ where .recognize() } +pub fn ascii_numeric1<I>() -> impl Parser<I, Output = I> +where + I: Input, + I::Item: Character, +{ + r#if(|c: &I::Item| c.is_ascii() && c.is_numeric()) + .repeated() + .at_least(1) + .recognize() +} + pub fn alphanumeric<I>() -> impl Parser<I, Output = I::Item> where I: Input, @@ -1003,6 +1041,14 @@ where r#if(|c: &I::Item| c.is_alphanumeric()) } +pub fn ascii_alphanumeric<I>() -> impl Parser<I, Output = I::Item> +where + I: Input, + I::Item: Character, +{ + r#if(|c: &I::Item| c.is_ascii_alphanumeric()) +} + pub fn alphanumeric1<I>() -> impl Parser<I, Output = I> where I: Input, @@ -1014,6 +1060,17 @@ where .recognize() } +pub fn ascii_alphanumeric1<I>() -> impl Parser<I, Output = I> +where + I: Input, + I::Item: Character, +{ + r#if(|c: &I::Item| c.is_ascii_alphanumeric()) + .repeated() + .at_least(1) + .recognize() +} + pub fn whitespace<I>() -> impl Parser<I, Output = I::Item> where I: Input, @@ -1022,6 +1079,14 @@ where r#if(|c: &I::Item| c.is_whitespace()) } +pub fn ascii_whitespace<I>() -> impl Parser<I, Output = I::Item> +where + I: Input, + I::Item: Character, +{ + r#if(|c: &I::Item| c.is_ascii_whitespace()) +} + pub fn whitespace1<I>() -> impl Parser<I, Output = I> where I: Input, @@ -1033,6 +1098,17 @@ where .recognize() } +pub fn ascii_whitespace1<I>() -> impl Parser<I, Output = I> +where + I: Input, + I::Item: Character, +{ + r#if(|c: &I::Item| c.is_ascii_whitespace()) + .repeated() + .at_least(1) + .recognize() +} + pub fn any<I>() -> impl Parser<I, Output = I::Item> where I: Input, |
