* ltltest/inf.cc, ltltest/reduc.cc, ltlvisit/reducform.cc: Fix style.

* sanity/style.test: More tests.
This commit is contained in:
Alexandre Duret-Lutz 2004-05-14 14:09:01 +00:00
parent aa5368baf9
commit f2f10852c6
5 changed files with 292 additions and 261 deletions

View file

@ -1,5 +1,8 @@
2004-05-14 Alexandre Duret-Lutz <adl@src.lip6.fr> 2004-05-14 Alexandre Duret-Lutz <adl@src.lip6.fr>
* ltltest/inf.cc, ltltest/reduc.cc, ltlvisit/reducform.cc: Fix style.
* sanity/style.test: More tests.
* src/tgbatest/ltl2tgba.cc (main): Fix style. * src/tgbatest/ltl2tgba.cc (main): Fix style.
* HACKING: Mention `else if'. * HACKING: Mention `else if'.

View file

@ -64,20 +64,23 @@ main(int argc, char** argv)
int exit_return = 0; int exit_return = 0;
std::cout << "Test f1 < f2" << std::endl; std::cout << "Test f1 < f2" << std::endl;
if (spot::ltl::inf_form(f1,f2)) { if (spot::ltl::inf_form(f1, f2))
{
std::cout << f1s << " < " << f2s << std::endl; std::cout << f1s << " < " << f2s << std::endl;
exit_return = 1; exit_return = 1;
} }
/* /*
std::cout << "Test !f1 < f2" << std::endl; std::cout << "Test !f1 < f2" << std::endl;
if (spot::ltl::infneg_form(f1,f2,0)) { if (spot::ltl::infneg_form(f1, f2, 0))
{
std::cout << "!(" << f1s << ") < " << f2s << std::endl; std::cout << "!(" << f1s << ") < " << f2s << std::endl;
exit_return = 2; exit_return = 2;
} }
std::cout << "Test f1 < !f2" << std::endl; std::cout << "Test f1 < !f2" << std::endl;
if (spot::ltl::infneg_form(f1,f2,1)) { if (spot::ltl::infneg_form(f1, f2, 1))
{
std::cout << f1s << " < !(" << f2s << ")" << std::endl; std::cout << f1s << " < !(" << f2s << ")" << std::endl;
exit_return = 3; exit_return = 3;
} }

View file

@ -45,7 +45,8 @@ main(int argc, char** argv)
syntax(argv[0]); syntax(argv[0]);
spot::ltl::option o; spot::ltl::option o;
switch(atoi(argv[1])){ switch (atoi(argv[1]))
{
case 0: case 0:
o = spot::ltl::Base; o = spot::ltl::Base;
break; break;
@ -58,7 +59,8 @@ main(int argc, char** argv)
case 3: case 3:
o = spot::ltl::BRI; o = spot::ltl::BRI;
break; break;
default: return 2; default:
return 2;
} }
spot::ltl::parse_error_list p1; spot::ltl::parse_error_list p1;
@ -69,7 +71,8 @@ main(int argc, char** argv)
return 2; return 2;
if (argc == 4){ if (argc == 4)
{
spot::ltl::parse_error_list p2; spot::ltl::parse_error_list p2;
f2 = spot::ltl::parse(argv[3], p2); f2 = spot::ltl::parse(argv[3], p2);
if (spot::ltl::format_parse_errors(std::cerr, argv[3], p2)) if (spot::ltl::format_parse_errors(std::cerr, argv[3], p2))
@ -103,9 +106,9 @@ main(int argc, char** argv)
std::string f1s_after = spot::ltl::to_string(f1); std::string f1s_after = spot::ltl::to_string(f1);
bool red = (length_f1_after < length_f1_before); bool red = (length_f1_after < length_f1_before);
if (red);
std::string f2s = ""; std::string f2s = "";
if (f2 != NULL) { if (f2 != NULL)
{
ftmp1 = f2; ftmp1 = f2;
f2 = unabbreviate_logic(f2); f2 = unabbreviate_logic(f2);
ftmp2 = f2; ftmp2 = f2;
@ -118,15 +121,17 @@ main(int argc, char** argv)
f2s = spot::ltl::to_string(f2); f2s = spot::ltl::to_string(f2);
} }
if (red && !f2)
if (red && (f2 == NULL)) { {
std::cout << length_f1_before << " " << length_f1_after std::cout << length_f1_before << " " << length_f1_after
<< " '" << f1s_before << "' reduce to '" << f1s_after << "'" << " '" << f1s_before << "' reduce to '" << f1s_after << "'"
<< std::endl; << std::endl;
} }
if (f2 != NULL){ if (f2)
if (f1 != f2) { {
if (f1 != f2)
{
if (length_f1_after < length_f1_before) if (length_f1_after < length_f1_before)
std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after
<< " KOREDUC " << std::endl; << " KOREDUC " << std::endl;
@ -135,7 +140,8 @@ main(int argc, char** argv)
<< " KOIDEM " << std::endl; << " KOIDEM " << std::endl;
exit_code = 1; exit_code = 1;
} }
else { else
{
if (f1s_before != f1s_after) if (f1s_before != f1s_after)
std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after
<< " OKREDUC " << std::endl; << " OKREDUC " << std::endl;
@ -145,8 +151,10 @@ main(int argc, char** argv)
exit_code = 0; exit_code = 0;
} }
} }
else{ else
if (length_f1_after < length_f1_before) exit_code = 0; {
if (length_f1_after < length_f1_before)
exit_code = 0;
} }
spot::ltl::destroy(f1); spot::ltl::destroy(f1);

View file

@ -90,17 +90,15 @@ namespace spot
return; return;
case unop::F: case unop::F:
/* if f is class of eventuality then F(f)=f */ /* If f is class of eventuality then F(f)=f. */
if (!is_eventual(result_) || (o == Inf)) { if (!is_eventual(result_) || (o == Inf))
result_ = unop::instance(unop::F, result_); result_ = unop::instance(unop::F, result_);
}
return; return;
case unop::G: case unop::G:
/* if f is class of universality then G(f)=f */ /* If f is class of universality then G(f)=f. */
if (!is_universal(result_) || (o == Inf)) { if (!is_universal(result_) || (o == Inf))
result_ = unop::instance(unop::G, result_); result_ = unop::instance(unop::G, result_);
}
return; return;
} }
/* Unreachable code. */ /* Unreachable code. */
@ -112,20 +110,20 @@ namespace spot
{ {
formula* f2 = recurse(bo->second()); formula* f2 = recurse(bo->second());
/* if b is of class eventuality then a U b = b /* If b is of class eventuality then a U b = b.
if b is of class universality then a R b = b */ If b is of class universality then a R b = b. */
if (o != Inf) { if ((o != Inf)
if ((is_eventual(f2) && ((bo->op()) == binop::U)) || && ((is_eventual(f2) && ((bo->op()) == binop::U))
(is_universal(f2) && ((bo->op()) == binop::R))) || (is_universal(f2) && ((bo->op()) == binop::R))))
{ {
result_ = f2; result_ = f2;
return; return;
} }
}
/* case of implies */ /* case of implies */
formula* f1 = recurse(bo->first()); formula* f1 = recurse(bo->first());
if (o != EventualUniversal) { if (o != EventualUniversal)
{
bool inf = inf_form(f1, f2); bool inf = inf_form(f1, f2);
bool infinv = inf_form(f2, f1); bool infinv = inf_form(f2, f1);
bool infnegleft = infneg_form(f2, f1, 0); bool infnegleft = infneg_form(f2, f1, 0);
@ -154,9 +152,9 @@ namespace spot
return; return;
} }
/* a < b => a U (b U c) = (b U c) */ /* a < b => a U (b U c) = (b U c) */
if (node_type(f2) == node_type_form_visitor::Binop) if (node_type(f2) == node_type_form_visitor::Binop
if (dynamic_cast<binop*>(f2)->op() == binop::U) && dynamic_cast<binop*>(f2)->op() == binop::U
if (inf_form(f1,dynamic_cast<binop*>(f2)->first())) && inf_form(f1, dynamic_cast<binop*>(f2)->first()))
{ {
result_ = f2; result_ = f2;
spot::ltl::destroy(f1); spot::ltl::destroy(f1);
@ -180,9 +178,9 @@ namespace spot
return; return;
} }
/* b < a => a R (b R c) = b R c */ /* b < a => a R (b R c) = b R c */
if (node_type(f2) == node_type_form_visitor::Binop) if (node_type(f2) == node_type_form_visitor::Binop
if (dynamic_cast<binop*>(f2)->op() == binop::R) && dynamic_cast<binop*>(f2)->op() == binop::R
if (inf_form(dynamic_cast<binop*>(f2)->first(),f1)) && inf_form(dynamic_cast<binop*>(f2)->first(), f1))
{ {
result_ = f2; result_ = f2;
spot::ltl::destroy(f1); spot::ltl::destroy(f1);
@ -208,7 +206,8 @@ namespace spot
for (unsigned i = 0; i < mos; ++i) for (unsigned i = 0; i < mos; ++i)
res->push_back(recurse(mo->nth(i))); res->push_back(recurse(mo->nth(i)));
if (o != EventualUniversal){ if (o != EventualUniversal)
{
switch (mo->op()) switch (mo->op())
{ {
@ -271,13 +270,15 @@ namespace spot
/* f1 < !f2 => f1 & f2 = false /* f1 < !f2 => f1 & f2 = false
!f1 < f2 => f1 | f2 = true */ !f1 < f2 => f1 | f2 = true */
for (index = res->begin(); index != res->end(); index++) { for (index = res->begin(); index != res->end(); index++)
for (indextmp = res->begin(); indextmp != res->end(); indextmp++) { for (indextmp = res->begin(); indextmp != res->end(); indextmp++)
if (index != indextmp){ if (index != indextmp
if (infneg_form(*index,*indextmp, (mo->op() == multop::Or) ? 0 : 1)) { && infneg_form(*index,*indextmp,
for (multop::vec::iterator j = res->begin(); j != res->end(); j++) { (mo->op() == multop::Or) ? 0 : 1))
{
for (multop::vec::iterator j = res->begin();
j != res->end(); j++)
spot::ltl::destroy(*j); spot::ltl::destroy(*j);
}
if (mo->op() == multop::Or) if (mo->op() == multop::Or)
result_ = constant::true_instance(); result_ = constant::true_instance();
else else
@ -285,10 +286,8 @@ namespace spot
return; return;
} }
} }
} if (res->size())
} {
}
if (res->size()) {
result_ = multop::instance(mo->op(), res); result_ = multop::instance(mo->op(), res);
return; return;
} }
@ -313,7 +312,8 @@ namespace spot
spot::ltl::formula* ftmp2 = NULL; spot::ltl::formula* ftmp2 = NULL;
reduce_form_visitor v(o); reduce_form_visitor v(o);
if (o == BRI) { if (o == BRI)
{
ftmp1 = spot::ltl::basic_reduce_form(f); ftmp1 = spot::ltl::basic_reduce_form(f);
const_cast<formula*>(ftmp1)->accept(v); const_cast<formula*>(ftmp1)->accept(v);
ftmp2 = spot::ltl::basic_reduce_form(v.result()); ftmp2 = spot::ltl::basic_reduce_form(v.result());
@ -322,7 +322,8 @@ namespace spot
return ftmp2; return ftmp2;
} }
else { else
{
const_cast<formula*>(f)->accept(v); const_cast<formula*>(f)->accept(v);
return v.result(); return v.result();
} }
@ -341,7 +342,8 @@ namespace spot
ftmp1 = spot::ltl::unabbreviate_logic(f); ftmp1 = spot::ltl::unabbreviate_logic(f);
ftmp2 = spot::ltl::negative_normal_form(ftmp1); ftmp2 = spot::ltl::negative_normal_form(ftmp1);
switch (o) { switch (o)
{
case Base: case Base:
ftmp3 = spot::ltl::basic_reduce_form(ftmp2); ftmp3 = spot::ltl::basic_reduce_form(ftmp2);
break; break;

View file

@ -39,18 +39,27 @@ while read file; do
grep '[ ]if (.*).*{' $tmp && grep '[ ]if (.*).*{' $tmp &&
diag 'Opening { should be on its own line.' diag 'Opening { should be on its own line.'
grep '[ ]if (.*).*;' $tmp &&
diag 'if body should be on another line.'
grep '[ ]while(' $tmp && grep '[ ]while(' $tmp &&
diag 'Missing space after "while"' diag 'Missing space after "while"'
grep '[ ]while (.*).*{' $tmp && grep '[ ]while (.*).*{' $tmp &&
diag 'Opening { should be on its own line.' diag 'Opening { should be on its own line.'
grep '[ ]while (.*).*[^)];' $tmp &&
diag 'while body should be on another line.'
grep '[ ]for(' $tmp && grep '[ ]for(' $tmp &&
diag 'Missing space after "for"' diag 'Missing space after "for"'
grep '[ ]for (.*).*{' $tmp && grep '[ ]for (.*).*{' $tmp &&
diag 'Opening { should be on its own line.' diag 'Opening { should be on its own line.'
grep '[ ]for (.*;.*;.*).*;' $tmp &&
diag 'for body should be on another line.'
grep '[ ]switch(' $tmp && grep '[ ]switch(' $tmp &&
diag 'Missing space after "switch"' diag 'Missing space after "switch"'
@ -75,6 +84,12 @@ while read file; do
grep '[^ ]||[^ ]' $tmp && grep '[^ ]||[^ ]' $tmp &&
diag 'Space arround binary operators.' diag 'Space arround binary operators.'
grep '[ ]default:[^:].*;' $tmp &&
diag 'Label should be on their own line.'
grep '[ ]case.*:[^:].*;' $tmp &&
diag 'Label should be on their own line.'
$fail && echo "$file" >>failures $fail && echo "$file" >>failures
done done