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___macro_argument_hh___included 00029 #define lestes__lang__cplus__lex___macro_argument_hh___included 00030 00031 /*! \file 00032 \brief Macro argument. 00033 00034 Declaration of macro_argument class representing preprocessor macro argument. 00035 \author pt 00036 */ 00037 #include <lestes/common.hh> 00038 00039 package(lestes); 00040 package(lang); 00041 package(cplus); 00042 package(lex); 00043 00044 // forward declaration to avoid cycle 00045 class token_input; 00046 class token_sequence; 00047 class macro_storage; 00048 00049 /*! 00050 \brief Macro argument. 00051 00052 Encapsulates macro argument with lazy evaluation. 00053 Provides nonexpanded, expanded and stringified representation 00054 of the argument. 00055 */ 00056 class macro_argument: public ::lestes::std::object { 00057 public: 00058 //! Type of internal state. 00059 typedef enum { BEGIN, PARSED, DEAD } state_type; 00060 //! Parse result type. 00061 typedef enum { 00062 //! The arguments will continue. 00063 CONTINUE, 00064 //! The last argument in the list. 00065 LAST, 00066 //! Error in argument. 00067 ERROR, 00068 //! The first argument is empty. 00069 EMPTY 00070 } result_type; 00071 //! Parses argument. 00072 result_type parse(const ptr<token_input> &input, bool first); 00073 //! Returns internal state. 00074 state_type state_get(void) const; 00075 //! Returns nonexpanded argument. 00076 ptr<token_sequence> nonexpanded_get(void) const; 00077 //! Returns expanded argument. 00078 ptr<token_sequence> expanded_get(const ptr<macro_storage> ¯os); 00079 //! Returns stringified argument. 00080 ptr<token_sequence> stringified_get(void); 00081 //! Test equality. 00082 bool equals(const ptr<macro_argument> &other) const; 00083 //! Returns new instance. 00084 static ptr<macro_argument> create(void); 00085 protected: 00086 //! Creates empty object. 00087 macro_argument(void); 00088 //! Marks the object. 00089 virtual void gc_mark(void); 00090 private: 00091 //! Internal state of the object. 00092 state_type state; 00093 //! The nonexpanded sequence. 00094 srp<token_sequence> nonexpanded; 00095 //! The expanded sequence, lazy evaluated. 00096 srp<token_sequence> expanded; 00097 //! The stringified sequence as a token in sequence, lazy evaluated. 00098 srp<token_sequence> stringified; 00099 }; 00100 00101 end_package(lex); 00102 end_package(cplus); 00103 end_package(lang); 00104 end_package(lestes); 00105 #endif 00106 /* vim: set ft=lestes : */
1.5.1-20070107