Skip to content

Commit

Permalink
Adapt generated Label of refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Vassor committed Apr 22, 2024
1 parent 6a41819 commit ced6955
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 25 deletions.
12 changes: 6 additions & 6 deletions generate/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand All @@ -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)
}
}
}
Expand All @@ -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)
}
}
}
Expand Down
61 changes: 42 additions & 19 deletions generate/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>),
LTnConst(String, String, Option<String>),
GTnVar(String, String, Option<String>),
GTnConst(String, String, Option<String>),
EqualVar(String, String, Option<String>),
EqualConst(String, String, Option<String>),
Tautology(Option<String>),
}

impl Display for Predicate {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Predicate::LTnVar(param, value) => {
write!(f, "LTnVar::<Value, Label, '{}', '{}'>", param, value)
Predicate::LTnVar(param, value, label) => {
match label {
None => write!(f, "LTnVar::<Value, Label, '{}', '{}'>", param, value),
Some(l) => write!(f, "LTnVar::<Value, {}, '{}', '{}'>", l, param, value),
}
}
Predicate::LTnConst(param, value) => {
write!(f, "LTnConst::<Label, '{}', {}>", param, value)
Predicate::LTnConst(param, value, label) => {
match label {
None => write!(f, "LTnConst::<Label, '{}', {}>", param, value),
Some(l) => write!(f, "LTnConst::<{}, '{}', {}>", l, param, value),
}
}
Predicate::GTnVar(param, value) => {
write!(f, "GTnVar::<Value, Label, '{}', '{}'>", param, value)
Predicate::GTnVar(param, value, label) => {
match label {
None => write!(f, "GTnVar::<Value, Label, '{}', '{}'>", param, value),
Some(l) => write!(f, "GTnVar::<Value, {}, '{}', '{}'>", l, param, value),
}
}
Predicate::GTnConst(param, value) => {
write!(f, "GTnConst::<Label, '{}', {}>", param, value)
Predicate::GTnConst(param, value, label) => {
match label {
None => write!(f, "GTnConst::<Label, '{}', {}>", param, value),
Some(l) => write!(f, "GTnConst::<{}, '{}', {}>", l, param, value),
}
}
Predicate::EqualVar(param, value) => {
write!(f, "EqualVar::<Value, Label, '{}', '{}'>", param, value)
Predicate::EqualVar(param, value, label) => {
match label {
None => write!(f, "EqualVar::<Value, Label, '{}', '{}'>", param, value),
Some(l) => write!(f, "EqualVar::<Value, {}, '{}', '{}'>", l, param, value),
}
}
Predicate::EqualConst(param, value) => {
write!(f, "EqualConst::<Label, '{}', {}>", param, value)
Predicate::EqualConst(param, value, label) => {
match label {
None => write!(f, "EqualConst::<Label, '{}', {}>", param, value),
Some(l) => write!(f, "EqualConst::<{}, '{}', {}>", l, param, value),
}
}
Predicate::Tautology(label) => {
match label {
Expand All @@ -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);
},
_ => {}
}
}
}
Expand Down

0 comments on commit ced6955

Please sign in to comment.