change depend::Expr::Conditional to ConditionalGroup

This commit is contained in:
John Turner
2025-10-28 12:26:30 +00:00
parent b54616a6dd
commit 024b3df691
2 changed files with 14 additions and 8 deletions

View File

@@ -11,8 +11,8 @@ pub enum Conditional {
#[derive(Clone, Debug)]
pub enum Expr {
Atom(Atom),
Conditional(Conditional),
AllOf(Vec<Expr>),
AnyOf(Vec<Expr>),
OneOf(Vec<Expr>),
ConditionalGroup(Conditional, Vec<Expr>),
}

View File

@@ -12,29 +12,35 @@ impl<'a> Parseable<'a, &'a str> for Expr {
fn parser() -> Self::Parser {
|it| {
let all_of = Expr::parser()
let all_of_group = Expr::parser()
.separated_list(whitespace1(), 1..)
.delimited_by(tag("(").followed_by(whitespace1()), tag(")"))
.map(|exprs| Expr::AllOf(exprs));
let any_of = Expr::parser()
let any_of_group = Expr::parser()
.separated_list(whitespace1(), 1..)
.delimited_by(tag("(").followed_by(whitespace1()), tag(")"))
.preceded_by(tag("||").followed_by(whitespace1()))
.map(|exprs| Expr::AnyOf(exprs));
let one_of = Expr::parser()
let one_of_group = Expr::parser()
.separated_list(whitespace1(), 1..)
.delimited_by(tag("(").followed_by(whitespace1()), tag(")"))
.preceded_by(tag("^^").followed_by(whitespace1()))
.map(|exprs| Expr::OneOf(exprs));
let conditional_group = Expr::parser()
.separated_list(whitespace1(), 1..)
.delimited_by(tag("(").followed_by(whitespace1()), tag(")"))
.preceded_by(Conditional::parser().followed_by(whitespace1()))
.map(|exprs| Expr::OneOf(exprs));
Atom::parser()
.map(|atom| Expr::Atom(atom))
.or(Conditional::parser().map(|conditional| Expr::Conditional(conditional)))
.or(any_of)
.or(all_of)
.or(one_of)
.or(conditional_group)
.or(any_of_group)
.or(all_of_group)
.or(one_of_group)
.parse(it)
}
}