Template ltlast/ & ltlenv/ classes in internal/ & Add ELTL parser.

This commit is contained in:
Damien Lefortier 2008-03-25 16:52:06 +01:00 committed by Damien Lefortier
parent 21c98c0a01
commit 543190f2bc
74 changed files with 4299 additions and 468 deletions

44
src/eltlast/Makefile.am Normal file
View file

@ -0,0 +1,44 @@
## Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
## département Systèmes Répartis Coopératifs (SRC), Université Pierre
## et Marie Curie.
##
## This file is part of Spot, a model checking library.
##
## Spot is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## Spot is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
## License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Spot; see the file COPYING. If not, write to the Free
## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
AM_CPPFLAGS = -I$(srcdir)/..
AM_CXXFLAGS = $(WARNING_CXXFLAGS)
eltlastdir = $(pkgincludedir)/eltlast
eltlast_HEADERS = \
allnodes.hh \
atomic_prop.hh \
automatop.hh \
binop.hh \
constant.hh \
formula.hh \
multop.hh \
nfa.hh \
refformula.hh \
unop.hh \
visitor.hh
noinst_LTLIBRARIES = libeltlast.la
libeltlast_la_SOURCES = \
automatop.cc \
nfa.cc

36
src/eltlast/allnodes.hh Normal file
View file

@ -0,0 +1,36 @@
// 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.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
/// \file eltlast/allnodes.hh
/// \brief Define all ELTL node types.
///
/// This file is usually needed when \b defining a visitor.
#ifndef SPOT_ELTLAST_ALLNODES_HH
# define SPOT_ELTLAST_ALLNODES_HH
# include "binop.hh"
# include "unop.hh"
# include "multop.hh"
# include "atomic_prop.hh"
# include "constant.hh"
# include "automatop.hh"
#endif // SPOT_ELTLAST_ALLNODES_HH

View file

@ -0,0 +1,42 @@
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
/// \file eltlast/atomic_prop.hh
/// \brief ELTL atomic propositions
#ifndef SPOT_ELTLAST_ATOMIC_PROP_HH
# define SPOT_ELTLAST_ATOMIC_PROP_HH
# include "formula.hh"
# include "internal/atomic_prop.hh"
namespace spot
{
namespace eltl
{
/// \brief Atomic propositions.
/// \ingroup eltl_ast
typedef spot::internal::atomic_prop<eltl_t> atomic_prop;
}
}
#endif // SPOT_ELTLAST_ATOMICPROP_HH

121
src/eltlast/automatop.cc Normal file
View file

@ -0,0 +1,121 @@
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include "visitor.hh"
#include "automatop.hh"
namespace spot
{
namespace eltl
{
automatop::automatop(vec* v)
: nfa_(), children_(v)
{
dump_ = "automatop(";
dump_ += (*v)[0]->dump();
for (unsigned n = 1; n < v->size(); ++n)
dump_ += ", " + (*v)[n]->dump();
dump_ += ")";
set_key_();
}
automatop::~automatop()
{
delete children_;
}
void
automatop::accept(visitor& v)
{
v.visit(this);
}
void
automatop::accept(const_visitor& v) const
{
v.visit(this);
}
automatop*
automatop::instance(nfa::ptr nfa, formula* autop)
{
vec* v = new vec;
v->push_back(autop);
automatop* res = instance(v);
res->nfa_ = nfa;
return res;
}
automatop*
automatop::instance(formula* first, formula* second)
{
vec* v = new vec;
v->push_back(first);
v->push_back(second);
return instance(v);
}
automatop*
automatop::instance(vec* v)
{
// Inline children of same kind.
{
vec inlined;
vec::iterator i = v->begin();
while (i != v->end())
{
if (automatop* p = dynamic_cast<automatop*>(*i))
{
unsigned ps = p->size();
for (unsigned n = 0; n < ps; ++n)
inlined.push_back(p->nth(n));
formula::unref(*i);
i = v->erase(i);
}
else
++i;
}
v->insert(v->end(), inlined.begin(), inlined.end());
}
automatop* res = new automatop(v);
return static_cast<automatop*>(res->ref());
}
unsigned
automatop::size() const
{
return children_->size();
}
const formula*
automatop::nth(unsigned n) const
{
return (*children_)[n];
}
formula*
automatop::nth(unsigned n)
{
return (*children_)[n];
}
}
}

