expander.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___expander_hh___included
00029 #define lestes__lang__cplus__lex___expander_hh___included
00030 
00031 /*! \file
00032   \brief Macro expander.
00033   
00034   Declaration of expander class performing macro expansion.
00035   \author pt
00036 */
00037 #include <lestes/common.hh>
00038 package(lestes);
00039 package(lang);
00040 package(cplus);
00041 package(lex);
00042 
00043 // forward declaration to break cycle
00044 class token_sequence;
00045 class macro_storage;
00046 class pp_filter;
00047 class token_stream;
00048 
00049 /*!
00050   \brief Macro expander.
00051 
00052   Performs reading of possibly expanded lines of tokens.
00053 */
00054 class expander: public ::lestes::std::object {
00055 public:
00056         //! The modes of input.
00057         typedef enum {
00058                 //! Normal mode.
00059                 NORMAL,
00060                 //! Directive.
00061                 DIRECTIVE,
00062                 //! End of file.
00063                 FILE_END
00064         } mode_type;
00065         //! Reads line from input.
00066         ptr<token_sequence> read_line(void);
00067         //! Reads expanded line from input.
00068         ptr<token_sequence> read_expanded(void);
00069         //! Returns input mode.
00070         mode_type mode_get(void);
00071         //! Returns new expander.
00072         static ptr<expander> create(const ptr<pp_filter> &a_input, const ptr<macro_storage> &a_macros);
00073 protected:
00074         //! Creates new expander.
00075         expander(const ptr<pp_filter> &a_input, const ptr<macro_storage> &a_macros);
00076         //! Marks the object.
00077         virtual void gc_mark(void);
00078 private:
00079         //! The macro storage for expansion.
00080         srp<macro_storage> macros;
00081         //! The stream connected to input.
00082         srp<token_stream> stream;
00083 };
00084 
00085 end_package(lex);
00086 end_package(cplus);
00087 end_package(lang);
00088 end_package(lestes);
00089 #endif
00090 /* vim: set ft=lestes : */

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