1 // 2 // aegis - project change supervisor 3 // Copyright (C) 1997, 2002, 2005-2008, 2012 Peter Miller 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program. If not, see 17 // <http://www.gnu.org/licenses/>. 18 // 19 20 #ifndef AEFIND_TREE_LOGICAL_H 21 #define AEFIND_TREE_LOGICAL_H 22 23 #include <aefind/tree/diadic.h> 24 #include <aefind/tree/monadic.h> 25 26 class tree_list; // forward 27 28 /** 29 * The tree_and class is used to represent an expression tree which 30 * performs a logical AND. 31 */ 32 class tree_and: 33 public tree_diadic 34 { 35 public: 36 /** 37 * The destructor. 38 */ 39 virtual ~tree_and(); 40 41 private: 42 /** 43 * The constructor. It is private on purpose, use the "create" 44 * clas smethod instead. 45 * 46 * @param left 47 * The left hand argument to this function. 48 * @param right 49 * The right hand argument to this function. 50 */ 51 tree_and(const pointer &left, const pointer &right); 52 53 public: 54 /** 55 * The create class method is used to create new dynamically 56 * allocated instance of this class. 57 * 58 * @param left 59 * The left hand argument to this function. 60 * @param right 61 * The right hand argument to this function. 62 */ 63 static pointer create(const pointer &left, const pointer &right); 64 65 /** 66 * The create_l class method is used to create new dynamically 67 * allocated instance of this class. 68 * 69 * @param args 70 * The arguments to this function. 71 */ 72 static pointer create_l(const tree_list &args); 73 74 protected: 75 // See base class for documentation. 76 const char *name() const; 77 78 // See base class for documentation. 79 rpt_value::pointer evaluate(string_ty *, string_ty *, string_ty *, 80 struct stat *) const; 81 82 // See base class for documentation. 83 tree::pointer optimize() const; 84 85 private: 86 /** 87 * The default constructor. Do not use. 88 */ 89 tree_and(); 90 91 /** 92 * The copy constructor. Do not use. 93 */ 94 tree_and(const tree_and &); 95 96 /** 97 * The assignment operator. Do not use. 98 */ 99 tree_and &operator=(const tree_and &); 100 }; 101 102 103 /** 104 * The tree_or class is used to represent an expression tree which 105 * performs a logical OR. 106 */ 107 class tree_or: 108 public tree_diadic 109 { 110 public: 111 /** 112 * The destructor. 113 */ 114 virtual ~tree_or(); 115 116 private: 117 /** 118 * The constructor. It is private on purpose, use the "create" 119 * clas smethod instead. 120 * 121 * @param left 122 * The left hand argument to this function. 123 * @param right 124 * The right hand argument to this function. 125 */ 126 tree_or(const pointer &left, const pointer &right); 127 128 public: 129 /** 130 * The create class method is used to create new dynamically 131 * allocated instance of this class. 132 * 133 * @param left 134 * The left hand argument to this function. 135 * @param right 136 * The right hand argument to this function. 137 */ 138 static pointer create(const pointer &left, const pointer &right); 139 140 /** 141 * The create_l class method is used to create new dynamically 142 * allocated instance of this class. 143 * 144 * @param args 145 * The arguments to this function. 146 */ 147 static pointer create_l(const tree_list &args); 148 149 protected: 150 // See base class for documentation. 151 const char *name() const; 152 153 // See base class for documentation. 154 rpt_value::pointer evaluate(string_ty *, string_ty *, string_ty *, 155 struct stat *) const; 156 157 // See base class for documentation. 158 tree::pointer optimize() const; 159 160 private: 161 /** 162 * The default constructor. Do not use. 163 */ 164 tree_or(); 165 166 /** 167 * The copy constructor. Do not use. 168 */ 169 tree_or(const tree_or &); 170 171 /** 172 * The assignment operator. Do not use. 173 */ 174 tree_or &operator=(const tree_or &); 175 }; 176 177 178 /** 179 * The tree_not class is used to represent an expression tree which 180 * evatuates to FUBAR 181 */ 182 class tree_not: 183 public tree_monadic 184 { 185 public: 186 /** 187 * The destructor. 188 */ 189 virtual ~tree_not(); 190 191 private: 192 /** 193 * The constructor. It is private on purpose, use the "create" 194 * clas smethod instead. 195 */ 196 tree_not(const pointer &arg); 197 198 public: 199 /** 200 * The create class method is used to create new dynamically 201 * allocated instance of this class. 202 * 203 * @param arg 204 * The singel argument to this function. 205 */ 206 static pointer create(const pointer &arg); 207 208 /** 209 * The create_l class method is used to create new dynamically 210 * allocated instance of this class. 211 * 212 * @param args 213 * The arguments to this function. 214 */ 215 static pointer create_l(const tree_list &args); 216 217 protected: 218 // See base class for documentation. 219 const char *name() const; 220 221 // See base class for documentation. 222 rpt_value::pointer evaluate(string_ty *, string_ty *, string_ty *, 223 struct stat *) const; 224 225 // See base class for documentation. 226 tree::pointer optimize() const; 227 228 private: 229 /** 230 * The default constructor. Do not use. 231 */ 232 tree_not(); 233 234 /** 235 * The copy constructor. Do not use. 236 */ 237 tree_not(const tree_not &); 238 239 /** 240 * The assignment operator. Do not use. 241 */ 242 tree_not &operator=(const tree_not &); 243 }; 244 245 246 /** 247 * The tree_comma class is used to represent an expression tree which 248 * performs a "comma" operator (discards the left value). 249 */ 250 class tree_comma: 251 public tree_diadic 252 { 253 public: 254 /** 255 * The destructor. 256 */ 257 virtual ~tree_comma(); 258 259 private: 260 /** 261 * The constructor. It is private on purpose, use the "create" 262 * clas smethod instead. 263 * 264 * @param left 265 * The left hand argument to this function. 266 * @param right 267 * The right hand argument to this function. 268 */ 269 tree_comma(const pointer &left, const pointer &right); 270 271 public: 272 /** 273 * The create class method is used to create new dynamically 274 * allocated instance of this class. 275 * 276 * @param left 277 * The left hand argument to this function. 278 * @param right 279 * The right hand argument to this function. 280 */ 281 static pointer create(const pointer &left, const pointer &right); 282 283 /** 284 * The create_l class method is used to create new dynamically 285 * allocated instance of this class. 286 * 287 * @param args 288 * The arguments to this function. 289 */ 290 static pointer create_l(const tree_list &args); 291 292 protected: 293 // See base class for documentation. 294 const char *name() const; 295 296 // See base class for documentation. 297 rpt_value::pointer evaluate(string_ty *, string_ty *, string_ty *, 298 struct stat *) const; 299 300 // See base class for documentation. 301 tree::pointer optimize() const; 302 303 private: 304 /** 305 * The default constructor. Do not use. 306 */ 307 tree_comma(); 308 309 /** 310 * The copy constructor. Do not use. 311 */ 312 tree_comma(const tree_comma &); 313 314 /** 315 * The assignment operator. Do not use. 316 */ 317 tree_comma &operator=(const tree_comma &); 318 }; 319 320 321 /** 322 * The tree_triadic class is used to represent an expression tree which 323 * performs a (a ? b : c) operation. 324 */ 325 class tree_triadic: 326 public tree 327 { 328 public: 329 /** 330 * The destructor. 331 */ 332 virtual ~tree_triadic(); 333 334 private: 335 /** 336 * The constructor. It is private on purpose, use the "create" 337 * clas smethod instead. 338 * 339 * @param a1 340 * The first argument to this function. 341 * @param a2 342 * The second argument to this function. 343 * @param a3 344 * The third argument to this function. 345 */ 346 tree_triadic(const pointer &a1, const pointer &a2, const pointer &a3); 347 348 public: 349 /** 350 * The create class method is used to create new dynamically 351 * allocated instance of this class. 352 * 353 * @param a1 354 * The first argument to this function. 355 * @param a2 356 * The second argument to this function. 357 * @param a3 358 * The third argument to this function. 359 */ 360 static pointer create(const pointer &a1, const pointer &a2, 361 const pointer &a3); 362 363 protected: 364 // See base class for documentation. 365 const char *name() const; 366 367 // See base class for documentation. 368 rpt_value::pointer evaluate(string_ty *, string_ty *, string_ty *, 369 struct stat *) const; 370 371 // See base class for documentation. 372 tree::pointer optimize() const; 373 374 // See base class for documentation. 375 void print() const; 376 377 // See base class for documentation. 378 bool useful() const; 379 380 // See base class for documentation. 381 bool constant() const; 382 383 private: 384 tree::pointer a1; 385 tree::pointer a2; 386 tree::pointer a3; 387 388 /** 389 * The default constructor. Do not use. 390 */ 391 tree_triadic(); 392 393 /** 394 * The copy constructor. Do not use. 395 */ 396 tree_triadic(const tree_triadic &); 397 398 /** 399 * The assignment operator. Do not use. 400 */ 401 tree_triadic &operator=(const tree_triadic &); 402 }; 403 404 #endif // AEFIND_TREE_LOGICAL_H 405 // vim: set ts=8 sw=4 et : 406