84
src/eltlast/automatop.hh Normal file
View file

@ -0,0 +1,84 @@
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
/// \file eltlast/automatop.hh
/// \brief ELTL automaton operators
#ifndef SPOT_ELTLAST_AUTOMATOP_HH
# define SPOT_ELTLAST_AUTOMATOP_HH
# include "multop.hh"
# include "refformula.hh"
# include "nfa.hh"
namespace spot
{
namespace eltl
{
/// \brief Automaton operators.
/// \ingroup eltl_ast
///
class automatop : public ref_formula
{
public:
/// List of formulae.
typedef std::vector<formula*> vec;
/// \brief Build a spot::eltl::automatop with automaton \c nfa
/// and children of \c autop.
static automatop* instance(nfa::ptr nfa, formula* autop);
/// \brief Build a spot::eltl::automatop with two children.
///
/// If one of the children itself is a spot::eltl::automatop,
/// it will be merged. This allows incremental building of
/// n-ary eltl::automatop.
static automatop* instance(formula* first, formula* second);
/// \brief Build a spot::eltl::automatop with many children.
static automatop* instance(vec* v);
virtual void accept(visitor& v);
virtual void accept(const_visitor& v) const;
/// Get the number of argument.
unsigned size() const;
/// \brief Get the nth argument.
///
/// Starting with \a n = 0.
const formula* nth(unsigned n) const;
/// \brief Get the nth argument.
///
/// Starting with \a n = 0.
formula* nth(unsigned n);
protected:
automatop(vec* v);
virtual ~automatop();
private:
nfa::ptr nfa_;
vec* children_;
};
}
}
#endif // SPOT_ELTLAST_AUTOMATOP_HH

45
src/eltlast/binop.hh Normal file
View file

@ -0,0 +1,45 @@
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
/// \file eltlast/binop.hh
/// \brief ELTL binary operators
///
/// This does not include \c AND and \c OR operators. These are
/// considered to be multi-operand operators (see spot::eltl::multop).
#ifndef SPOT_ELTLAST_BINOP_HH
# define SPOT_ELTLAST_BINOP_HH
# include "formula.hh"
# include "internal/binop.hh"
namespace spot
{
namespace eltl
{
/// \brief Binary operator.
/// \ingroup eltl_ast
typedef spot::internal::binop<eltl_t> binop;
}
}
#endif // SPOT_ELTLAST_BINOP_HH

42
src/eltlast/constant.hh Normal file
View file

@ -0,0 +1,42 @@
// 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.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
/// \file eltlast/constant.hh
/// \brief ELTL constants
#ifndef SPOT_ELTLAST_CONSTANT_HH
# define SPOT_ELTLAST_CONSTANT_HH
# include "formula.hh"
# include "internal/constant.hh"
namespace spot
{
namespace eltl
{
/// \brief A constant (True or False)
/// \ingroup eltl_ast
typedef spot::internal::constant<eltl_t> constant;
}
}
#endif // SPOT_ELTLAST_CONSTANT_HH

96
src/eltlast/formula.hh Normal file
View file

@ -0,0 +1,96 @@
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
/// \file eltlast/formula.hh
/// \brief ELTL formula interface
#ifndef SPOT_ELTLAST_FORMULA_HH
# define SPOT_ELTLAST_FORMULA_HH
# include "internal/formula.hh"
namespace spot
{
namespace eltl
{
/// \defgroup eltl ELTL formulae
///
/// This module gathers types and definitions related to ELTL formulae.
/// \addtogroup eltl_essential Essential ELTL types
/// \ingroup eltl
/// \addtogroup eltl_ast ELTL Abstract Syntax Tree
/// \ingroup eltl
/// Forward declarations
struct visitor;
struct const_visitor;
/// \brief An ELTL formula.
/// \ingroup eltl_essential
/// \ingroup eltl_ast
///
/// The only way you can work with a formula is to
/// build a spot::eltl::visitor or spot::eltl::const_visitor.
struct eltl_t
{
typedef spot::eltl::visitor visitor;
typedef spot::eltl::const_visitor const_visitor;
enum binop { Xor, Implies, Equiv };
const char* binop_name(binop op) const
{
switch (op)
{
case Xor:
return "Xor";
case Implies:
return "Implies";
case Equiv:
return "Equiv";
}
// Unreachable code.
assert(0);
return 0;
}
enum unop { Not };
const char* unop_name(unop op) const
{
switch (op)
{
case Not:
return "Not";
}
// Unreachable code.
assert(0);
return 0;
}
};
typedef spot::internal::formula<eltl_t> formula;
typedef spot::internal::formula_ptr_less_than<eltl_t> formula_ptr_less_than;
typedef spot::internal::formula_ptr_hash<eltl_t> formula_ptr_hash;
}
}
#endif /* !SPOT_ELTLAST_FORMULA_HH_ */

