unit_part.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___unit_part_hh___included
00029 #define lestes__lang__cplus__lex___unit_part_hh___included
00030 
00031 /*! \file
00032   \brief Part of translation unit.
00033 
00034   Declaration of unit_part class representing a part of the translation unit.
00035   \author pt
00036 */
00037 #include <lestes/common.hh>
00038 #include <lestes/lang/cplus/lex/pp_filter.hh>
00039 
00040 package(lestes);
00041 
00042 package(std);
00043 // forward declarations to avoid cycle
00044 class source_location;
00045 class file_info;
00046 end_package(std);
00047 
00048 package(lang);
00049 package(cplus);
00050 package(lex);
00051 
00052 // forward declaration to break cycle
00053 class pp_token;
00054 class data_source;
00055 class encoder;
00056 class pre_lex;
00057 class pp_lex;
00058 class expander;
00059 class condition_stack;
00060 class macro_storage;
00061 class line_control;
00062 
00063 /*!
00064   \brief Part of translation unit.
00065 
00066   Represents a part of translation unit, which is either the original
00067   source file itself, or any file included by the source file.
00068 */
00069 class unit_part: public pp_filter {
00070 public:
00071         //! Sets start of line flag.
00072         void start_of_line(void);
00073         // TODO pt remove
00074         //! Activates connection to flex before start of reading.
00075         //void activate(void);
00076         //! Returns associated condition stack.
00077         ptr<condition_stack> conditions_get(void) const;
00078         //! Returs associated expander.
00079         ptr<expander> expander_get(void) const;
00080         //! Returs the line control.
00081         ptr<line_control> line_control_get(void) const;
00082         /* TODO pt remove
00083         //! Updates line information.
00084         void line_change(lstring file_name, ulint a_line);
00085         */
00086         //! Reads next token.
00087         ptr<pp_token> read(void);
00088         //! Returns new unit, initializes with file information, data source and encoder.
00089         static ptr<unit_part> create(const ptr<file_info> &a_file,
00090                         const ptr<data_source> &a_data, const ptr<encoder> &a_encoder, 
00091                         const ptr<macro_storage> &a_macros);
00092 protected:
00093         //! Creates new unit, initializes with file information, data source and encoding.
00094         unit_part(const ptr<file_info> &a_file, 
00095                 const ptr<data_source> &a_data, const ptr<encoder> &a_encoder,
00096                 const ptr<macro_storage> &a_macros);
00097         //! Marks the object.
00098         virtual void gc_mark(void);
00099 private:
00100         // TODO pt add representation of file name and path (for nested includes)
00101         // TODO pt remove
00102         //! The base location.
00103         //srp<source_location> location;
00104         //! Start of line flag.
00105         bool start;
00106         //! Conditions stack.
00107         srp<condition_stack> conditions;
00108         //! Character set encoder.
00109         srp<encoder> enc;
00110         //! Data source.
00111         srp<data_source> ds;
00112         //! Operations prior to lexical analysis.
00113         srp<pre_lex> plx;
00114         //! Line control.
00115         srp<line_control> lic;
00116         //! Flex wrapper.
00117         srp<pp_lex> ppl;
00118         //! Expander.
00119         srp<expander> exp;
00120         //! Hides copy constructor.
00121         unit_part(const unit_part &);
00122         //! Hides assignment operator.
00123         unit_part &operator=(const unit_part &);
00124 };
00125 
00126 end_package(lex);
00127 end_package(cplus);
00128 end_package(lang);
00129 end_package(lestes);
00130 
00131 #endif
00132 /* vim: set ft=lestes : */

Generated on Mon Feb 12 18:23:44 2007 for lestes by doxygen 1.5.1-20070107