00001 // 00002 // aegis - project change supervisor 00003 // Copyright (C) 1994-1996, 2002-2008 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program. If not, see 00017 // <http://www.gnu.org/licenses/>. 00018 // 00019 00020 #ifndef AEGIS_AER_EXPR_H 00021 #define AEGIS_AER_EXPR_H 00022 00023 #include <common/ac/shared_ptr.h> 00024 #include <common/ac/stddef.h> 00025 00026 #include <libaegis/aer/pos.h> 00027 #include <libaegis/aer/value.h> 00028 00029 00034 class rpt_expr 00035 { 00036 public: 00037 typedef aegis_shared_ptr<rpt_expr> pointer; 00038 00042 virtual ~rpt_expr(); 00043 00044 protected: 00048 rpt_expr(); 00049 00050 public: 00055 void parse_error(const char *fmt) const; 00056 00061 void append(const rpt_expr::pointer &child); 00062 00067 void prepend(const rpt_expr::pointer &child); 00068 00079 rpt_value::pointer evaluate(bool undefer, bool dereference) const; 00080 00085 size_t get_nchildren() const { return nchild; } 00086 00091 rpt_position::pointer get_pos() const { return pos; } 00092 00097 void pos_from_lex(); 00098 00104 void pos_from(const rpt_expr::pointer &other); 00105 00106 protected: 00111 virtual rpt_value::pointer evaluate() const = 0; 00112 00113 public: 00122 virtual bool lvalue() const; 00123 00133 rpt_expr::pointer nth_child(size_t n) const; 00134 00135 private: 00140 rpt_position::pointer pos; 00141 00147 rpt_expr::pointer *child; 00148 00153 size_t nchild; 00154 00159 size_t nchild_max; 00160 00164 rpt_expr(const rpt_expr &); 00165 00169 rpt_expr &operator=(const rpt_expr &); 00170 }; 00171 00172 #endif // AEGIS_AER_EXPR_H