44
src/eltlast/multop.hh Normal file
View file

@ -0,0 +1,44 @@
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
/// \file eltlast/multop.hh
/// \brief ELTL multi-operand operators
#ifndef SPOT_ELTLAST_MULTOP_HH
# define SPOT_ELTLAST_MULTOP_HH
# include "formula.hh"
# include "internal/multop.hh"
namespace spot
{
namespace eltl
{
/// \brief Multi-operand operators.
/// \ingroup eltl_ast
///
/// These operators are considered commutative and associative.
typedef spot::internal::multop<eltl_t> multop;
}
}
#endif // SPOT_ELTLAST_MULTOP_HH

127
src/eltlast/nfa.cc Normal file
View file

@ -0,0 +1,127 @@
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include <cassert>
#include "nfa.hh"
namespace spot
{
namespace eltl
{
nfa::nfa()
: ns_(), sn_(), init_(0), arity_(0), finals_()
{
}
nfa::~nfa()
{
ns_map::iterator i;
for (i = ns_.begin(); i != ns_.end(); ++i)
{
state::iterator i2;
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
delete *i2;
delete i->second;
}
}
nfa::state*
nfa::add_state(const std::string& name)
{
ns_map::iterator i = ns_.find(name);
if (i == ns_.end())
{
state* s = new nfa::state;
ns_[name] = s;
sn_[s] = name;
if (!init_)
init_ = s;
return s;
}
return i->second;
}
void
nfa::add_transition(const std::string& s, const std::string& d, unsigned c)
{
state* source = add_state(s);
nfa::transition* t = new transition;
t->dest = add_state(d);
t->cost = c;
source->push_back(t);
if (c > arity_)
arity_ = c;
}
void
nfa::set_init_state(const std::string& state)
{
init_ = add_state(state);
}
void
nfa::set_final(const std::string& state)
{
finals_.insert(state);
}
bool
nfa::is_final(const std::string& state)
{
return finals_.find(state) != finals_.end();
}
unsigned
nfa::arity()
{
return arity_ + 1;
}
const nfa::state*
nfa::get_init_state()
{
if (!init_)
add_state("empty");
return init_;
}
nfa::iterator
nfa::begin(const state* s) const
{
return nfa::iterator(s->begin());
}
nfa::iterator
nfa::end(const state* s) const
{
return nfa::iterator(s->end());
}
std::string
nfa::format_state(const state* s) const
{
sn_map::const_iterator i = sn_.find(s);
assert(i != sn_.end());
return i->second;
}
}
}

147
src/eltlast/nfa.hh Normal file
View file

