forked from gentoo-utils/gentoo-utils
change depend::Expr::Conditional to ConditionalGroup
This commit is contained in:
@@ -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>),
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user