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___pre_lex_hh___included 00029 #define lestes__lang__cplus__lex___pre_lex_hh___included 00030 00031 /*! \file 00032 \brief Character level processing. 00033 00034 Declaration of pre_lex class performing operations before lexical analysis. 00035 \author pt 00036 */ 00037 00038 #include <lestes/common.hh> 00039 #include <lestes/lang/cplus/lex/ucn_token.hh> 00040 #include <lestes/lang/cplus/lex/data_source.hh> 00041 #include <lestes/lang/cplus/lex/encoder.hh> 00042 #include <lestes/lang/cplus/lex/special_tokens.hh> 00043 #include <lestes/lang/cplus/lex/line_numbers.hh> 00044 #include <lestes/lang/cplus/lex/trigraphs.hh> 00045 #include <lestes/lang/cplus/lex/line_join.hh> 00046 00047 package(lestes); 00048 package(lang); 00049 package(cplus); 00050 package(lex); 00051 00052 /*! 00053 \brief Character level processing. 00054 00055 Performs operations done prior to lexical analysis. 00056 */ 00057 class pre_lex: public ::lestes::std::object { 00058 public: 00059 //! Reads single token. 00060 ptr<ucn_token> read(void); 00061 //! Returns new instance, initializes with data source and encoder. 00062 static ptr<pre_lex> create(const ptr<data_source> &a_src, const ptr<encoder> &a_enc); 00063 protected: 00064 //! Creates new object, initializes with data source and encoder. 00065 pre_lex(const ptr<data_source> &a_src, const ptr<encoder> &a_enc); 00066 //! Marks the object. 00067 virtual void gc_mark(void); 00068 private: 00069 //! Connect all filters. 00070 void connect(void); 00071 //! Type of state. 00072 typedef enum { 00073 //! Starting state. 00074 START, 00075 //! Continuing state. 00076 CONT, 00077 //! Newline was read. 00078 NEWLINE, 00079 //! Error was returned. 00080 ERROR, 00081 //! EOF was read. 00082 END, 00083 } state_type; 00084 //! State of the object. 00085 state_type state; 00086 //! Saved token. 00087 srp<ucn_token> saved; 00088 //! Data source. 00089 srp<data_source> src; 00090 //! Source encoder. 00091 srp<encoder> enc; 00092 //! Special tokens translator. 00093 srp<special_tokens> stok; 00094 //! Line numbering. 00095 srp<line_numbers> lnum; 00096 //! Trigraph translator. 00097 srp<trigraphs> trig; 00098 //! Line joining. 00099 srp<line_join> ljoin; 00100 //! Hides copy constructor. 00101 pre_lex(const pre_lex ©); 00102 //! Hides assignment operator. 00103 pre_lex &operator=(const pre_lex &rhs); 00104 }; 00105 00106 end_package(lex); 00107 end_package(cplus); 00108 end_package(lang); 00109 end_package(lestes); 00110 00111 #endif 00112 /* vim: set ft=lestes : */
1.5.1-20070107