Commit eec66e6d authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

* src/ltlast/multop.cc (multop::multop): Use multop::add.

(multop::add): If the formulae we add is itself a multop for the
same operator, merge its children with ours.
* src/ltltest/parseerr.test: Add two tests for multop merging.
parent 2fd7b742
2003-04-16 Alexandre DURET-LUTZ <aduret@circe.lip6.fr>
* src/ltlast/multop.cc (multop::multop): Use multop::add.
(multop::add): If the formulae we add is itself a multop for the
same operator, merge its children with ours.
* src/ltltest/parseerr.test: Add two tests for multop merging.
2003-04-15 Alexandre DURET-LUTZ <aduret@src.lip6.fr> 2003-04-15 Alexandre DURET-LUTZ <aduret@src.lip6.fr>
* src/ltlast/formulae.hh (formulae::equals): Remove. * src/ltlast/formulae.hh (formulae::equals): Remove.
......
...@@ -8,16 +8,31 @@ namespace spot ...@@ -8,16 +8,31 @@ namespace spot
namespace ltl namespace ltl
{ {
multop::multop(type op, formulae* first, formulae* second) multop::multop(type op, formulae* first, formulae* second)
: op_(op), children_(2) : op_(op)
{ {
children_[0] = first; children_.reserve(2);
children_[1] = second; add(first);
add(second);
} }
void void
multop::add(formulae* f) multop::add(formulae* f)
{ {
children_.push_back(f); // If the formulae we add is itself a multop for the same operator,
// merge its children with ours.
multop* p = dynamic_cast<multop*>(f);
if (p && p->op() == op())
{
unsigned ps = p->size();
for (unsigned i = 0; i < ps; ++i)
children_.push_back(p->nth(i));
// that sub-formulae is now useless
delete f;
}
else
{
children_.push_back(f);
}
} }
multop::~multop() multop::~multop()
......
...@@ -39,6 +39,9 @@ check 'a U b V c R' '' ...@@ -39,6 +39,9 @@ check 'a U b V c R' ''
# leading and trailing garbage are skipped # leading and trailing garbage are skipped
check '/2/3/4/5 a + b /6/7/8/' 'multop(Or, AP(a), AP(b))' check '/2/3/4/5 a + b /6/7/8/' 'multop(Or, AP(a), AP(b))'
check 'a U b c' 'binop(U, AP(a), AP(b))' check 'a U b c' 'binop(U, AP(a), AP(b))'
# (check multop merging while we are at it)
check 'a & b & c & d e' 'multop(And, AP(a), AP(b), AP(c), AP(d))'
check 'a & (b | c) & d should work' 'multop(And, AP(a), multop(Or, AP(b), AP(c)), AP(d))'
# Recovery inside parentheses # Recovery inside parentheses
check 'a U (b c) U e R (f g <=> h)' \ check 'a U (b c) U e R (f g <=> h)' \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment