ltlvisit: rename tostring.hh as print.hh and rename printer functions

This actually performs three related changes, but separating them
would be quite inconvenient.

1) rename tostring.hh to print.hh a welcome side-effect is that
I could fix several files that included this file for not reason.

2) de-overload some of the to_string functions, and rename them
as follow:

  to_string -> print_psl, print_sere, str_psl, str_sere
  to_utf8_string -> print_utf8_psl, print_utf8_sere,
                    str_utf8_psl, str_utf8_sere
  to_spin_string -> print_spin_ltl, str_spin_ltl
  to_wring_string -> print_wring_ltl, str_wing_ltl
  to_lbt_string -> print_lbt_ltl, str_lbt_ltl
  to_latex_string -> print_latex_psl, str_latex_psl
  to_sclatex_string -> print_sclatex_psl, str_sclatex_psl

Now it is clearer what these functions do, and their restrictions.

3) all those print_* functions now take the stream to write onto
as their first argument.  This fixes #88.

* src/ltlvisit/tostring.cc, src/ltlvisit/tostring.hh: Rename into...
* src/ltlvisit/print.cc, src/ltlvisit/print.hh: ... those, and make
the changes listed above.
* doc/org/tut01.org, src/bin/common_output.cc,
src/bin/common_trans.cc, src/bin/ltl2tgba.cc, src/bin/ltl2tgta.cc,
src/bin/ltlcross.cc, src/bin/ltldo.cc, src/bin/ltlfilt.cc,
src/bin/randltl.cc, src/ltlparse/ltlparse.yy,
src/ltlvisit/Makefile.am, src/ltlvisit/mark.cc,
src/ltlvisit/relabel.cc, src/ltlvisit/simplify.cc,
src/ltlvisit/snf.cc, src/ta/taexplicit.cc, src/ta/tgtaexplicit.cc,
src/taalgos/tgba2ta.cc, src/tests/equalsf.cc, src/tests/ltl2tgba.cc,
src/tests/ltlrel.cc, src/tests/randtgba.cc, src/tests/reduc.cc,
src/tests/syntimpl.cc, src/tests/tostring.cc, src/twa/bdddict.cc,
src/twa/bddprint.cc, src/twa/taatgba.cc, src/twa/taatgba.hh,
src/twa/twagraph.cc, src/twaalgos/compsusp.cc, src/twaalgos/lbtt.cc,
src/twaalgos/ltl2taa.cc, src/twaalgos/ltl2tgba_fm.cc,
src/twaalgos/neverclaim.cc, src/twaalgos/remprop.cc,
src/twaalgos/stats.cc, wrap/python/ajax/spot.in, wrap/python/spot.py,
wrap/python/spot_impl.i: Adjust.
This commit is contained in:
Alexandre Duret-Lutz 2015-06-04 22:56:57 +02:00
parent 0cf952e793
commit 8fb7b279f7
42 changed files with 365 additions and 312 deletions

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et
// Copyright (C) 2012, 2013, 2014, 2015 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -26,7 +26,7 @@
#include "simulation.hh"
#include "safety.hh"
#include "ltlast/allnodes.hh"
#include "ltlvisit/tostring.hh"
#include "ltlvisit/print.hh"
#include "ltlvisit/clone.hh"
#include <queue>
#include <sstream>
@ -167,8 +167,7 @@ namespace spot
std::ostringstream s;
s << "";
to_string(f, s);
s << "";
print_psl(s, f) << "";
res = suspenv.require(s.str());
// We have to clone f, because it is not always a sub-tree
// of the original formula. (Think n-ary operators.)
@ -184,8 +183,7 @@ namespace spot
std::ostringstream s;
s << '[';
to_string(f, s);
s << ']';
print_psl(s, f) << ']';
res = suspenv.require(s.str());
// We have to clone f, because it is not always a sub-tree
// of the original formula. (Think n-ary operators.)

View file

@ -28,7 +28,7 @@
#include "reachiter.hh"
#include "misc/bddlt.hh"
#include "priv/accmap.hh"
#include "ltlvisit/tostring.hh"
#include "ltlvisit/print.hh"
#include "ltlparse/public.hh"
namespace spot
@ -107,7 +107,7 @@ namespace spot
}
const ltl::formula* f = bdd_to_formula(si->current_condition(),
aut_->get_dict());
to_lbt_string(f, body_);
print_lbt_ltl(body_, f);
f->destroy();
body_ << '\n';
}

View file

@ -24,7 +24,6 @@
#include "ltlvisit/lunabbrev.hh"
#include "ltlvisit/tunabbrev.hh"
#include "ltlvisit/nenoform.hh"
#include "ltlvisit/tostring.hh"
#include "ltlvisit/contain.hh"
#include "ltl2taa.hh"

View file

