diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-11-01 17:28:19 +0000 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-11-01 17:28:19 +0000 |
| commit | a38b01cd0494570cb067acd06fdadce9a6ef0ef0 (patch) | |
| tree | 239726881c83797fff92c5954546d873e4e91e2c /src/ebuild/parsers.rs | |
| parent | 6b04125d14503790e6ab388e11f1f9ebe7e7faea (diff) | |
| download | gentoo-utils-a38b01cd0494570cb067acd06fdadce9a6ef0ef0.tar.gz | |
update parsers to use the ParserIter trait from mon
Diffstat (limited to 'src/ebuild/parsers.rs')
| -rw-r--r-- | src/ebuild/parsers.rs | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/ebuild/parsers.rs b/src/ebuild/parsers.rs index 56b86ba..f685df3 100644 --- a/src/ebuild/parsers.rs +++ b/src/ebuild/parsers.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use mon::{Parser, alpha1, r#if, tag, whitespace1}; +use mon::{Parser, ParserIter, alpha1, r#if, tag, whitespace1}; use crate::{ Parseable, @@ -26,7 +26,8 @@ impl<'a> Parseable<'a, &'a str> for Uri { .followed_by(tag("://")) .map(|output: &str| output.to_string()); let path = r#if(|c: &char| !c.is_ascii_whitespace()) - .repeated(1..) + .repeated() + .at_least(1) .recognize() .map(|output: &str| output.to_string()); @@ -42,7 +43,8 @@ impl<'a> Parseable<'a, &'a str> for SrcUri { fn parser() -> Self::Parser { let filename = || { r#if(|c: &char| !c.is_ascii_whitespace()) - .repeated(1..) + .repeated() + .at_least(1) .recognize() .map(|output: &str| PathBuf::from(output)) }; @@ -65,7 +67,9 @@ impl<'a> Parseable<'a, &'a str> for License { fn parser() -> Self::Parser { let start = r#if(|c: &char| c.is_ascii_alphanumeric() || "_".contains(*c)); - let rest = r#if(|c: &char| c.is_ascii_alphanumeric() || "+_.-".contains(*c)).repeated(0..); + let rest = r#if(|c: &char| c.is_ascii_alphanumeric() || "+_.-".contains(*c)) + .repeated() + .many(); start .and(rest) @@ -79,7 +83,9 @@ impl<'a> Parseable<'a, &'a str> for Eapi { fn parser() -> Self::Parser { let start = r#if(|c: &char| c.is_ascii_alphanumeric() || "_".contains(*c)); - let rest = r#if(|c: &char| c.is_ascii_alphanumeric() || "+_.-".contains(*c)).repeated(0..); + let rest = r#if(|c: &char| c.is_ascii_alphanumeric() || "+_.-".contains(*c)) + .repeated() + .many(); start .and(rest) @@ -96,7 +102,8 @@ impl<'a> Parseable<'a, &'a str> for Eclass { fn parser() -> Self::Parser { r#if(|c: &char| !c.is_ascii_whitespace()) - .repeated(1..) + .repeated() + .at_least(1) .recognize() .map(|output: &str| Eclass(output.to_string())) } @@ -111,18 +118,21 @@ where fn parser() -> Self::Parser { |it| { let all_of_group = Depend::parser() - .separated_by(whitespace1(), 1..) + .separated_by(whitespace1()) + .at_least(1) .delimited_by(tag("(").followed_by(whitespace1()), tag(")")) .map(|exprs| Depend::AllOf(exprs)); let any_of_group = Depend::parser() - .separated_by(whitespace1(), 1..) + .separated_by(whitespace1()) + .at_least(1) .delimited_by(tag("(").followed_by(whitespace1()), tag(")")) .preceded_by(tag("||").followed_by(whitespace1())) .map(|exprs| Depend::AnyOf(exprs)); let one_of_group = Depend::parser() - .separated_by(whitespace1(), 1..) + .separated_by(whitespace1()) + .at_least(1) .delimited_by(tag("(").followed_by(whitespace1()), tag(")")) .preceded_by(tag("^^").followed_by(whitespace1())) .map(|exprs| Depend::OneOf(exprs)); @@ -131,7 +141,8 @@ where .followed_by(whitespace1()) .and( Depend::parser() - .separated_by(whitespace1(), 1..) + .separated_by(whitespace1()) + .at_least(1) .delimited_by(tag("(").followed_by(whitespace1()), tag(")")), ) .map(|(conditional, exprs)| Depend::ConditionalGroup(conditional, exprs)); @@ -164,7 +175,7 @@ impl<'a> Parseable<'a, &'a str> for Conditional { #[cfg(test)] mod test { - use mon::input::InputIter; + use mon::{ParserIter, input::InputIter}; use crate::{atom::Atom, ebuild::Depend}; @@ -189,7 +200,8 @@ mod test { let it = InputIter::new("flag? ( || ( foo/bar foo/bar ) )"); Depend::<Atom>::parser() - .separated_by(whitespace1(), 0..) + .separated_by(whitespace1()) + .many() .check_finished(it) .unwrap(); } |
