use super::aggregate::AggregateBody;
use super::atom::Atom;
use super::bind::BindExpr;
use super::filter::BuiltinFilter;
use super::symbols::VariableSymbol;
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum Literal {
Positive(Atom),
Negative(Atom),
Filter(BuiltinFilter),
Bind {
var: VariableSymbol,
expr: BindExpr,
},
Aggregate(AggregateBody),
}
impl Literal {
#[must_use]
pub fn atom(&self) -> Option<&Atom> {
match self {
Self::Positive(atom) | Self::Negative(atom) => Some(atom),
Self::Filter(_) | Self::Bind { .. } | Self::Aggregate(_) => None,
}
}
#[must_use]
pub fn is_positive(&self) -> bool {
matches!(self, Self::Positive(_))
}
#[must_use]
pub fn is_negative(&self) -> bool {
matches!(self, Self::Negative(_))
}
#[must_use]
pub fn is_filter(&self) -> bool {
matches!(self, Self::Filter(_))
}
#[must_use]
pub fn is_bind(&self) -> bool {
matches!(self, Self::Bind { .. })
}
#[must_use]
pub fn is_aggregate(&self) -> bool {
matches!(self, Self::Aggregate(_))
}
}