Implements spot::ltl::destroy() and exercise it.
* src/ltlast/atomic_prop.hh: Declare instance_count(). * src/ltlast/binop.hh, src/ltlast/unop.hh, src/ltlast/multop.hh: Likewise. Also, really inherit for ref_formula this time. * src/ltlast/atomic_prop.cc, src/ltlast/binop.cc, src/ltlast/unop.cc, src/ltlast/multop.cc: On destruction, suppress the instance from the instance map. Implement instance_count(). * src/ltlast/formula.cc, src/ltlast/formula.hh, src/ltlast/ref_formula.cc, src/ltlast/ref_formula.hh: Add virtual destructors. * src/ltlparse/ltlparse.yy: Recover from binary operators with missing right hand operand (the point is just to destroy the the left hand operand). * src/ltltest/equals.cc, src/ltltest/readltl.cc, src/ltltest/tostring.cc: Destroy used formulae. Make sure instance_count()s are null are the end. * src/ltltest/parseerr.test: Adjust expected result, now that the parser lnows about missing right hand operands. * src/ltlvisit/destroy.hh, src/ltlvisit/destroy.cc, src/ltlvisit/postfix.hh, src/ltlvisit/postfix.cc: New files. * src/ltlvisit/Makefile.am (libltlvisit_la_SOURCES): Add them. * src/ltlvisit/lunabbrev.cc (Xor, Equiv): Clone formulae occurring twice in the rewritten expression.
This commit is contained in:
parent
5f6d8b6234
commit
9123e56ff9
24 changed files with 382 additions and 24 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include <string>
|
||||
#include "public.hh"
|
||||
#include "ltlast/allnodes.hh"
|
||||
#include "ltlvisit/destroy.hh"
|
||||
|
||||
extern spot::ltl::formula* result;
|
||||
|
||||
|
|
@ -83,6 +84,9 @@ ltl_formula: subformula
|
|||
many_errors: error
|
||||
| many_errors error
|
||||
|
||||
/* The reason we use `constant::false_instance()' for error recovery
|
||||
is that it isn't reference counted. (Hence it can't leak references.) */
|
||||
|
||||
subformula: ATOMIC_PROP
|
||||
{
|
||||
$$ = parse_environment.require(*$1);
|
||||
|
|
@ -120,18 +124,67 @@ subformula: ATOMIC_PROP
|
|||
{ $$ = unop::instance(unop::Not, $2); }
|
||||
| subformula OP_AND subformula
|
||||
{ $$ = multop::instance(multop::And, $1, $3); }
|
||||
| subformula OP_AND error
|
||||
{
|
||||
destroy($1);
|
||||
error_list.push_back(parse_error(@2,
|
||||
"missing right operand for OP_AND"));
|
||||
$$ = constant::false_instance();
|
||||
}
|
||||
| subformula OP_OR subformula
|
||||
{ $$ = multop::instance(multop::Or, $1, $3); }
|
||||
| subformula OP_OR error
|
||||
{
|
||||
destroy($1);
|
||||
error_list.push_back(parse_error(@2,
|
||||
"missing right operand for OP_OR"));
|
||||
$$ = constant::false_instance();
|
||||
}
|
||||
| subformula OP_XOR subformula
|
||||
{ $$ = binop::instance(binop::Xor, $1, $3); }
|
||||
| subformula OP_XOR error
|
||||
{
|
||||
destroy($1);
|
||||
error_list.push_back(parse_error(@2,
|
||||
"missing right operand for OP_XOR"));
|
||||
$$ = constant::false_instance();
|
||||
}
|
||||
| subformula OP_IMPLIES subformula
|
||||
{ $$ = binop::instance(binop::Implies, $1, $3); }
|
||||
| subformula OP_IMPLIES error
|
||||
{
|
||||
destroy($1);
|
||||
error_list.push_back(parse_error(@2,
|
||||
"missing right operand for OP_IMPLIES"));
|
||||
$$ = constant::false_instance();
|
||||
}
|
||||
| subformula OP_EQUIV subformula
|
||||
{ $$ = binop::instance(binop::Equiv, $1, $3); }
|
||||
| subformula OP_EQUIV error
|
||||
{
|
||||
destroy($1);
|
||||
error_list.push_back(parse_error(@2,
|
||||
"missing right operand for OP_EQUIV"));
|
||||
$$ = constant::false_instance();
|
||||
}
|
||||
| subformula OP_U subformula
|
||||
{ $$ = binop::instance(binop::U, $1, $3); }
|
||||
| subformula OP_U error
|
||||
{
|
||||
destroy($1);
|
||||
error_list.push_back(parse_error(@2,
|
||||
"missing right operand for OP_U"));
|
||||
$$ = constant::false_instance();
|
||||
}
|
||||
| subformula OP_R subformula
|
||||
{ $$ = binop::instance(binop::R, $1, $3); }
|
||||
| subformula OP_R error
|
||||
{
|
||||
destroy($1);
|
||||
error_list.push_back(parse_error(@2,
|
||||
"missing right operand for OP_R"));
|
||||
$$ = constant::false_instance();
|
||||
}
|
||||
| OP_F subformula
|
||||
{ $$ = unop::instance(unop::F, $2); }
|
||||
| OP_G subformula
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue