update parsers to use the ParserIter trait from mon

This commit is contained in:
2025-11-01 17:28:19 +00:00
parent 6b04125d14
commit a38b01cd04
5 changed files with 53 additions and 28 deletions

View File

@@ -5,7 +5,7 @@ use std::{
use get::Get;
use mon::{Parser, input::InputIter, tag, whitespace1};
use mon::{Parser, ParserIter, input::InputIter, tag, whitespace1};
use crate::{
Parseable,
@@ -200,7 +200,8 @@ fn read_src_uri(input: &str) -> Option<Result<Vec<Depend<SrcUri>>, Error>> {
.find_map(|line| line.strip_prefix("SRC_URI="))?;
match Depend::<SrcUri>::parser()
.separated_by(whitespace1(), 0..)
.separated_by(whitespace1())
.many()
.parse_finished(InputIter::new(line))
{
Ok(slot) => Some(Ok(slot)),
@@ -223,7 +224,8 @@ fn read_inherit(input: &str) -> Option<Result<Vec<Eclass>, Error>> {
.find_map(|line| line.strip_prefix("INHERIT="))?;
match Eclass::parser()
.separated_by(whitespace1(), 0..)
.separated_by(whitespace1())
.many()
.parse_finished(InputIter::new(line))
{
Ok(inherit) => Some(Ok(inherit)),
@@ -235,7 +237,8 @@ fn read_iuse(input: &str) -> Option<Result<Vec<IUseFlag>, Error>> {
let line = input.lines().find_map(|line| line.strip_prefix("IUSE="))?;
match IUseFlag::parser()
.separated_by(whitespace1(), 0..)
.separated_by(whitespace1())
.many()
.parse_finished(InputIter::new(line))
{
Ok(iuse) => Some(Ok(iuse)),
@@ -249,7 +252,8 @@ fn read_license(input: &str) -> Option<Result<Vec<Depend<License>>, Error>> {
.find_map(|line| line.strip_suffix("LICENSE="))?;
match Depend::<License>::parser()
.separated_by(whitespace1(), 0..)
.separated_by(whitespace1())
.many()
.parse_finished(InputIter::new(line))
{
Ok(license) => Some(Ok(license)),
@@ -297,7 +301,8 @@ fn read_idepend(input: &str) -> Option<Result<Vec<Depend<Atom>>, Error>> {
fn parse_depends(line: &str) -> Result<Vec<Depend<Atom>>, Error> {
Depend::<Atom>::parser()
.separated_by(whitespace1(), 0..)
.separated_by(whitespace1())
.many()
.parse_finished(InputIter::new(line))
.map_err(|_| Error::Parser(line.to_string()))
}