spot
0.9.1
|
00001 // Copyright (C) 2010, 2011, 2012 Laboratoire de Recherche et Développement 00002 // de l'Epita (LRDE). 00003 // 00004 // This file is part of Spot, a model checking library. 00005 // 00006 // Spot is free software; you can redistribute it and/or modify it 00007 // under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // Spot is distributed in the hope that it will be useful, but WITHOUT 00012 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00013 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 00014 // License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with Spot; see the file COPYING. If not, write to the Free 00018 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00019 // 02111-1307, USA. 00020 00023 #ifndef SPOT_LTLAST_BUNOP_HH 00024 # define SPOT_LTLAST_BUNOP_HH 00025 00026 #include <map> 00027 #include <iosfwd> 00028 #include "refformula.hh" 00029 #include "constant.hh" 00030 00031 namespace spot 00032 { 00033 namespace ltl 00034 { 00035 00038 class bunop : public ref_formula 00039 { 00040 public: 00041 enum type { Star }; 00042 00043 static const unsigned unbounded = -1U; 00044 00060 static const formula* instance(type op, 00061 const formula* child, 00062 unsigned min = 0, 00063 unsigned max = unbounded); 00064 00074 static const formula* sugar_goto(const formula* child, 00075 unsigned min = 1, 00076 unsigned max = unbounded); 00077 00084 static const formula* sugar_equal(const formula* child, 00085 unsigned min = 0, 00086 unsigned max = unbounded); 00087 00088 virtual void accept(visitor& v) const; 00089 00091 const formula* child() const; 00092 00094 unsigned min() const; 00096 unsigned max() const; 00097 00101 std::string format() const; 00102 00104 type op() const; 00106 const char* op_name() const; 00107 00109 virtual std::string dump() const; 00110 00112 static unsigned instance_count(); 00113 00115 static std::ostream& dump_instances(std::ostream& os); 00116 00122 static const formula* one_star() 00123 { 00124 if (!one_star_) 00125 one_star_ = instance(Star, constant::true_instance()); 00126 return one_star_; 00127 } 00128 00129 protected: 00130 typedef std::pair<unsigned, unsigned> pairu; 00131 typedef std::pair<type, const formula*> pairo; 00132 typedef std::pair<pairo, pairu> pair; 00133 typedef std::map<pair, const bunop*> map; 00134 static map instances; 00135 00136 bunop(type op, const formula* child, unsigned min, unsigned max); 00137 virtual ~bunop(); 00138 00139 private: 00140 type op_; 00141 const formula* child_; 00142 unsigned min_; 00143 unsigned max_; 00144 static const formula* one_star_; 00145 }; 00146 00151 inline 00152 const bunop* 00153 is_bunop(const formula* f) 00154 { 00155 if (f->kind() != formula::BUnOp) 00156 return 0; 00157 return static_cast<const bunop*>(f); 00158 } 00159 00164 inline 00165 const bunop* 00166 is_bunop(const formula* f, bunop::type op) 00167 { 00168 if (const bunop* bo = is_bunop(f)) 00169 if (bo->op() == op) 00170 return bo; 00171 return 0; 00172 } 00173 00177 inline 00178 const bunop* 00179 is_Star(const formula* f) 00180 { 00181 return is_bunop(f, bunop::Star); 00182 } 00183 00187 inline 00188 const bunop* 00189 is_KleenStar(const formula* f) 00190 { 00191 if (const bunop* b = is_Star(f)) 00192 if (b->min() == 0 && b->max() == bunop::unbounded) 00193 return b; 00194 return 0; 00195 } 00196 00197 } 00198 } 00199 #endif // SPOT_LTLAST_BUNOP_HH