line_control.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___line_control_hh___included
00029 #define lestes__lang__cplus__lex___line_control_hh___included
00030 
00031 /*! \file
00032   \brief Line number control.
00033 
00034   Declaration of class line_control responsible for creating full location information
00035   from physical location and effects of #line directives.
00036   \author pt
00037 */
00038 #include <lestes/common.hh>
00039 
00040 package(lestes);
00041 
00042 package(std);
00043 // forward declaration to avoid cycle
00044 class file_info;
00045 class source_location;
00046 end_package(std);
00047 
00048 package(lang);
00049 package(cplus);
00050 package(lex);
00051 
00052 // forward declaration to avoid cycle
00053 class simple_location;
00054 
00055 /*!
00056   \brief Line number control.
00057   
00058   Performs translating physical location to full featured source location information.
00059   Handles line number and file name changes as of #line directive.
00060 */
00061 class line_control : public ::lestes::std::object {
00062 public:
00063         //! Translates physical location to source location.
00064         ptr<source_location> translate_location(const ptr<simple_location> &physical) const;
00065         //! Changes line numbering.
00066         void change_line(const ptr<source_location> &before, ulint line_number);
00067         //! Changes file name.
00068         void change_file(const lstring &file_name);
00069         //! Returns new instance, initializes with file information.
00070         static ptr<line_control> create(const ptr<file_info> &a_info);
00071 protected:
00072         //! Creates the object.
00073         line_control(const ptr<file_info> &a_info);
00074         //! Marks the object.
00075         virtual void gc_mark(void);
00076 private:
00077         //! The file information for locations.
00078         srp<file_info> file;
00079         //! The delta between physical and logical line number.
00080         ulint delta;
00081         //! Hides copy constructor.
00082         line_control(const line_control &);
00083         //! Hides assignment operator.
00084         line_control &operator=(const line_control &);
00085 };
00086 
00087 end_package(lex);
00088 end_package(cplus);
00089 end_package(lang);
00090 end_package(lestes);
00091 
00092 #endif
00093 /* vim: set ft=lestes : */

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