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___token_input_hh___included 00029 #define lestes__lang__cplus__lex___token_input_hh___included 00030 00031 /*! \file 00032 \brief Abstract input of tokens. 00033 00034 Declaration of token_input class representing abstract input of tokens. 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 end_package(std); 00046 00047 package(lang); 00048 package(cplus); 00049 package(lex); 00050 00051 // forward declaration to break cycle 00052 class pp_token; 00053 class token_sequence; 00054 class macro_storage; 00055 00056 /*! 00057 \brief Abstract input of tokens. 00058 00059 Represents abstract input of tokens, which also behaves as pp_filter. 00060 Provides sequential access at front and expansion of lines. 00061 */ 00062 class token_input: public pp_filter { 00063 public: 00064 //! Returns front token. 00065 virtual ptr<pp_token> peek_front(void) abstract; 00066 //! Reads front token, squeezing whitespace. 00067 virtual ptr<pp_token> read_front(void) abstract; 00068 //! Reads front token, skipping front whitespace, but not newline. 00069 virtual ptr<pp_token> read_front_skip_ws(void) abstract; 00070 //! Skips front whitespace. 00071 virtual bool skip_front_ws(void) abstract; 00072 protected: 00073 //! Creates object, initializes with no input. 00074 inline token_input(void); 00075 //! Creates object, initializes with input. 00076 inline token_input(const ptr<pp_filter> &a_input); 00077 private: 00078 //! Hides copy constructor. 00079 token_input(const token_input &); 00080 //! Hides assignment operator. 00081 token_input &operator=(const token_input &); 00082 }; 00083 00084 /*! 00085 Creates the object, initializes with no input. 00086 Useful when the data is stored directly in the object. 00087 */ 00088 inline token_input::token_input(void): 00089 pp_filter() 00090 { 00091 } 00092 00093 /*! 00094 Creates the object, initializes with input. 00095 \pre a_input != NULL 00096 \param a_input The input to read from. 00097 */ 00098 inline token_input::token_input(const ptr<pp_filter> &a_input): 00099 pp_filter(checked(a_input)) 00100 { 00101 } 00102 00103 end_package(lex); 00104 end_package(cplus); 00105 end_package(lang); 00106 end_package(lestes); 00107 #endif 00108 /* vim: set ft=lestes : */
1.5.1-20070107