Skip to content

Commit c3a550a

Browse files
committed
Parse boolean literals in annotation
1 parent e0e13f3 commit c3a550a

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/annot.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ enum FormulaOrTerm<T> {
196196
Term(chc::Term<T>, chc::Sort),
197197
BinOp(chc::Term<T>, AmbiguousBinOp, chc::Term<T>),
198198
Not(Box<FormulaOrTerm<T>>),
199+
Literal(bool),
199200
}
200201

201202
impl<T> FormulaOrTerm<T> {
@@ -215,6 +216,13 @@ impl<T> FormulaOrTerm<T> {
215216
chc::Formula::Atom(chc::Atom::new(pred.into(), vec![lhs, rhs]))
216217
}
217218
FormulaOrTerm::Not(formula_or_term) => formula_or_term.into_formula()?.not(),
219+
FormulaOrTerm::Literal(b) => {
220+
if b {
221+
chc::Formula::top()
222+
} else {
223+
chc::Formula::bottom()
224+
}
225+
}
218226
};
219227
Some(fo)
220228
}
@@ -233,6 +241,7 @@ impl<T> FormulaOrTerm<T> {
233241
let (t, _) = formula_or_term.into_term()?;
234242
(t.not(), chc::Sort::bool())
235243
}
244+
FormulaOrTerm::Literal(b) => (chc::Term::bool(b), chc::Sort::bool()),
236245
};
237246
Some((t, s))
238247
}
@@ -461,8 +470,8 @@ where
461470
ident.as_str(),
462471
self.formula_existentials.get(ident.name.as_str()),
463472
) {
464-
("true", _) => FormulaOrTerm::Formula(chc::Formula::top()),
465-
("false", _) => FormulaOrTerm::Formula(chc::Formula::bottom()),
473+
("true", _) => FormulaOrTerm::Literal(true),
474+
("false", _) => FormulaOrTerm::Literal(false),
466475
(_, Some(sort)) => {
467476
let var =
468477
chc::Term::FormulaExistentialVar(sort.clone(), ident.name.to_string());

0 commit comments

Comments
 (0)