macro_body.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_body_hh___included
00029 #define lestes__lang__cplus__lex___macro_body_hh___included
00030 
00031 /*! \file
00032         Definition of macro_body class representing macro expansion list.
00033         \author pt
00034 */
00035 
00036 #include <lestes/common.hh>
00037 #include <lestes/lang/cplus/lex/macro_item.hh>
00038 #include <lestes/std/vector.hh>
00039 
00040 package(lestes);
00041 
00042 package(std);
00043 // forward declarations to avoid cycle
00044 class source_location;
00045 end_package(std);
00046 
00047 package(lang);
00048 package(cplus);
00049 package(lex);
00050 
00051 // forward declarations to avoid cycle
00052 class token_input;
00053 class token_sequence;
00054 class macro_head;
00055 class macro_arguments;
00056 class macro_storage;
00057 
00058 /*!
00059   Representation of macro expansion list.
00060 */
00061 class macro_body: public ::lestes::std::object {
00062 public:
00063         //! type of internal state
00064         typedef enum { BEGIN, PARSED, DEAD } state_type;
00065         //! parses object-like macro body
00066         bool parse(const ptr<token_input> &input);
00067         //! parses function-like macro body
00068         bool parse(const ptr<token_input> &input, const ptr<macro_head> &head);
00069         //! expands object-like macro 
00070         ptr<token_sequence> expand(const ptr<source_location> &loc);
00071         //! expands function-like macro
00072         ptr<token_sequence> expand(const ptr<source_location> &loc, 
00073                         const ptr<macro_arguments> &mas, const ptr<macro_storage> &macros);
00074         //! returns internal state
00075         state_type state_get(void) const;
00076         //! tests equality
00077         bool equals(const ptr<macro_body> &other) const;
00078         //! returns empty expansion list
00079         static ptr<macro_body> create(void);
00080 protected:
00081         //! creates empty expansion list
00082         macro_body(void);
00083         //! Marks the object.
00084         virtual void gc_mark(void);
00085 private:
00086         //! type of list for storing the expansion items
00087         typedef ::lestes::std::vector< srp<macro_item> > items_type;
00088         //! internal state of the object
00089         state_type state;
00090         //! the list of expansion items
00091         srp<items_type> items;
00092 };
00093 
00094 end_package(lex);
00095 end_package(cplus);
00096 end_package(lang);
00097 end_package(lestes);
00098 
00099 #endif
00100 /* vim: set ft=lestes : */

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