Commit 2a0f8837 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

* src/ltlenv/environment.hh (require): Return a formula, not

an atomic_prop.
* src/ltlast/atomic_prop.hh (atomic_prop): New argument env.
(environment_): New member.
(env): New method.
* src/ltlast/atomic_prop.cc (atomic_prop, env): Likewise.
* src/ltlenv/defaultenv.cc (require): Pass *this as the
environment argument to atomic_prop.
* src/ltlvisit/clone.cc (visit(const atomic_prop*)): Also copy
the environment.
* src/ltlvisit/nenoform.cc (visit(const atomic_prop*)): Likewise.
parent a30a0638
2003-04-17 Alexandre DURET-LUTZ <aduret@src.lip6.fr> 2003-04-17 Alexandre DURET-LUTZ <aduret@src.lip6.fr>
* src/ltlenv/environment.hh (require): Return a formula, not
an atomic_prop.
* src/ltlast/atomic_prop.hh (atomic_prop): New argument env.
(environment_): New member.
(env): New method.
* src/ltlast/atomic_prop.cc (atomic_prop, env): Likewise.
* src/ltlenv/defaultenv.cc (require): Pass *this as the
environment argument to atomic_prop.
* src/ltlvisit/clone.cc (visit(const atomic_prop*)): Also copy
the environment.
* src/ltlvisit/nenoform.cc (visit(const atomic_prop*)): Likewise.
* configure.ac: Output src/ltlenv/Makefile. * configure.ac: Output src/ltlenv/Makefile.
* src/ltlenv/Makefile.am, src/ltlenv/defaultenv.cc, * src/ltlenv/Makefile.am, src/ltlenv/defaultenv.cc,
src/ltlenv/defaultenv.hh, src/ltlenv/environment.hh: New files. src/ltlenv/defaultenv.hh, src/ltlenv/environment.hh: New files.
......
...@@ -6,8 +6,8 @@ namespace spot ...@@ -6,8 +6,8 @@ namespace spot
namespace ltl namespace ltl
{ {
atomic_prop::atomic_prop(std::string name) atomic_prop::atomic_prop(const std::string& name, environment& env)
: name_(name) : name_(name), env_(&env)
{ {
} }
...@@ -32,5 +32,12 @@ namespace spot ...@@ -32,5 +32,12 @@ namespace spot
{ {
return name_; return name_;
} }
environment&
atomic_prop::env() const
{
return *env_;
}
} }
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <string> #include <string>
#include "formula.hh" #include "formula.hh"
#include "ltlenv/environment.hh"
namespace spot namespace spot
{ {
...@@ -12,15 +13,17 @@ namespace spot ...@@ -12,15 +13,17 @@ namespace spot
class atomic_prop : public formula class atomic_prop : public formula
{ {
public: public:
atomic_prop(std::string name); atomic_prop(const std::string& name, environment& env);
virtual ~atomic_prop(); virtual ~atomic_prop();
virtual void accept(visitor& visitor); virtual void accept(visitor& visitor);
virtual void accept(const_visitor& visitor) const; virtual void accept(const_visitor& visitor) const;
const std::string& name() const; const std::string& name() const;
environment& env() const;
private: private:
std::string name_; std::string name_;
environment* env_;
}; };
} }
......
...@@ -5,10 +5,10 @@ namespace spot ...@@ -5,10 +5,10 @@ namespace spot
namespace ltl namespace ltl
{ {
atomic_prop* formula*
default_environment::require(const std::string& s) default_environment::require(const std::string& s)
{ {
return new atomic_prop(s); return new atomic_prop(s, *this);
} }
const std::string& const std::string&
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# define SPOT_LTLENV_DEFAULT_ENVIRONMENT_HH # define SPOT_LTLENV_DEFAULT_ENVIRONMENT_HH
# include "environment.hh" # include "environment.hh"
# include "ltlast/atomic_prop.hh"
namespace spot namespace spot
{ {
...@@ -11,7 +12,7 @@ namespace spot ...@@ -11,7 +12,7 @@ namespace spot
class default_environment : public environment class default_environment : public environment
{ {
public: public:
virtual atomic_prop* require(const std::string& prop_str); virtual formula* require(const std::string& prop_str);
virtual const std::string& name(); virtual const std::string& name();
/* This class is a singleton. */ /* This class is a singleton. */
......
#ifndef SPOT_LTLENV_ENVIRONMENT_HH #ifndef SPOT_LTLENV_ENVIRONMENT_HH
# define SPOT_LTLENV_ENVIRONMENT_HH # define SPOT_LTLENV_ENVIRONMENT_HH
# include "ltlast/atomic_prop.hh" # include "ltlast/formula.hh"
# include <string> # include <string>
namespace spot namespace spot
...@@ -16,7 +16,11 @@ namespace spot ...@@ -16,7 +16,11 @@ namespace spot
// described by prop_str. // described by prop_str.
// Note this is NOT a const method. Some environment will // Note this is NOT a const method. Some environment will
// "create" the atomic proposition when asked. // "create" the atomic proposition when asked.
virtual atomic_prop* require(const std::string& prop_str) = 0; // We return a formula instead of an atomic_prop, because this
// will allow nifty tricks (e.g., we could name formulae in an
// environment, and let the parser build a larger tree from
// these).
virtual formula* require(const std::string& prop_str) = 0;
virtual const std::string& name() = 0; virtual const std::string& name() = 0;
// FIXME: More functions will be needed later, but // FIXME: More functions will be needed later, but
......
...@@ -22,7 +22,7 @@ namespace spot ...@@ -22,7 +22,7 @@ namespace spot
void void
clone_visitor::visit(const atomic_prop* ap) clone_visitor::visit(const atomic_prop* ap)
{ {
result_ = new atomic_prop(ap->name()); result_ = new atomic_prop(ap->name(), ap->env());
} }
void void
......
...@@ -27,7 +27,7 @@ namespace spot ...@@ -27,7 +27,7 @@ namespace spot
void void
visit(const atomic_prop* ap) visit(const atomic_prop* ap)
{ {
formula* f = new atomic_prop(ap->name()); formula* f = new atomic_prop(ap->name(), ap->env());
if (negated_) if (negated_)
result_ = new unop(unop::Not, f); result_ = new unop(unop::Not, f);
else else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment