Revert everything related to Damien's work in 2008 (he will commit a new version soon).

Here are the reverted patches:
8c0d1003b0,
25a3114287,
9afbaf6342,
dc0005f4e1,
543190f2bc.
This commit is contained in:
Alexandre Duret-Lutz 2009-03-25 13:58:18 +01:00
parent 3d278663cd
commit b1bfdee870
130 changed files with 912 additions and 5104 deletions

View file

@ -20,16 +20,13 @@
// 02111-1307, USA.
/// \file ltlast/formula.hh
/// \brief LTL formula, AST and visitor interface
/// \brief LTL formula interface
#ifndef SPOT_LTLAST_FORMULA_HH
# define SPOT_LTLAST_FORMULA_HH
# include "internal/formula.hh"
# include "internal/atomic_prop.hh"
# include "internal/constant.hh"
# include "internal/unop.hh"
# include "internal/binop.hh"
# include "internal/multop.hh"
#include <string>
#include <cassert>
#include "predecl.hh"
namespace spot
{
@ -64,9 +61,6 @@ namespace spot
/// \addtogroup ltl_misc Miscellaneous algorithms for LTL formulae
/// \ingroup ltl_algorithm
struct ltl_t;
struct visitor;
struct const_visitor;
/// \brief An LTL formula.
/// \ingroup ltl_essential
@ -74,136 +68,114 @@ namespace spot
///
/// The only way you can work with a formula is to
/// build a spot::ltl::visitor or spot::ltl::const_visitor.
typedef spot::internal::formula<ltl_t> formula;
/// Forward declarations
formula* clone(const formula* f);
std::ostream& to_string(const formula* f, std::ostream& os);
void destroy(const formula* f);
struct ltl_t
class formula
{
typedef spot::ltl::visitor visitor;
typedef spot::ltl::const_visitor const_visitor;
public:
/// Entry point for vspot::ltl::visitor instances.
virtual void accept(visitor& v) = 0;
/// Entry point for vspot::ltl::const_visitor instances.
virtual void accept(const_visitor& v) const = 0;
static formula* clone_(const formula* f)
/// \brief clone this node
///
/// This increments the reference counter of this node (if one is
/// used). You should almost never use this method directly as
/// it doesn't touch the children. If you want to clone a
/// whole formula, use spot::ltl::clone() instead.
formula* ref();
/// \brief release this node
///
/// This decrements the reference counter of this node (if one is
/// used) and can free the object. You should almost never use
/// this method directly as it doesn't touch the children. If you
/// want to release a whole formula, use spot::ltl::destroy() instead.
static void unref(formula* f);
/// Return a canonic representation of the formula
const std::string& dump() const;
/// Return a hash_key for the formula.
size_t
hash() const
{
return clone(f);
return hash_key_;
}
protected:
virtual ~formula();
static std::ostream& to_string_(const formula* f, std::ostream& os)
{
return to_string(f, os);
}
/// \brief increment reference counter if any
virtual void ref_();
/// \brief decrement reference counter if any, return true when
/// the instance must be deleted (usually when the counter hits 0).
virtual bool unref_();
static void destroy_(const formula* f)
{
destroy(f);
}
/// \brief Compute key_ from dump_.
///
/// Should be called once in each object, after dump_ has been set.
void set_key_();
/// The canonic representation of the formula
std::string dump_;
/// \brief The hash key of this formula.
///
/// Initialized by set_key_().
size_t hash_key_;
};
enum binop { Xor, Implies, Equiv, U, R };
const char* binop_name(binop op) const
/// \brief Strict Weak Ordering for <code>const formula*</code>.
/// \ingroup ltl_essentials
///
/// This is meant to be used as a comparison functor for
/// STL \c map whose key are of type <code>const formula*</code>.
///
/// For instance here is how one could declare
/// a map of \c const::formula*.
/// \code
/// // Remember how many times each formula has been seen.
/// std::map<const spot::ltl::formula*, int,
/// spot::formula_ptr_less_than> seen;
/// \endcode
struct formula_ptr_less_than:
public std::binary_function<const formula*, const formula*, bool>
{
bool
operator()(const formula* left, const formula* right) const
{
switch (op)
{
case Xor:
return "Xor";
case Implies:
return "Implies";
case Equiv:
return "Equiv";
case U:
return "U";
case R:
return "R";
}
// Unreachable code.
assert(0);
return 0;
}
enum unop { Not, X, F, G };
const char* unop_name(unop op) const
{
switch (op)
{
case Not:
return "Not";
case X:
return "X";
case F:
return "F";
case G:
return "G";
}
// Unreachable code.
assert(0);
return 0;
assert(left);
assert(right);
size_t l = left->hash();
size_t r = right->hash();
if (1 != r)
return l < r;
return left->dump() < right->dump();
}
};
typedef spot::internal::formula_ptr_less_than formula_ptr_less_than;
typedef spot::internal::formula_ptr_hash formula_ptr_hash;
/// \brief Atomic propositions.
/// \ingroup ltl_ast
typedef spot::internal::atomic_prop<ltl_t> atomic_prop;
/// \brief A constant (True or False)
/// \ingroup ltl_ast
typedef spot::internal::constant<ltl_t> constant;
/// \brief Unary operators.
/// \ingroup ltl_ast
typedef spot::internal::unop<ltl_t> unop;
/// \brief Binary operator.
/// \ingroup ltl_ast
typedef spot::internal::binop<ltl_t> binop;
/// \brief Multi-operand operators.
/// \ingroup ltl_ast
/// \brief Hash Function for <code>const formula*</code>.
/// \ingroup ltl_essentials
/// \ingroup hash_funcs
///
/// These operators are considered commutative and associative.
typedef spot::internal::multop<ltl_t> multop;
/// \brief Formula visitor that can modify the formula.
/// \ingroup ltl_essential
/// This is meant to be used as a hash functor for
/// Sgi's \c hash_map whose key are of type <code>const formula*</code>.
///
/// 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::ltl:const_visitor instead.
struct visitor
/// For instance here is how one could declare
/// a map of \c const::formula*.
/// \code
/// // Remember how many times each formula has been seen.
/// Sgi::hash_map<const spot::ltl::formula*, int,
/// const spot::ltl::formula_ptr_hash> seen;
/// \endcode
struct formula_ptr_hash:
public std::unary_function<const formula*, size_t>
{
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;
size_t
operator()(const formula* that) const
{
assert(that);
return that->hash();
}
};
/// \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::ltl: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;
};
}
}