@ -26,11 +26,11 @@
#include "ltlast/visitor.hh"
#include "ltlast/allnodes.hh"
#include "ltlvisit/nenoform.hh"
#include "ltlvisit/tostring.hh"
#include "ltlvisit/print.hh"
#include "ltlvisit/postfix.hh"
#include "ltlvisit/apcollect.hh"
#include "ltlvisit/mark.hh"
#include "ltlvisit/tostring.hh"
#include "ltlvisit/print.hh"
#include <cassert>
#include <memory>
#include <utility>
@ -392,7 +392,7 @@ namespace spot
for (auto& fi: next_map)
{
os << " " << fi.second << ": Next[";
to_string(fi.first, os) << ']' << std::endl;
print_psl(os, fi.first) << ']' << std::endl;
}
os << "Shared Dict:" << std::endl;
dict->dump(os);
@ -513,9 +513,8 @@ namespace spot
bdd dest_bdd = bdd_existcomp(cube, d.next_set);
const formula* dest = d.conj_bdd_to_formula(dest_bdd);
bdd_print_set(std::cerr, d.dict, label) << " => ";
bdd_print_set(std::cerr, d.dict, dest_bdd) << " = "
<< to_string(dest)
<< '\n';
bdd_print_set(std::cerr, d.dict, dest_bdd) << " = ";
print_psl(std::cerr, dest) << '\n';
dest->destroy();
}
return std::cerr;
@ -1071,14 +1070,6 @@ namespace spot
translate_ratexp(const formula* f, translate_dict& dict,
const formula* to_concat)
{
// static unsigned indent = 0;
// for (unsigned i = indent; i > 0; --i)
// std::cerr << "| ";
// std::cerr << "translate_ratexp[" << to_string(f);
// if (to_concat)
// std::cerr << ", " << to_string(to_concat);
// std::cerr << ']' << std::endl;
// ++indent;
bdd res;
if (!f->is_boolean())
{
@ -1096,11 +1087,6 @@ namespace spot
res &= bdd_ithvar(x);
to_concat->destroy();
}
// --indent;
// for (unsigned i = indent; i > 0; --i)
// std::cerr << "| ";
// std::cerr << "\\ ";
// bdd_print_set(std::cerr, dict.dict, res) << std::endl;
return res;
}
@ -1834,11 +1820,6 @@ namespace spot
formula_set implied;
implied_subformulae(node, implied);
// std::cerr << "---" << std::endl;
// for (formula_set::const_iterator i = implied.begin();
// i != implied.end(); ++i)
// std::cerr << to_string(*i) << std::endl;
res_ = bddtrue;
unsigned s = node->size();
for (unsigned n = 0; n < s; ++n)
@ -1860,13 +1841,8 @@ namespace spot
// G(Fa & Fb) get optimized. See the comment in
// the case handling G.
bdd res = recurse(sub, recurring_);
//std::cerr << "== in And (" << to_string(sub)
// << ')' << std::endl;
// trace_ltl_bdd(dict_, res);
res_ &= res;
}
//std::cerr << "=== And final" << std::endl;
// trace_ltl_bdd(dict_, res_);
break;
}
case multop::Or:
@ -2111,7 +2087,7 @@ namespace spot
translate_dict::translated t = d_.ltl_to_bdd(f, !f->is_marked());
// std::cerr << "-----" << std::endl;
// std::cerr << "Formula: " << to_string(f) << std::endl;
// std::cerr << "Formula: " << str_psl(f) << std::endl;
// std::cerr << "Rational: " << t.has_rational << std::endl;
// std::cerr << "Marked: " << t.has_marked << std::endl;
// std::cerr << "Mark all: " << !f->is_marked() << std::endl;

View file

@ -26,7 +26,7 @@
#include "twa/bddprint.hh"
#include "twa/twagraph.hh"
#include "reachiter.hh"
#include "ltlvisit/tostring.hh"
#include "ltlvisit/print.hh"
#include "twa/formula2bdd.hh"
namespace spot
@ -151,11 +151,13 @@ namespace spot
else
os_ << " :: (";
const ltl::formula* f = bdd_to_formula(t.cond, aut_->get_dict());
to_spin_string(f, os_, true);
// This is actually a Boolean formula, but the LTL printer
// is all we have.
print_spin_ltl(os_, f, true);
if (atom)
{
os_ << ") -> assert(!(";
to_spin_string(f, os_, true);
print_spin_ltl(os_, f, true);
os_ << ")) }";
}
else

View file

@ -21,7 +21,6 @@
#include "ltlenv/defaultenv.hh"
#include "twaalgos/mask.hh"
#include "misc/casts.hh"
#include "ltlvisit/tostring.hh"
#include <ctype.h>
#include <sstream>

View file

@ -25,7 +25,7 @@
#include "twa/twa.hh"
#include "stats.hh"
#include "reachiter.hh"
#include "ltlvisit/tostring.hh"
#include "ltlvisit/print.hh"
#include "twaalgos/isdet.hh"
#include "twaalgos/sccinfo.hh"
@ -137,7 +137,7 @@ namespace spot
void printable_formula::print(std::ostream& os, const char*) const
{
ltl::to_string(val_, os);
ltl::print_psl(os, val_);
};
stat_printer::stat_printer(std::ostream& os, const char* format)