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 /tests/sexpr.rs | |
| parent | 438ade86160efc42ecab98322ceec8ef8d73aacf (diff) | |
| download | mon-7fa1e34c22f4c5bfa99925560be9c23bb2d6d670.tar.gz | |
impl ascii alternatives to alphabetic, numeric and whitespace methods and parsers
Diffstat (limited to 'tests/sexpr.rs')
| -rw-r--r-- | tests/sexpr.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/sexpr.rs b/tests/sexpr.rs index 77ef3a0..a3783f0 100644 --- a/tests/sexpr.rs +++ b/tests/sexpr.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use mon::{ - Parser, ParserIter, alpha1, alphanumeric, alphanumeric1, input::InputIter, numeric1, tag, - whitespace, whitespace1, + Parser, ParserIter, ascii_alpha1, ascii_alphanumeric, ascii_alphanumeric1, ascii_numeric1, + ascii_whitespace1, input::InputIter, tag, }; #[derive(Debug)] @@ -14,20 +14,20 @@ enum Sexpr { } fn atom<'a>() -> impl Parser<&'a str, Output = Sexpr> { - alpha1() - .and(alphanumeric().repeated().many()) + ascii_alpha1() + .and(ascii_alphanumeric().repeated().many()) .recognize() .map(|output: &str| Sexpr::Atom(output.to_string())) } fn string<'a>() -> impl Parser<&'a str, Output = Sexpr> { - alphanumeric1() + ascii_alphanumeric1() .delimited_by(tag("\""), tag("\"")) .map(|output: &str| Sexpr::String(output.to_string())) } fn int<'a>() -> impl Parser<&'a str, Output = Sexpr> { - numeric1().map(|output: &str| Sexpr::Int(output.parse().unwrap())) + ascii_numeric1().map(|output: &str| Sexpr::Int(output.parse().unwrap())) } // Recursive parsers must avoid an infinite loop, you can do this @@ -35,7 +35,7 @@ fn int<'a>() -> impl Parser<&'a str, Output = Sexpr> { fn sexpr<'a>() -> impl Parser<&'a str, Output = Sexpr> { |it| { sexpr() - .separated_by(whitespace1()) + .separated_by(ascii_whitespace1()) .many() .delimited_by(tag("("), tag(")")) .map(|output| Sexpr::List(output)) |
