* iface/gspn/eesrg.cc (format_state): Do not rewrite n's,
just strip the last one. Escaping must be done at output. * iface/gspn/gspm.cc (format_state): Likewise. * src/misc/escape.hh, src/misc/escape.cc: New files. * src/misc/Makefile.am: Add them. * src/tgba/bddprint.cc (bdd_format_accset): New function. * src/tgba/bddprint.hh (bdd_format_accset): New function. * src/tgbaalgos/dotty.cc (dotty_bfs::process_state): Escape the state name using escape_str(). (dotty_bfs::process_link): Escape conditions and acceptance conditions using escape_str(). * src/tgbaalgos/save.cc (save_bfs::start): Call print_acc(). (save_bfs::print_acc): New function extracted from save_bfs::start(). Escape each acceptance condition. (save_bfs::process_state): Use escape_str() and print_acc()
This commit is contained in:
parent
8008deeddd
commit
9297d6dd9f
10 changed files with 182 additions and 91 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
//
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
#include "dotty.hh"
|
||||
#include "tgba/bddprint.hh"
|
||||
#include "reachiter.hh"
|
||||
#include "misc/escape.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
|
|
@ -52,19 +53,20 @@ namespace spot
|
|||
void
|
||||
process_state(const state* s, int n, tgba_succ_iterator*)
|
||||
{
|
||||
os_ << " " << n << " [label=\""
|
||||
<< automata_->format_state(s) << "\"]" << std::endl;
|
||||
os_ << " " << n << " [label=\"";
|
||||
escape_str(os_, automata_->format_state(s)) << "\"]" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
process_link(int in, int out, const tgba_succ_iterator* si)
|
||||
{
|
||||
os_ << " " << in << " -> " << out << " [label=\"";
|
||||
bdd_print_formula(os_, automata_->get_dict(),
|
||||
si->current_condition()) << "\\n";
|
||||
bdd_print_accset(os_, automata_->get_dict(),
|
||||
si->current_acceptance_conditions()) << "\"]"
|
||||
<< std::endl;
|
||||
escape_str(os_, bdd_format_formula(automata_->get_dict(),
|
||||
si->current_condition())) << "\\n";
|
||||
escape_str(os_,
|
||||
bdd_format_accset(automata_->get_dict(),
|
||||
si->current_acceptance_conditions()))
|
||||
<< "\"]" << std::endl;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "tgba/bddprint.hh"
|
||||
#include "ltlvisit/tostring.hh"
|
||||
#include "reachiter.hh"
|
||||
#include "misc/escape.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
|
|
@ -39,10 +40,34 @@ namespace spot
|
|||
void
|
||||
start()
|
||||
{
|
||||
const bdd_dict* d = automata_->get_dict();
|
||||
os_ << "acc =";
|
||||
print_acc(automata_->all_acceptance_conditions()) << ";" << std::endl;
|
||||
}
|
||||
|
||||
bdd acc = automata_->all_acceptance_conditions();
|
||||
void
|
||||
process_state(const state* s, int, tgba_succ_iterator* si)
|
||||
{
|
||||
const bdd_dict* d = automata_->get_dict();
|
||||
std::string cur = automata_->format_state(s);
|
||||
for (si->first(); !si->done(); si->next())
|
||||
{
|
||||
state* dest = si->current_state();
|
||||
os_ << "\"" << cur << "\", \""
|
||||
<< automata_->format_state(dest) << "\", \"";
|
||||
escape_str(os_, bdd_format_formula(d, si->current_condition()));
|
||||
os_ << "\",";
|
||||
print_acc(si->current_acceptance_conditions()) << ";" << std::endl;
|
||||
delete dest;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::ostream& os_;
|
||||
|
||||
std::ostream&
|
||||
print_acc(bdd acc)
|
||||
{
|
||||
const bdd_dict* d = automata_->get_dict();
|
||||
while (acc != bddfalse)
|
||||
{
|
||||
bdd cube = bdd_satone(acc);
|
||||
|
|
@ -59,50 +84,14 @@ namespace spot
|
|||
d->acc_formula_map.find(v);
|
||||
assert(vi != d->acc_formula_map.end());
|
||||
os_ << " \"";
|
||||
ltl::to_string(vi->second, os_) << "\"";
|
||||
escape_str(os_, ltl::to_string(vi->second)) << "\"";
|
||||
break;
|
||||
}
|
||||
cube = bdd_low(cube);
|
||||
}
|
||||
}
|
||||
os_ << ";" << std::endl;
|
||||
return os_;
|
||||
}
|
||||
|
||||
void
|
||||
process_state(const state* s, int, tgba_succ_iterator* si)
|
||||
{
|
||||
const bdd_dict* d = automata_->get_dict();
|
||||
std::string cur = automata_->format_state(s);
|
||||
for (si->first(); !si->done(); si->next())
|
||||
{
|
||||
state* dest = si->current_state();
|
||||
os_ << "\"" << cur << "\", \""
|
||||
<< automata_->format_state(dest) << "\", \"";
|
||||
std::string s = bdd_format_formula(d, si->current_condition());
|
||||
// Escape " and \ characters in s.
|
||||
for (std::string::const_iterator i = s.begin();
|
||||
i != s.end(); ++i)
|
||||
switch (*i)
|
||||
{
|
||||
case '\\':
|
||||
os_ << "\\\\";
|
||||
break;
|
||||
case '"':
|
||||
os_ << "\\\"";
|
||||
break;
|
||||
default:
|
||||
os_ << *i;
|
||||
break;
|
||||
}
|
||||
os_ << "\",";
|
||||
bdd_print_acc(os_, d, si->current_acceptance_conditions());
|
||||
os_ << ";" << std::endl;
|
||||
delete dest;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::ostream& os_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue