00001 /* 00002 The lestes compiler suite 00003 Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy 00004 Copyright (C) 2002, 2003, 2004, 2005 Petr Zika 00005 Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala 00006 Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina 00007 Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda 00008 Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar 00009 Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas 00010 00011 This program is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation; version 2 of the License. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 See the full text of the GNU General Public License version 2, and 00021 the limitations in the file doc/LICENSE. 00022 00023 By accepting the license the licensee waives any and all claims 00024 against the copyright holder(s) related in whole or in part to the 00025 work, its use, and/or the inability to use it. 00026 00027 */ 00028 #ifndef lestes__lang__cplus__lex___condition_hh___included 00029 #define lestes__lang__cplus__lex___condition_hh___included 00030 00031 /*! \file 00032 \brief Conditional directive. 00033 00034 Declaration of condition class representing conditional 00035 preprocessor directives. 00036 \author pt 00037 */ 00038 #include <lestes/common.hh> 00039 package(lestes); 00040 00041 package(std); 00042 // forward declaration to break cycle 00043 class source_location; 00044 end_package(std); 00045 00046 package(lang); 00047 package(cplus); 00048 package(lex); 00049 00050 /*! 00051 \brief Conditional directive. 00052 00053 Represents conditional preprocessor directive for use within condition_stack. 00054 Contains location in the source, type and state of processing. 00055 */ 00056 class condition: public ::lestes::std::object { 00057 public: 00058 //! Types of conditions. 00059 typedef enum { 00060 //! Empty, bottom stack entry. 00061 COND_EMPTY = 0, 00062 //! Directive #if. 00063 COND_IF = 1, 00064 //! Directive #ifdef. 00065 COND_IFDEF = 2, 00066 //! Directive #ifndef. 00067 COND_IFNDEF = 3, 00068 //! Directive #elif. 00069 COND_ELIF = 4, 00070 //! Directive #else. 00071 COND_ELSE = 5 00072 } type_type; 00073 //! Returns location. 00074 ptr<source_location> location_get(void) const; 00075 //! Returns type. 00076 type_type type_get(void) const; 00077 //! Return whether waiting for true branch. 00078 bool waiting_get(void) const; 00079 //! Return whether the output was active. 00080 bool active_get(void) const; 00081 //! Returns printable name. 00082 lstring name_get(void) const; 00083 //! Tests equality. 00084 bool equals(const ptr<condition> &other) const; 00085 //! Returns empty condition. 00086 static ptr<condition> create_empty(void); 00087 //! Returns condition. 00088 static ptr<condition> create(type_type a_cond, bool a_waitning, bool a_active, const ptr<source_location> &a_location); 00089 protected: 00090 //! Creates empty condition. 00091 condition(void); 00092 //! Creates new condition. 00093 condition(type_type a_cond, bool a_waitning, bool a_active, const ptr<source_location> &a_location); 00094 //! Marks the object. 00095 virtual void gc_mark(void); 00096 private: 00097 //! Type of the condition. 00098 type_type type; 00099 //! Waiting for the true branch of conditional. 00100 bool waiting; 00101 //! Output is active after leaving the conditional on this level. 00102 bool active; 00103 //! Location of usage. 00104 srp<source_location> location; 00105 //! Names of the conditions. 00106 static lstring condition_name[]; 00107 //! Hides copy constructor. 00108 condition(const condition ©); 00109 //! Hides assignment operator. 00110 condition &operator=(const condition &rhs); 00111 }; 00112 00113 end_package(lex); 00114 end_package(cplus); 00115 end_package(lang); 00116 end_package(lestes); 00117 00118 #endif 00119 /* vim: set ft=lestes : */
1.5.1-20070107