From 699d4bafd0fb1e2e7bf12e62a3c9673bc4bfa578 Mon Sep 17 00:00:00 2001 From: John Turner Date: Thu, 20 Nov 2025 23:27:41 +0000 Subject: [PATCH] update mon and use new ascii parsers --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/atom/parsers.rs | 36 ++++++++++++++++++++++++------------ src/ebuild/parsers.rs | 32 ++++++++++++++++++++------------ src/ebuild/repo/mod.rs | 12 ++++++------ src/useflag/parsers.rs | 9 ++++++--- 6 files changed, 58 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c11cdc..36e4e20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,7 +40,7 @@ dependencies = [ [[package]] name = "mon" version = "0.1.0" -source = "git+https://jturnerusa.dev/cgit/mon/?rev=438ade86160efc42ecab98322ceec8ef8d73aacf#438ade86160efc42ecab98322ceec8ef8d73aacf" +source = "git+https://jturnerusa.dev/cgit/mon/?rev=7fa1e34c22f4c5bfa99925560be9c23bb2d6d670#7fa1e34c22f4c5bfa99925560be9c23bb2d6d670" [[package]] name = "proc-macro2" diff --git a/Cargo.toml b/Cargo.toml index a92311c..2343f68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] -mon = { git = "https://jturnerusa.dev/cgit/mon/", rev = "438ade86160efc42ecab98322ceec8ef8d73aacf" } +mon = { git = "https://jturnerusa.dev/cgit/mon/", rev = "7fa1e34c22f4c5bfa99925560be9c23bb2d6d670" } get = { git = "https://jturnerusa.dev/cgit/get/", rev = "cd5f75b65777a855ab010c3137304ac05f2e56b8" } itertools = "0.14.0" thiserror = "2.0.17" diff --git a/src/atom/parsers.rs b/src/atom/parsers.rs index 7733f12..301409c 100644 --- a/src/atom/parsers.rs +++ b/src/atom/parsers.rs @@ -1,6 +1,9 @@ use core::option::Option::None; -use mon::{Parser, ParserIter, alphanumeric, eof, r#if, input::InputIter, numeric1, one_of, tag}; +use mon::{ + Parser, ParserIter, ascii_alphanumeric, ascii_numeric1, eof, r#if, input::InputIter, one_of, + tag, +}; use crate::{ Parseable, @@ -40,7 +43,7 @@ impl<'a> Parseable<'a, &'a str> for VersionNumber { type Parser = impl Parser<&'a str, Output = Self>; fn parser() -> Self::Parser { - numeric1().map(|output: &str| VersionNumber(output.to_string())) + ascii_numeric1().map(|output: &str| VersionNumber(output.to_string())) } } @@ -115,8 +118,11 @@ impl<'a> Parseable<'a, &'a str> for Category { type Parser = impl Parser<&'a str, Output = Self>; fn parser() -> Self::Parser { - let start = alphanumeric().or(one_of("_".chars())); - let rest = alphanumeric().or(one_of("+_.-".chars())).repeated().many(); + let start = ascii_alphanumeric().or(one_of("_".chars())); + let rest = ascii_alphanumeric() + .or(one_of("+_.-".chars())) + .repeated() + .many(); start .and(rest) @@ -129,19 +135,19 @@ impl<'a> Parseable<'a, &'a str> for Name { type Parser = impl Parser<&'a str, Output = Self>; fn parser() -> Self::Parser { - let start = || alphanumeric().or(one_of("_".chars())); + let start = || ascii_alphanumeric().or(one_of("_".chars())); - let rest = alphanumeric() + let rest = ascii_alphanumeric() .or(one_of("_+".chars())) .or(one_of("-".chars()).and_not( Version::parser() .preceded_by(tag("-")) - .followed_by(alphanumeric().or(one_of("_+-".chars())).not()), + .followed_by(ascii_alphanumeric().or(one_of("_+-".chars())).not()), )) .repeated() .many(); - let verify = alphanumeric() + let verify = ascii_alphanumeric() .or(one_of("_+".chars())) .or(one_of("-".chars()) .and_not(Version::parser().preceded_by(tag("-")).followed_by(eof()))) @@ -172,8 +178,11 @@ impl<'a> Parseable<'a, &'a str> for SlotName { type Parser = impl Parser<&'a str, Output = Self>; fn parser() -> Self::Parser { - let start = alphanumeric().or(one_of("_".chars())); - let rest = alphanumeric().or(one_of("+_.-".chars())).repeated().many(); + let start = ascii_alphanumeric().or(one_of("_".chars())); + let rest = ascii_alphanumeric() + .or(one_of("+_.-".chars())) + .repeated() + .many(); start .and(rest) @@ -215,8 +224,11 @@ impl<'a> Parseable<'a, &'a str> for Repo { type Parser = impl Parser<&'a str, Output = Self>; fn parser() -> Self::Parser { - let start = alphanumeric().or(one_of("_".chars())); - let rest = alphanumeric().or(one_of("+_-".chars())).repeated().many(); + let start = ascii_alphanumeric().or(one_of("_".chars())); + let rest = ascii_alphanumeric() + .or(one_of("+_-".chars())) + .repeated() + .many(); start .and(rest) diff --git a/src/ebuild/parsers.rs b/src/ebuild/parsers.rs index 73603a2..aa801e8 100644 --- a/src/ebuild/parsers.rs +++ b/src/ebuild/parsers.rs @@ -1,6 +1,8 @@ use std::path::PathBuf; -use mon::{Parser, ParserIter, alpha1, alphanumeric, r#if, one_of, tag, whitespace1}; +use mon::{ + Parser, ParserIter, ascii_alpha1, ascii_alphanumeric, ascii_whitespace1, r#if, one_of, tag, +}; use crate::{ Parseable, @@ -22,7 +24,7 @@ impl<'a> Parseable<'a, &'a str> for Uri { type Parser = impl Parser<&'a str, Output = Self>; fn parser() -> Self::Parser { - let protocol = alpha1::<&str>() + let protocol = ascii_alpha1::<&str>() .followed_by(tag("://")) .map(|output: &str| output.to_string()); let path = r#if(|c: &char| !c.is_ascii_whitespace()) @@ -67,8 +69,11 @@ impl<'a> Parseable<'a, &'a str> for License { type Parser = impl Parser<&'a str, Output = Self>; fn parser() -> Self::Parser { - let start = alphanumeric().or(one_of("_".chars())); - let rest = alphanumeric().or(one_of("+_.-".chars())).repeated().many(); + let start = ascii_alphanumeric().or(one_of("_".chars())); + let rest = ascii_alphanumeric() + .or(one_of("+_.-".chars())) + .repeated() + .many(); start .and(rest) @@ -81,8 +86,11 @@ impl<'a> Parseable<'a, &'a str> for Eapi { type Parser = impl Parser<&'a str, Output = Self>; fn parser() -> Self::Parser { - let start = alphanumeric().or(one_of("_".chars())); - let rest = alphanumeric().or(one_of("+_.-".chars())).repeated().many(); + let start = ascii_alphanumeric().or(one_of("_".chars())); + let rest = ascii_alphanumeric() + .or(one_of("+_.-".chars())) + .repeated() + .many(); start .and(rest) @@ -116,23 +124,23 @@ where |it| { let exprs = || { Depend::parser() - .separated_by_with_trailing(whitespace1()) + .separated_by_with_trailing(ascii_whitespace1()) .at_least(1) - .delimited_by(tag("(").followed_by(whitespace1()), tag(")")) + .delimited_by(tag("(").followed_by(ascii_whitespace1()), tag(")")) }; let all_of_group = exprs().map(|exprs| Depend::AllOf(exprs)); let any_of_group = exprs() - .preceded_by(tag("||").followed_by(whitespace1())) + .preceded_by(tag("||").followed_by(ascii_whitespace1())) .map(|exprs| Depend::AnyOf(exprs)); let one_of_group = exprs() - .preceded_by(tag("^^").followed_by(whitespace1())) + .preceded_by(tag("^^").followed_by(ascii_whitespace1())) .map(|exprs| Depend::OneOf(exprs)); let conditional_group = Conditional::parser() - .followed_by(whitespace1()) + .followed_by(ascii_whitespace1()) .and(exprs()) .map(|(conditional, exprs)| Depend::ConditionalGroup(conditional, exprs)); @@ -189,7 +197,7 @@ mod test { let it = InputIter::new("flag? ( || ( foo/bar foo/bar ) )"); Depend::::parser() - .separated_by(whitespace1()) + .separated_by(ascii_whitespace1()) .many() .check_finished(it) .unwrap(); diff --git a/src/ebuild/repo/mod.rs b/src/ebuild/repo/mod.rs index abf9569..ae2113c 100644 --- a/src/ebuild/repo/mod.rs +++ b/src/ebuild/repo/mod.rs @@ -5,7 +5,7 @@ use std::{ use get::Get; -use mon::{Parser, ParserIter, input::InputIter, tag, whitespace1}; +use mon::{Parser, ParserIter, ascii_whitespace1, input::InputIter, tag}; use crate::{ Parseable, @@ -208,7 +208,7 @@ fn read_src_uri(input: &str) -> Option>, Error>> { .find_map(|line| line.strip_prefix("SRC_URI="))?; match Depend::::parser() - .separated_by(whitespace1()) + .separated_by(ascii_whitespace1()) .many() .parse_finished(InputIter::new(line)) { @@ -232,7 +232,7 @@ fn read_inherit(input: &str) -> Option, Error>> { .find_map(|line| line.strip_prefix("INHERIT="))?; match Eclass::parser() - .separated_by(whitespace1()) + .separated_by(ascii_whitespace1()) .many() .parse_finished(InputIter::new(line)) { @@ -245,7 +245,7 @@ fn read_iuse(input: &str) -> Option, Error>> { let line = input.lines().find_map(|line| line.strip_prefix("IUSE="))?; match IUseFlag::parser() - .separated_by(whitespace1()) + .separated_by(ascii_whitespace1()) .many() .parse_finished(InputIter::new(line)) { @@ -260,7 +260,7 @@ fn read_license(input: &str) -> Option>, Error>> { .find_map(|line| line.strip_suffix("LICENSE="))?; match Depend::::parser() - .separated_by(whitespace1()) + .separated_by(ascii_whitespace1()) .many() .parse_finished(InputIter::new(line)) { @@ -309,7 +309,7 @@ fn read_idepend(input: &str) -> Option>, Error>> { fn parse_depends(line: &str) -> Result>, Error> { Depend::::parser() - .separated_by(whitespace1()) + .separated_by(ascii_whitespace1()) .many() .parse_finished(InputIter::new(line)) .map_err(|_| Error::Parser(line.to_string())) diff --git a/src/useflag/parsers.rs b/src/useflag/parsers.rs index fc371a6..ca5929d 100644 --- a/src/useflag/parsers.rs +++ b/src/useflag/parsers.rs @@ -1,4 +1,4 @@ -use mon::{Parser, ParserIter, alphanumeric, one_of, tag}; +use mon::{Parser, ParserIter, ascii_alphanumeric, one_of, tag}; use crate::{ Parseable, @@ -9,8 +9,11 @@ impl<'a> Parseable<'a, &'a str> for UseFlag { type Parser = impl Parser<&'a str, Output = Self>; fn parser() -> Self::Parser { - let start = alphanumeric(); - let rest = alphanumeric().or(one_of("+_@-".chars())).repeated().many(); + let start = ascii_alphanumeric(); + let rest = ascii_alphanumeric() + .or(one_of("+_@-".chars())) + .repeated() + .many(); start .and(rest)