diff --git a/src/depend/mod.rs b/src/depend/mod.rs index ffa7836..9a7fb71 100644 --- a/src/depend/mod.rs +++ b/src/depend/mod.rs @@ -11,8 +11,8 @@ pub enum Conditional { #[derive(Clone, Debug)] pub enum Expr { Atom(Atom), - Conditional(Conditional), AllOf(Vec), AnyOf(Vec), OneOf(Vec), + ConditionalGroup(Conditional, Vec), } diff --git a/src/depend/parsers.rs b/src/depend/parsers.rs index 7a69fee..26139ea 100644 --- a/src/depend/parsers.rs +++ b/src/depend/parsers.rs @@ -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) } }