* HACKING, Makefile.am, configure.ac, m4/gccwarn.m4,
src/Makefile.am, src/ltlast/Makefile.am, src/ltlast/allnodes.hh, src/ltlast/atomic_prop.cc, src/ltlast/atomic_prop.hh, src/ltlast/binop.cc, src/ltlast/binop.hh, src/ltlast/constant.cc, src/ltlast/constant.hh, src/ltlast/formulae.hh, src/ltlast/multop.cc, src/ltlast/multop.hh, src/ltlast/predecl.hh, src/ltlast/unop.cc, src/ltlast/unop.hh, src/ltlast/visitor.hh, src/ltlparse/Makefile.am, src/ltlparse/ltlparse.yy, src/ltlparse/ltlscan.ll, src/ltlparse/parsedecl.hh, src/ltlparse/public.hh, src/ltlvisit/Makefile.am, src/ltlvisit/dotty.cc, src/ltlvisit/dotty.hh, src/ltlvisit/dump.cc, src/ltlvisit/dump.hh, src/ltlvisit/rewrite.cc, src/ltlvisit/rewrite.hh, src/ltltest/Makefile.am, src/ltltest/defs.in, src/ltltest/readltl.cc, src/ltltest/parse.test, src/ltltest/parseerr.test, src/misc/Makefile.am, src/misc/const_sel.hh: New files.
This commit is contained in:
parent
ababb9ff93
commit
f0a8d0aeb3
46 changed files with 1818 additions and 0 deletions
3
src/ltlast/.cvsignore
Normal file
3
src/ltlast/.cvsignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
19
src/ltlast/Makefile.am
Normal file
19
src/ltlast/Makefile.am
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
AM_CPPFLAGS = -I$(srcdir)/..
|
||||
AM_CXXFLAGS = $(WARNING_CXXFLAGS)
|
||||
|
||||
lib_LIBRARIES = libltlast.a
|
||||
libltlast_a_SOURCES = \
|
||||
allnodes.hh \
|
||||
atomic_prop.cc \
|
||||
atomic_prop.hh \
|
||||
binop.cc \
|
||||
binop.hh \
|
||||
constant.cc \
|
||||
constant.hh \
|
||||
formulae.hh \
|
||||
multop.cc \
|
||||
multop.hh \
|
||||
predecl.hh \
|
||||
unop.cc \
|
||||
unop.hh
|
||||
|
||||
10
src/ltlast/allnodes.hh
Normal file
10
src/ltlast/allnodes.hh
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef SPOT_LTLAST_ALLNODES_HH
|
||||
# define SPOT_LTLAST_ALLNODES_HH
|
||||
|
||||
# include "binop.hh"
|
||||
# include "unop.hh"
|
||||
# include "multop.hh"
|
||||
# include "atomic_prop.hh"
|
||||
# include "constant.hh"
|
||||
|
||||
#endif // SPOT_LTLAST_ALLNODES_HH
|
||||
43
src/ltlast/atomic_prop.cc
Normal file
43
src/ltlast/atomic_prop.cc
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include "atomic_prop.hh"
|
||||
#include "visitor.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
|
||||
atomic_prop::atomic_prop(std::string name)
|
||||
: name_(name)
|
||||
{
|
||||
}
|
||||
|
||||
atomic_prop::~atomic_prop()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
atomic_prop::accept(visitor& v)
|
||||
{
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
void
|
||||
atomic_prop::accept(const_visitor& v) const
|
||||
{
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
bool
|
||||
atomic_prop::equals(const formulae* f) const
|
||||
{
|
||||
const atomic_prop* p = dynamic_cast<const atomic_prop*>(f);
|
||||
return p && p->name() == name();
|
||||
}
|
||||
|
||||
const std::string&
|
||||
atomic_prop::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
src/ltlast/atomic_prop.hh
Normal file
31
src/ltlast/atomic_prop.hh
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef SPOT_LTLAST_ATOMIC_PROP_HH
|
||||
# define SPOT_LTLAST_ATOMIC_PROP_HH
|
||||
|
||||
#include <string>
|
||||
#include "formulae.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
|
||||
class atomic_prop : public formulae
|
||||
{
|
||||
public:
|
||||
atomic_prop(std::string name);
|
||||
virtual ~atomic_prop();
|
||||
|
||||
virtual void accept(visitor& visitor);
|
||||
virtual void accept(const_visitor& visitor) const;
|
||||
|
||||
virtual bool equals(const formulae* f) const;
|
||||
|
||||
const std::string& name() const;
|
||||
private:
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPOT_LTLAST_ATOMICPROP_HH
|
||||
91
src/ltlast/binop.cc
Normal file
91
src/ltlast/binop.cc
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
#include <cassert>
|
||||
#include "binop.hh"
|
||||
#include "visitor.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
binop::binop(type op, formulae* first, formulae* second)
|
||||
: op_(op), first_(first), second_(second)
|
||||
{
|
||||
}
|
||||
|
||||
binop::~binop()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
binop::accept(visitor& v)
|
||||
{
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
void
|
||||
binop::accept(const_visitor& v) const
|
||||
{
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
const formulae*
|
||||
binop::first() const
|
||||
{
|
||||
return first_;
|
||||
}
|
||||
|
||||
formulae*
|
||||
binop::first()
|
||||
{
|
||||
return first_;
|
||||
}
|
||||
|
||||
const formulae*
|
||||
binop::second() const
|
||||
{
|
||||
return second_;
|
||||
}
|
||||
|
||||
formulae*
|
||||
binop::second()
|
||||
{
|
||||
return second_;
|
||||
}
|
||||
|
||||
bool
|
||||
binop::equals(const formulae* f) const
|
||||
{
|
||||
const binop* p = dynamic_cast<const binop*>(f);
|
||||
return p && p->op() == op()
|
||||
&& first()->equals(p->first())
|
||||
&& second()->equals(p->second());
|
||||
}
|
||||
|
||||
binop::type
|
||||
binop::op() const
|
||||
{
|
||||
return op_;
|
||||
}
|
||||
|
||||
const char*
|
||||
binop::op_name() 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
43
src/ltlast/binop.hh
Normal file
43
src/ltlast/binop.hh
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef SPOT_LTLAST_BINOP_HH
|
||||
# define SPOT_LTLAST_BINOP_HH
|
||||
|
||||
#include "formulae.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
|
||||
class binop : public formulae
|
||||
{
|
||||
public:
|
||||
// And and Or are not here. Because they
|
||||
// are often nested we represent them as multops.
|
||||
enum type { Xor, Implies, Equiv, U, R };
|
||||
|
||||
binop(type op, formulae* first, formulae* second);
|
||||
virtual ~binop();
|
||||
|
||||
virtual void accept(visitor& v);
|
||||
virtual void accept(const_visitor& v) const;
|
||||
|
||||
virtual bool equals(const formulae* f) const;
|
||||
|
||||
const formulae* first() const;
|
||||
formulae* first();
|
||||
const formulae* second() const;
|
||||
formulae* second();
|
||||
|
||||
type op() const;
|
||||
const char* op_name() const;
|
||||
|
||||
private:
|
||||
type op_;
|
||||
formulae* first_;
|
||||
formulae* second_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPOT_LTLAST_BINOP_HH
|
||||
59
src/ltlast/constant.cc
Normal file
59
src/ltlast/constant.cc
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#include "constant.hh"
|
||||
#include "visitor.hh"
|
||||
#include <cassert>
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
constant::constant(type val)
|
||||
: val_(val)
|
||||
{
|
||||
}
|
||||
|
||||
constant::~constant()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
constant::accept(visitor& v)
|
||||
{
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
void
|
||||
constant::accept(const_visitor& v) const
|
||||
{
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
bool
|
||||
constant::equals(const formulae* f) const
|
||||
{
|
||||
const constant* p = dynamic_cast<const constant*>(f);
|
||||
return p && p->val() == val();
|
||||
}
|
||||
|
||||
constant::type
|
||||
constant::val() const
|
||||
{
|
||||
return val_;
|
||||
}
|
||||
|
||||
const char*
|
||||
constant::val_name() const
|
||||
{
|
||||
switch (val_)
|
||||
{
|
||||
case True:
|
||||
return "1";
|
||||
case False:
|
||||
return "0";
|
||||
}
|
||||
// Unreachable code.
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
37
src/ltlast/constant.hh
Normal file
37
src/ltlast/constant.hh
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef SPOT_LTLAST_CONSTANT_HH
|
||||
# define SPOT_LTLAST_CONSTANT_HH
|
||||
|
||||
#include "formulae.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
|
||||
class constant : public formulae
|
||||
{
|
||||
public:
|
||||
enum type { False, True };
|
||||
|
||||
constant(type val);
|
||||
virtual ~constant();
|
||||
|
||||
virtual void accept(visitor& v);
|
||||
virtual void accept(const_visitor& v) const;
|
||||
|
||||
virtual bool equals(const formulae* h) const;
|
||||
|
||||
const formulae* child() const;
|
||||
formulae* child();
|
||||
|
||||
type val() const;
|
||||
const char* val_name() const;
|
||||
|
||||
private:
|
||||
type val_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPOT_LTLAST_CONSTANT_HH
|
||||
25
src/ltlast/formulae.hh
Normal file
25
src/ltlast/formulae.hh
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef SPOT_LTLAST_FORMULAE_HH
|
||||
# define SPOT_LTLAST_FORMULAE_HH
|
||||
|
||||
#include "predecl.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
|
||||
class formulae
|
||||
{
|
||||
public:
|
||||
virtual void accept(visitor& v) = 0;
|
||||
virtual void accept(const_visitor& v) const = 0;
|
||||
|
||||
virtual bool equals(const formulae* f) const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // SPOT_LTLAST_FORMULAE_HH
|
||||
111
src/ltlast/multop.cc
Normal file
111
src/ltlast/multop.cc
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
#include <cassert>
|
||||
#include <utility>
|
||||
#include "multop.hh"
|
||||
#include "visitor.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
multop::multop(type op, formulae* first, formulae* second)
|
||||
: op_(op), children_(2)
|
||||
{
|
||||
children_[0] = first;
|
||||
children_[1] = second;
|
||||
}
|
||||
|
||||
void
|
||||
multop::add(formulae* f)
|
||||
{
|
||||
children_.push_back(f);
|
||||
}
|
||||
|
||||
multop::~multop()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
multop::accept(visitor& v)
|
||||
{
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
void
|
||||
multop::accept(const_visitor& v) const
|
||||
{
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
unsigned
|
||||
multop::size() const
|
||||
{
|
||||
return children_.size();
|
||||
}
|
||||
|
||||
const formulae*
|
||||
multop::nth(unsigned n) const
|
||||
{
|
||||
return children_[n];
|
||||
}
|
||||
|
||||
formulae*
|
||||
multop::nth(unsigned n)
|
||||
{
|
||||
return children_[n];
|
||||
}
|
||||
|
||||
multop::type
|
||||
multop::op() const
|
||||
{
|
||||
return op_;
|
||||
}
|
||||
|
||||
bool
|
||||
multop::equals(const formulae* f) const
|
||||
{
|
||||
// This check is a bit more complicated than other checks
|
||||
// because And(a, b, c) is equal to And(c, a, b, a).
|
||||
const multop* p1 = dynamic_cast<const multop*>(f);
|
||||
if (!p1 || p1->op() != op())
|
||||
return false;
|
||||
|
||||
const multop* p2 = this;
|
||||
unsigned s1 = p1->size();
|
||||
unsigned s2 = p2->size();
|
||||
if (s1 > s2)
|
||||
{
|
||||
std::swap(s1, s2);
|
||||
std::swap(p1, p2);
|
||||
}
|
||||
|
||||
for (unsigned n1 = 0; n1 < s1; ++n1)
|
||||
{
|
||||
unsigned n2;
|
||||
for (n2 = 0; n2 < s2; ++n2)
|
||||
{
|
||||
if (p1->nth(n1)->equals(p2->nth(n2)))
|
||||
break;
|
||||
}
|
||||
if (n2 == s2)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const char*
|
||||
multop::op_name() const
|
||||
{
|
||||
switch (op_)
|
||||
{
|
||||
case And:
|
||||
return "And";
|
||||
case Or:
|
||||
return "Or";
|
||||
}
|
||||
// Unreachable code.
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
44
src/ltlast/multop.hh
Normal file
44
src/ltlast/multop.hh
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#ifndef SPOT_LTLAST_MULTOP_HH
|
||||
# define SPOT_LTLAST_MULTOP_HH
|
||||
|
||||
#include <vector>
|
||||
#include "formulae.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
|
||||
class multop : public formulae
|
||||
{
|
||||
public:
|
||||
enum type { Or, And };
|
||||
|
||||
// A multop has at least two arguments.
|
||||
multop(type op, formulae* first, formulae* second);
|
||||
// More argument can be added.
|
||||
void add(formulae* f);
|
||||
|
||||
virtual ~multop();
|
||||
|
||||
virtual void accept(visitor& v);
|
||||
virtual void accept(const_visitor& v) const;
|
||||
|
||||
virtual bool equals(const formulae* f) const;
|
||||
|
||||
unsigned size() const;
|
||||
const formulae* nth(unsigned n) const;
|
||||
formulae* nth(unsigned n);
|
||||
|
||||
type op() const;
|
||||
const char* op_name() const;
|
||||
|
||||
private:
|
||||
type op_;
|
||||
std::vector<formulae*> children_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPOT_LTLAST_MULTOP_HH
|
||||
18
src/ltlast/predecl.hh
Normal file
18
src/ltlast/predecl.hh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef SPOT_LTLAST_PREDECL_HH
|
||||
# define SPOT_LTLAST_PREDECL_HH
|
||||
|
||||
namespace spot {
|
||||
namespace ltl {
|
||||
struct visitor;
|
||||
struct const_visitor;
|
||||
|
||||
struct atomic_prop;
|
||||
struct unop;
|
||||
struct constant;
|
||||
struct binop;
|
||||
struct formulae;
|
||||
struct multop;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPOT_LTLAST_PREDECL_HH
|
||||
75
src/ltlast/unop.cc
Normal file
75
src/ltlast/unop.cc
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
#include "unop.hh"
|
||||
#include "visitor.hh"
|
||||
#include <cassert>
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
unop::unop(type op, formulae* child)
|
||||
: op_(op), child_(child)
|
||||
{
|
||||
}
|
||||
|
||||
unop::~unop()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
unop::accept(visitor& v)
|
||||
{
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
void
|
||||
unop::accept(const_visitor& v) const
|
||||
{
|
||||
v.visit(this);
|
||||
}
|
||||
|
||||
const formulae*
|
||||
unop::child() const
|
||||
{
|
||||
return child_;
|
||||
}
|
||||
|
||||
formulae*
|
||||
unop::child()
|
||||
{
|
||||
return child_;
|
||||
}
|
||||
|
||||
bool
|
||||
unop::equals(const formulae* f) const
|
||||
{
|
||||
const unop* p = dynamic_cast<const unop*>(f);
|
||||
return p && p->op() == op() && child()->equals(p->child());
|
||||
}
|
||||
|
||||
unop::type
|
||||
unop::op() const
|
||||
{
|
||||
return op_;
|
||||
}
|
||||
|
||||
const char*
|
||||
unop::op_name() 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
38
src/ltlast/unop.hh
Normal file
38
src/ltlast/unop.hh
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef SPOT_LTLAST_UNOP_HH
|
||||
# define SPOT_LTLAST_UNOP_HH
|
||||
|
||||
#include "formulae.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace ltl
|
||||
{
|
||||
|
||||
class unop : public formulae
|
||||
{
|
||||
public:
|
||||
enum type { Not, X, F, G };
|
||||
|
||||
unop(type op, formulae* child);
|
||||
virtual ~unop();
|
||||
|
||||
virtual void accept(visitor& v);
|
||||
virtual void accept(const_visitor& v) const;
|
||||
|
||||
virtual bool equals(const formulae* h) const;
|
||||
|
||||
const formulae* child() const;
|
||||
formulae* child();
|
||||
|
||||
type op() const;
|
||||
const char* op_name() const;
|
||||
|
||||
private:
|
||||
type op_;
|
||||
formulae* child_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPOT_LTLAST_UNOP_HH
|
||||
32
src/ltlast/visitor.hh
Normal file
32
src/ltlast/visitor.hh
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef SPOT_LTLAST_VISITOR_HH
|
||||
# define SPOT_LTLAST_VISITOR_HH
|
||||
|
||||
#include "predecl.hh"
|
||||
#include "misc/const_sel.hh"
|
||||
|
||||
namespace spot {
|
||||
namespace ltl {
|
||||
|
||||
template <bool WantConst>
|
||||
struct generic_visitor
|
||||
{
|
||||
virtual void visit(typename const_sel<atomic_prop, WantConst>::t* node)
|
||||
= 0;
|
||||
|
||||
virtual void visit(typename const_sel<constant, WantConst>::t* node)
|
||||
= 0;
|
||||
|
||||
virtual void visit(typename const_sel<binop, WantConst>::t* node) = 0;
|
||||
|
||||
virtual void visit(typename const_sel<unop, WantConst>::t* node) = 0;
|
||||
|
||||
virtual void visit(typename const_sel<multop, WantConst>::t* node) = 0;
|
||||
};
|
||||
|
||||
struct visitor : public generic_visitor<false> {};
|
||||
struct const_visitor : public generic_visitor<true> {};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPOT_LTLAST_VISITOR_HH
|
||||
Loading…
Add table
Add a link
Reference in a new issue