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)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Expr {
|
pub enum Expr {
|
||||||
Atom(Atom),
|
Atom(Atom),
|
||||||
Conditional(Conditional),
|
|
||||||
AllOf(Vec<Expr>),
|
AllOf(Vec<Expr>),
|
||||||
AnyOf(Vec<Expr>),
|
AnyOf(Vec<Expr>),
|
||||||
OneOf(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 {
|
fn parser() -> Self::Parser {
|
||||||
|it| {
|
|it| {
|
||||||
let all_of = Expr::parser()
|
let all_of_group = Expr::parser()
|
||||||
.separated_list(whitespace1(), 1..)
|
.separated_list(whitespace1(), 1..)
|
||||||
.delimited_by(tag("(").followed_by(whitespace1()), tag(")"))
|
.delimited_by(tag("(").followed_by(whitespace1()), tag(")"))
|
||||||
.map(|exprs| Expr::AllOf(exprs));
|
.map(|exprs| Expr::AllOf(exprs));
|
||||||
|
|
||||||
let any_of = Expr::parser()
|
let any_of_group = Expr::parser()
|
||||||
.separated_list(whitespace1(), 1..)
|
.separated_list(whitespace1(), 1..)
|
||||||
.delimited_by(tag("(").followed_by(whitespace1()), tag(")"))
|
.delimited_by(tag("(").followed_by(whitespace1()), tag(")"))
|
||||||
.preceded_by(tag("||").followed_by(whitespace1()))
|
.preceded_by(tag("||").followed_by(whitespace1()))
|
||||||
.map(|exprs| Expr::AnyOf(exprs));
|
.map(|exprs| Expr::AnyOf(exprs));
|
||||||
|
|
||||||
let one_of = Expr::parser()
|
let one_of_group = Expr::parser()
|
||||||
.separated_list(whitespace1(), 1..)
|
.separated_list(whitespace1(), 1..)
|
||||||
.delimited_by(tag("(").followed_by(whitespace1()), tag(")"))
|
.delimited_by(tag("(").followed_by(whitespace1()), tag(")"))
|
||||||
.preceded_by(tag("^^").followed_by(whitespace1()))
|
.preceded_by(tag("^^").followed_by(whitespace1()))
|
||||||
.map(|exprs| Expr::OneOf(exprs));
|
.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()
|
Atom::parser()
|
||||||
.map(|atom| Expr::Atom(atom))
|
.map(|atom| Expr::Atom(atom))
|
||||||
.or(Conditional::parser().map(|conditional| Expr::Conditional(conditional)))
|
.or(conditional_group)
|
||||||
.or(any_of)
|
.or(any_of_group)
|
||||||
.or(all_of)
|
.or(all_of_group)
|
||||||
.or(one_of)
|
.or(one_of_group)
|
||||||
.parse(it)
|
.parse(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user