macro_item.hh

Go to the documentation of this file.
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_item_hh___included
00029 #define lestes__lang__cplus__lex___macro_item_hh___included
00030 
00031 /*! \file
00032   \brief Expansion list item.
00033   
00034   Declaration of macro_item class representing part of macro expansion list.
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 break cycle
00045 class pp_token;
00046 class token_sequence;
00047 
00048 /*!
00049   \brief Expansion list item.
00050 
00051   Represents of part of macro expansion list.
00052   Used as an element in macro_body.
00053 */
00054 class macro_item: public ::lestes::std::object {
00055 public:
00056         //! Type of action performed within the item.
00057         typedef enum {
00058                 //! Insert literal value.
00059                 LITERAL,
00060                 //! Insert expanded parameter.
00061                 EXPANSION,
00062                 //! Insert copy of parameter.
00063                 COPY,
00064                 //! Insert stringification of parameter.
00065                 STR,
00066                 //! Insert concatenation of adjacent tokens.
00067                 CONCAT
00068         } action_type;
00069         //! Type of index of macro parameter.
00070         typedef ulint index_type;
00071         //! Returns action to be performed.
00072         action_type action_get(void) const;
00073         //! Returns value of literal or glue token.
00074         ptr<token_sequence> value_get(void) const;
00075         //! Returns index of referenced macro parameter.
00076         index_type index_get(void) const;
00077         //! Returns blank flag.
00078         bool blank_get(void) const;
00079         //! Tests equality.
00080         bool equals(const ptr<macro_item> &other) const;
00081         //! Returns literal macro item.
00082         static ptr<macro_item> create_literal(const ptr<token_sequence> &a_value);
00083         //! Returns expansion macro item.
00084         static ptr<macro_item> create_expansion(index_type a_index);
00085         //! Returns copy macro item.
00086         static ptr<macro_item> create_copy(index_type a_index);
00087         //! Returns stringification macro item.
00088         static ptr<macro_item> create_str(index_type a_index, const ptr<token_sequence> &a_value);
00089         //! Returns concatenation macro item.
00090         static ptr<macro_item> create_concat(const ptr<token_sequence> &a_value);
00091 protected:
00092         //! Creates item.
00093         macro_item(action_type a_action, index_type a_index, const ptr<token_sequence> &a_value);
00094         //! Marks the object.
00095         virtual void gc_mark(void);
00096 private:
00097         //! Action to be performed.
00098         action_type action;
00099         //! Index of referenced macro parameter.
00100         index_type index;
00101         //! Value of literal or operation token wrapped in sequence.
00102         srp<token_sequence> value;
00103 };
00104 
00105 end_package(lex);
00106 end_package(cplus);
00107 end_package(lang);
00108 end_package(lestes);
00109 
00110 #endif
00111 /* vim: set ft=lestes : */

Generated on Mon Feb 12 18:22:40 2007 for lestes by doxygen 1.5.1-20070107