lbt: Do not write a trailing space.

* NEWS: Mention it.
* src/ltlvisit/lbt.cc: Instead of outputting a space after each
node, output one before each node but the first one.
This commit is contained in:
Alexandre Duret-Lutz 2013-01-19 15:27:57 +01:00
parent bf3c3aecde
commit 3a5eec42de
2 changed files with 41 additions and 24 deletions

2
NEWS
View file

@ -13,6 +13,8 @@ New in spot 1.0a (not released):
(instead of binary operators) when placed in double quotes, but
on output they were output without quotes, making the result
unparsable.
- the to_lbt_string() functions would always output a trailing space.
This is not the case anymore.
- tgba_product::transition_annotation() would segfault when
called in a product against a Kripke structure.
* Minor improvements:

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -46,12 +46,24 @@ namespace spot
class lbt_visitor: public visitor
{
protected:
std::ostream& os_;
bool first_;
public:
lbt_visitor(std::ostream& os)
: os_(os)
: os_(os), first_(true)
{
}
void blank()
{
if (first_)
first_ = false;
else
os_ << ' ';
}
virtual
~lbt_visitor()
{
@ -60,16 +72,18 @@ namespace spot
void
visit(const atomic_prop* ap)
{
blank();
std::string str = ap->name();
if (!is_pnum(str.c_str()))
os_ << '"' << str << "\" ";
os_ << '"' << str << '"';
else
os_ << str << ' ';
os_ << str;
}
void
visit(const constant* c)
{
blank();
switch (c->val())
{
case constant::False:
@ -87,6 +101,7 @@ namespace spot
void
visit(const binop* bo)
{
blank();
switch (bo->op())
{
case binop::Xor:
@ -129,6 +144,7 @@ namespace spot
void
visit(const unop* uo)
{
blank();
switch (uo->op())
{
case unop::Not:
@ -182,15 +198,14 @@ namespace spot
unsigned n = mo->size();
for (unsigned i = n - 1; i != 0; --i)
os_ << o << ' ';
{
blank();
os_ << o;
}
for (unsigned i = 0; i < n; ++i)
{
mo->nth(i)->accept(*this);
}
}
protected:
std::ostream& os_;
};
} // anonymous