impl profile evaluation

This commit is contained in:
John Turner
2025-11-29 20:43:28 +00:00
parent 94f3397d19
commit d1127df296
16 changed files with 1365 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
use mon::{Parser, ParserIter, ascii_whitespace, ascii_whitespace1, tag};
use crate::{
Parseable,
atom::Atom,
repo::profile::{FlagOperation, package_use::Expr},
};
impl<'a> Parseable<'a, &'a str> for Expr {
type Parser = impl Parser<&'a str, Output = Self>;
fn parser() -> Self::Parser {
Atom::parser()
.followed_by(ascii_whitespace1())
.and(
FlagOperation::parser()
.separated_by(ascii_whitespace().and_not(tag("\n")).repeated().at_least(1))
.at_least(1),
)
.map(|(atom, operations)| Expr(atom, operations))
}
}
#[cfg(test)]
mod test {
use mon::input::InputIter;
use super::*;
#[test]
fn test_parse_expr() {
let it = InputIter::new("foo/bar a -b");
Expr::parser().check_finished(it).unwrap();
}
}