string_joiner.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___string_joiner_hh___included
00029 #define lestes__lang__cplus__lex___string_joiner_hh___included
00030 
00031 /*! \file
00032   \brief String literal joining filter.
00033 
00034   Declaration of string_joiner class performing joining of string literals.
00035   \author pt
00036 */
00037 #include <lestes/common.hh> 
00038 #include <lestes/std/vector.hh> 
00039 #include <lestes/lang/cplus/lex/pp_filter.hh>
00040 #include <lestes/lang/cplus/lex/pp_token.hh>
00041 
00042 package(lestes);
00043 package(lang);
00044 package(cplus);
00045 package(lex);
00046 
00047 /*!
00048   \brief String literal joining filter.
00049   
00050   Performs joining of adjacent string literals and adjacent wide string literals.
00051 */
00052 class string_joiner: public pp_filter {
00053 public:
00054         //! Reads next token.
00055         ptr<pp_token> read(void);
00056         //! Returns new instance.
00057         static ptr<string_joiner> create(const ptr<pp_filter> &a_input);
00058 protected:
00059         //! Creates the object.
00060         string_joiner(const ptr<pp_filter> &a_input);
00061         //! Marks the object.
00062         virtual void gc_mark(void);
00063 private:
00064         //! States of the processor.
00065         typedef enum {
00066                 //! No tokens in buffer.
00067                 START = 0,
00068                 //! Read first string.
00069                 FIRST_STRING = 1,
00070                 //! Reading string sequence.
00071                 NEXT_STRING = 2,
00072                 //! Read first wide string.
00073                 FIRST_WIDE_STRING = 3,
00074                 //! Reading wide string sequence.
00075                 NEXT_WIDE_STRING = 4,
00076                 //! Reading mixed string and wide string sequence.
00077                 NEXT_BAD_STRING = 5,
00078                 //! Ordinary token saved in buffer.
00079                 SAVED = 6,
00080         } state_type;
00081         //! Type of sequence of adjacent literals.
00082         typedef ::lestes::std::vector< srp<pp_token> > sequence_type;
00083         //! Current state of the processor.
00084         state_type state;
00085         //! Buffered token.
00086         srp<pp_token> saved;
00087         //! Current sequence of adjacent literals.
00088         srp<sequence_type> sequence;
00089         //! Returns joined string literal.
00090         ptr<pp_token> join_sequence(pp_token_type ptt) const;
00091         //! Hides copy constructor.
00092         string_joiner(const string_joiner &);
00093         //! Hides assignment operator.
00094         string_joiner &operator=(const string_joiner &);
00095 };
00096 
00097 end_package(lex);
00098 end_package(cplus);
00099 end_package(lang);
00100 end_package(lestes);
00101 
00102 #endif
00103 /* vim: set ft=lestes : */

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