concat.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___concat_hh___included
00029 #define lestes__lang__cplus__lex___concat_hh___included
00030 
00031 /*! \file
00032   \brief Token concatenator.
00033   
00034   Declaration of concat class wrapping concat_guts flexer.
00035   \author pt
00036 */
00037 #include <lestes/common.hh>
00038 #include <lestes/std/ucn_string.hh>
00039 #include <lestes/lang/cplus/lex/ucn_token.hh>
00040 
00041 package(lestes);
00042 package(lang);
00043 package(cplus);
00044 package(lex);
00045 
00046 package(concat_guts);
00047 //! Forward declaration of flex buffer type.
00048 struct yy_buffer_state;
00049 end_package(concat_guts);
00050 
00051 // forward declaration to avoid cycle
00052 class token_sequence;
00053 class pp_token;
00054 
00055 /*!
00056   \brief Token concatenator.
00057   
00058   Performs token concatenation.
00059   Handles integration with concat_guts flexer.
00060 */
00061 class concat: public ::lestes::std::object {
00062 public:
00063         //! Type of character in flex.
00064         typedef char char_type;
00065         //! Type of size in flex.
00066         typedef int size_type;
00067         //! Finalizes object.
00068         virtual ~concat(void);
00069         //! Stores next characters for YY_INPUT.
00070         size_type yy_input(char_type *cbuf, size_type max);
00071         //! Performs token concatenation.
00072         ptr<token_sequence> process(const ptr<pp_token> &left, const ptr<pp_token> &right);
00073         //! Returns the only instance.
00074         static ptr<concat> instance(void);
00075 protected:
00076         //! Creates the object.
00077         concat(void);
00078         //! Marks the object.
00079         virtual void gc_mark(void);
00080 private:
00081         //! Type of flex buffer.
00082         typedef struct concat_guts::yy_buffer_state *yy_buffer_type;
00083         //! Flex buffer.
00084         yy_buffer_type yy_buffer;
00085         //! Current value of input string.
00086         ucn_string value;
00087         //! Current index in the input.
00088         ucn_string::size_type index;
00089         //! Current length of the input.
00090         ucn_string::size_type length;
00091         //! Hides copy constructor.
00092         concat(const concat &copy);
00093         //! Hides assignment operator.
00094         concat &operator=(const concat &rhs);
00095         //! The only instance.
00096         static ptr<concat> singleton;
00097 };
00098 
00099 end_package(lex);
00100 end_package(cplus);
00101 end_package(lang);
00102 end_package(lestes);
00103 
00104 #endif
00105 /* vim: set ft=lestes : */

Generated on Mon Feb 12 18:27:05 2007 for lestes by doxygen 1.5.1-20070107