@ -0,0 +1,147 @@
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
/// \file eltlast/nfa.hh
/// \brief NFA interface
#ifndef SPOT_ELTLAST_NFA_HH
# define SPOT_ELTLAST_NFA_HH
# include "misc/hash.hh"
# include <boost/shared_ptr.hpp>
# include <list>
# include <set>
namespace spot
{
namespace eltl
{
/// Forward declaration. See below.
class succ_iterator;
/// \brief A Nondeterministic Finite Automaton used in ELTL
/// automata operators.
/// \ingroup eltl_essential
class nfa
{
public:
struct transition;
typedef std::list<transition*> state;
/// Iterator over the successors of a state.
typedef succ_iterator iterator;
typedef boost::shared_ptr<nfa> ptr;
/// Explicit transitions.
struct transition
{
unsigned cost;
const state* dest;
};
nfa();
~nfa();
void
add_transition(const std::string& s, const std::string& d, unsigned c);
void
set_init_state(const std::string& state);
const state*
get_init_state();
void
set_final(const std::string& state);
bool
is_final(const std::string& state);
/// \brief Get the `arity' i.e. max t.cost, for each transition t.
unsigned
arity();
/// \brief Return an iterator on the first succesor (if any) of \a state.
///
/// The usual way to do this with a \c for lopp.
/// \code
/// for (nfa::iterator i = a.begin(state); i != a.end(state); ++i)
/// ...
/// \endcode
iterator
begin(const state* state) const;
/// \brief Return an iterator just past the last succesor of \a state.
iterator
end(const state* state) const;
std::string
format_state(const state* state) const;
private:
state*
add_state(const std::string& name);
typedef Sgi::hash_map<const std::string, state*, string_hash> ns_map;
typedef Sgi::hash_map<const state*, std::string, ptr_hash<state> > sn_map;
ns_map ns_;
sn_map sn_;
state* init_;
unsigned arity_;
std::set<std::string> finals_;
/// Explicitly disllow use of implicity generated member functions
/// we don't want.
nfa(const nfa& other);
nfa& operator=(const nfa& other);
};
class succ_iterator
{
public:
succ_iterator(const nfa::state::const_iterator s)
: i_(s)
{
}
void
operator++()
{
++i_;
}
bool
operator!=(const succ_iterator& rhs) const
{
return i_ != rhs.i_;
}
const nfa::transition* operator*() const
{
return *i_;
}
private:
nfa::state::const_iterator i_;
};
}
}
#endif // SPOT_ELTLAST_NFA_HH_

42
src/eltlast/refformula.hh Normal file
View file

@ -0,0 +1,42 @@
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
/// \file eltlast/refformula.hh
/// \brief Reference-counted ELTL formulae
#ifndef SPOT_ELTLAST_REFFORMULA_HH
# define SPOT_ELTLAST_REFFORMULA_HH
# include "formula.hh"
# include "internal/refformula.hh"
namespace spot
{
namespace eltl
{
/// \brief A reference-counted ELTL formula.
/// \ingroup eltl_ast
typedef spot::internal::ref_formula<eltl_t> ref_formula;
}
}
#endif // SPOT_ELTLAST_REFFORMULA_HH

42
src/eltlast/unop.hh Normal file
View file

@ -0,0 +1,42 @@
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
/// \file eltlast/unop.hh
/// \brief ELTL unary operators
#ifndef SPOT_ELTLAST_UNOP_HH
# define SPOT_ELTLAST_UNOP_HH
# include "formula.hh"
# include "internal/unop.hh"
namespace spot
{
namespace eltl
{
/// \brief Unary operators.
/// \ingroup eltl_ast
typedef spot::internal::unop<eltl_t> unop;
}
}
#endif // SPOT_ELTLAST_UNOP_HH

82
src/eltlast/visitor.hh Normal file
View file

@ -0,0 +1,82 @@
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
/// \file eltlast/visitor.hh
/// \brief ELTL visitor interface
#ifndef SPOT_ELTLAST_VISITOR_HH
# define SPOT_ELTLAST_VISITOR_HH
# include "binop.hh"
# include "unop.hh"
# include "multop.hh"
# include "atomic_prop.hh"
# include "constant.hh"
namespace spot
{
namespace eltl
{
// Forward declaration.
struct automatop;
/// \brief Formula visitor that can modify the formula.
/// \ingroup eltl_essential
///
/// Writing visitors is the prefered way
/// to traverse a formula, since it doesn't
/// involve any cast.
///
/// If you do not need to modify the visited formula, inherit from
/// spot::eltl:const_visitor instead.
struct visitor
{
virtual ~visitor() {}
virtual void visit(atomic_prop* node) = 0;
virtual void visit(constant* node) = 0;
virtual void visit(binop* node) = 0;
virtual void visit(unop* node) = 0;
virtual void visit(multop* node) = 0;
virtual void visit(automatop* node) = 0;
};
/// \brief Formula visitor that cannot modify the formula.
///
/// Writing visitors is the prefered way
/// to traverse a formula, since it doesn't
/// involve any cast.
///
/// If you want to modify the visited formula, inherit from
/// spot::eltl:visitor instead.
struct const_visitor
{
virtual ~const_visitor() {}
virtual void visit(const atomic_prop* node) = 0;
virtual void visit(const constant* node) = 0;
virtual void visit(const binop* node) = 0;
virtual void visit(const unop* node) = 0;
virtual void visit(const multop* node) = 0;
virtual void visit(const automatop* node) = 0;
};
}
}
#endif // SPOT_ELTLAST_VISITOR_HH