diff --git a/generate/src/parser.rs b/generate/src/parser.rs index 164991f..7d46257 100644 --- a/generate/src/parser.rs +++ b/generate/src/parser.rs @@ -358,10 +358,10 @@ mod label { Atom::Var(a_name) => { match b { Atom::Var(b_name) => { - super::super::Predicate::LTnVar(a_name, b_name) + super::super::Predicate::LTnVar(a_name, b_name, None) } Atom::Const(val) => { - super::super::Predicate::LTnConst(a_name, val) + super::super::Predicate::LTnConst(a_name, val, None) } } } @@ -375,10 +375,10 @@ mod label { Atom::Var(a_name) => { match b { Atom::Var(b_name) => { - super::super::Predicate::GTnVar(a_name, b_name) + super::super::Predicate::GTnVar(a_name, b_name, None) } Atom::Const(val) => { - super::super::Predicate::GTnConst(a_name, val) + super::super::Predicate::GTnConst(a_name, val, None) } } } @@ -392,10 +392,10 @@ mod label { Atom::Var(a_name) => { match b { Atom::Var(b_name) => { - super::super::Predicate::EqualVar(a_name, b_name) + super::super::Predicate::EqualVar(a_name, b_name, None) } Atom::Const(val) => { - super::super::Predicate::EqualConst(a_name, val) + super::super::Predicate::EqualConst(a_name, val, None) } } } diff --git a/generate/src/template.rs b/generate/src/template.rs index a58de98..b90bbc2 100644 --- a/generate/src/template.rs +++ b/generate/src/template.rs @@ -12,35 +12,53 @@ pub(crate) struct Route(pub usize); #[derive(Clone, Debug)] pub(crate) enum Predicate { - LTnVar(String, String), - LTnConst(String, String), - GTnVar(String, String), - GTnConst(String, String), - EqualVar(String, String), - EqualConst(String, String), + LTnVar(String, String, Option), + LTnConst(String, String, Option), + GTnVar(String, String, Option), + GTnConst(String, String, Option), + EqualVar(String, String, Option), + EqualConst(String, String, Option), Tautology(Option), } impl Display for Predicate { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { - Predicate::LTnVar(param, value) => { - write!(f, "LTnVar::", param, value) + Predicate::LTnVar(param, value, label) => { + match label { + None => write!(f, "LTnVar::", param, value), + Some(l) => write!(f, "LTnVar::", l, param, value), + } } - Predicate::LTnConst(param, value) => { - write!(f, "LTnConst::", param, value) + Predicate::LTnConst(param, value, label) => { + match label { + None => write!(f, "LTnConst::", param, value), + Some(l) => write!(f, "LTnConst::<{}, '{}', {}>", l, param, value), + } } - Predicate::GTnVar(param, value) => { - write!(f, "GTnVar::", param, value) + Predicate::GTnVar(param, value, label) => { + match label { + None => write!(f, "GTnVar::", param, value), + Some(l) => write!(f, "GTnVar::", l, param, value), + } } - Predicate::GTnConst(param, value) => { - write!(f, "GTnConst::", param, value) + Predicate::GTnConst(param, value, label) => { + match label { + None => write!(f, "GTnConst::", param, value), + Some(l) => write!(f, "GTnConst::<{}, '{}', {}>", l, param, value), + } } - Predicate::EqualVar(param, value) => { - write!(f, "EqualVar::", param, value) + Predicate::EqualVar(param, value, label) => { + match label { + None => write!(f, "EqualVar::", param, value), + Some(l) => write!(f, "EqualVar::", l, param, value), + } } - Predicate::EqualConst(param, value) => { - write!(f, "EqualConst::", param, value) + Predicate::EqualConst(param, value, label) => { + match label { + None => write!(f, "EqualConst::", param, value), + Some(l) => write!(f, "EqualConst::<{}, '{}', {}>", l, param, value), + } } Predicate::Tautology(label) => { match label { @@ -55,10 +73,15 @@ impl Display for Predicate { impl Predicate { fn set_label_str(&mut self, label: String) { match self { + Predicate::LTnVar(_, _, opt) | + Predicate::LTnConst(_, _, opt) | + Predicate::GTnVar(_, _, opt) | + Predicate::GTnConst(_, _, opt) | + Predicate::EqualVar(_, _, opt) | + Predicate::EqualConst(_, _, opt) | Predicate::Tautology(opt) => { opt.insert(label); }, - _ => {} } } }