ct_common  1.0.1
Common library for combinatorial testing
src/ct_common/file_parse/ct_lexer-token.hpp
Go to the documentation of this file.
00001 /* -*- C++ -*-   vim: set syntax=cpp: 
00002  * (C) 2004-2009 Frank-Rene Schaefer
00003  * ABSOLUTELY NO WARRANTY
00004  */
00005 #ifndef __QUEX_INCLUDE_GUARD__TOKEN__GENERATED____CT____LEXER_TOKEN
00006 #define __QUEX_INCLUDE_GUARD__TOKEN__GENERATED____CT____LEXER_TOKEN
00007 
00008 #include <quex/code_base/definitions>
00009 #include <quex/code_base/asserts>
00010 #include <quex/code_base/compatibility/stdint.h>
00011 
00012 /* LexemeNull object may be used for 'take_text'. */
00013 QUEX_NAMESPACE_LEXEME_NULL_OPEN
00014 extern QUEX_TYPE_CHARACTER   QUEX_LEXEME_NULL_IN_ITS_NAMESPACE;
00015 QUEX_NAMESPACE_LEXEME_NULL_CLOSE
00016 
00017 
00018 
00019 #   line 2 "quex/code_base/token/CppDefault.qx"
00020 
00021 #       include <iostream>
00022 #       include <string>
00023 
00024 #include <quex/code_base/converter_helper/identity>
00025    
00026 
00027 #   line 28 "ct_lexer-token.hpp"
00028 
00029  
00030 namespace ct {
00031 
00032 
00033 class lexer_Token;
00034 
00035 /* NOTE: The following function might have to be defined by the user if one
00036  *       does not rely on quex's function generation.                        */
00037 extern const char*  QUEX_NAME_TOKEN(map_id_to_name)(const QUEX_TYPE_TOKEN_ID);
00038 
00039 inline void    QUEX_NAME_TOKEN(construct)(lexer_Token* __this);
00040 inline void    QUEX_NAME_TOKEN(destruct)(lexer_Token* __this);
00041 inline void    QUEX_NAME_TOKEN(copy)(lexer_Token* me, const lexer_Token* That);
00042 inline bool    QUEX_NAME_TOKEN(take_text)(lexer_Token*            __this, 
00043                                           QUEX_TYPE_ANALYZER*         analyzer, 
00044                                           const QUEX_TYPE_CHARACTER*  Begin, 
00045                                           const QUEX_TYPE_CHARACTER*  End);
00046 
00047 #ifdef QUEX_OPTION_TOKEN_REPETITION_SUPPORT
00048 inline size_t  QUEX_NAME_TOKEN(repetition_n_get)(lexer_Token* __this);
00049 inline void    QUEX_NAME_TOKEN(repetition_n_set)(lexer_Token* __this, size_t N);
00050 #endif 
00051 
00052 class lexer_Token {
00053 public:
00054     lexer_Token();
00055     lexer_Token(const lexer_Token& That);
00056     /* operator=(..): USE WITH CAUTION--POSSIBLE MAJOR PERFORMANCE DECREASE! 
00057      *                BETTER USE __copy(That)                                */
00058     lexer_Token& operator=(const lexer_Token& That) 
00059     { QUEX_NAME_TOKEN(copy)(this, &That); return *this; }
00060     virtual ~lexer_Token();
00061 
00062 
00063 #   line 12 "quex/code_base/token/CppDefault.qx"
00064     std::basic_string<QUEX_TYPE_CHARACTER> text;
00065 #   line 13 "quex/code_base/token/CppDefault.qx"
00066     size_t                                 number;
00067 #   line 68 "ct_lexer-token.hpp"
00068 
00069 
00070 public:
00071 
00072 #   line 12 "quex/code_base/token/CppDefault.qx"
00073     std::basic_string<QUEX_TYPE_CHARACTER> get_text() const                                         { return text; }
00074 #   line 12 "quex/code_base/token/CppDefault.qx"
00075     void                                   set_text(std::basic_string<QUEX_TYPE_CHARACTER>& Value)  { text = Value; }
00076 #   line 13 "quex/code_base/token/CppDefault.qx"
00077     size_t                                 get_number() const                                       { return number; }
00078 #   line 13 "quex/code_base/token/CppDefault.qx"
00079     void                                   set_number(size_t Value)                                 { number = Value; }
00080 #   line 81 "ct_lexer-token.hpp"
00081 
00082     void set(const QUEX_TYPE_TOKEN_ID ID) { _id = ID; }
00083     void set(const QUEX_TYPE_TOKEN_ID ID, const std::basic_string<QUEX_TYPE_CHARACTER>& Value0)
00084     { _id = ID; text = Value0; }
00085     void set(const QUEX_TYPE_TOKEN_ID ID, const size_t& Value0)
00086     { _id = ID; number = Value0; }
00087     void set(const QUEX_TYPE_TOKEN_ID ID, const std::basic_string<QUEX_TYPE_CHARACTER>& Value0, const size_t& Value1)
00088     { _id = ID; text = Value0; number = Value1; }
00089 
00090 
00091     public:
00092         /* _line_n, _column_n, and _id are public, so that the token policy 
00093          * can access it. making it private would imply complications for 
00094          * user customized token classes. The token policies should be the
00095          * same for C and Cpp.                                               */
00096         QUEX_TYPE_TOKEN_ID    _id;
00097         QUEX_TYPE_TOKEN_ID    type_id() const                             { return _id; }
00098         const char*           map_id_to_name(QUEX_TYPE_TOKEN_ID ID) const { return QUEX_NAME_TOKEN(map_id_to_name)(ID); }
00099         const std::string     type_id_name() const                        { return map_id_to_name(_id); }
00100 
00101 #   ifdef     QUEX_OPTION_TOKEN_STAMPING_WITH_LINE_AND_COLUMN
00102 #       ifdef QUEX_OPTION_LINE_NUMBER_COUNTING
00103     public:
00104         QUEX_TYPE_TOKEN_LINE_N    _line_n;
00105         QUEX_TYPE_TOKEN_LINE_N    line_number() const                                 { return _line_n; }
00106         void                      set_line_number(const QUEX_TYPE_TOKEN_LINE_N Value) { _line_n = Value; }
00107 #       endif
00108 #       ifdef  QUEX_OPTION_COLUMN_NUMBER_COUNTING
00109     public:
00110         QUEX_TYPE_TOKEN_COLUMN_N  _column_n;
00111         QUEX_TYPE_TOKEN_COLUMN_N  column_number() const                                   { return _column_n; }
00112         void                      set_column_number(const QUEX_TYPE_TOKEN_COLUMN_N Value) { _column_n = Value; }
00113 #       endif
00114 #   endif
00115     public:
00116 #   define self (*this)
00117 
00118 #   line 32 "quex/code_base/token/CppDefault.qx"
00119 
00120         typedef std::basic_string<QUEX_TYPE_CHARACTER> __string;
00121 
00122         operator 
00123         const std::string() const
00124         { return get_string(); }
00125 
00126         const std::string
00127         get_string() const 
00128         {
00129             std::string             tmp;
00130 
00131             tmp = map_id_to_name(self._id);
00132 
00133             tmp += " '" + pretty_char_text() + "' ";
00134 
00135             return tmp;
00136         }
00137     
00138         const std::string 
00139         pretty_char_text() const
00140         {
00141             std::string             tmp = QUEX_CONVERTER_STRING(identical,char)(self.text);
00142             std::string::size_type  pos = 0;
00143 
00144             while( (pos = tmp.find("\n") ) != __string::npos ) tmp.replace(pos, (size_t)1, "\\n");
00145             while( (pos = tmp.find("\t") ) != __string::npos ) tmp.replace(pos, (size_t)1, "\\t");
00146             while( (pos = tmp.find("\r") ) != __string::npos ) tmp.replace(pos, (size_t)1, "\\r");
00147 
00148             return tmp;
00149         }
00150 
00151 #       if ! defined(__QUEX_OPTION_WCHAR_T_DISABLED)
00152         const std::wstring 
00153         pretty_wchar_text() const
00154         {
00155             std::wstring             tmp = QUEX_CONVERTER_STRING(identical,wchar)(self.text);
00156             std::wstring::size_type  pos = 0;
00157 
00158             while( (pos = tmp.find(L"\n") ) != __string::npos ) tmp.replace(pos, (size_t)1, L"\\n");
00159             while( (pos = tmp.find(L"\t") ) != __string::npos ) tmp.replace(pos, (size_t)1, L"\\t");
00160             while( (pos = tmp.find(L"\r") ) != __string::npos ) tmp.replace(pos, (size_t)1, L"\\r");
00161 
00162             return tmp;
00163         }
00164 #       endif
00165    
00166 
00167 #   line 168 "ct_lexer-token.hpp"
00168 
00169 #   undef  self
00170 
00171     private:
00172         friend void QUEX_NAME_TOKEN(copy)(lexer_Token* me, const lexer_Token* That);
00173         friend bool QUEX_NAME_TOKEN(take_text)(lexer_Token*               __this, 
00174                                                QUEX_TYPE_ANALYZER*         analyzer, 
00175                                                const QUEX_TYPE_CHARACTER*  Begin, 
00176                                                const QUEX_TYPE_CHARACTER*  End);
00177 };
00178 
00179 } /* Closing Namespace 'ct' */
00180 
00181 
00182 
00183 #   line 121 "quex/code_base/token/CppDefault.qx"
00184 
00185         namespace ct {
00186 
00187         inline std::ostream&
00188         operator<<(std::ostream& ostr, const lexer_Token& Tok)
00189         { ostr << std::string(Tok); return ostr; }
00190         } /* Closing Namespace 'ct' */
00191 
00192 
00193 #include <quex/code_base/converter_helper/identity.i>
00194    
00195 
00196 #   line 197 "ct_lexer-token.hpp"
00197 
00198 
00199 
00200 
00201 #endif /* __QUEX_INCLUDE_GUARD__TOKEN__GENERATED____CT____LEXER_TOKEN */
00202 
00203 /* -*- C++ -*-   vim: set syntax=cpp: 
00204  * (C) 2004-2009 Frank-Rene Schaefer
00205  * ABSOLUTELY NO WARRANTY
00206  */
00207 #ifndef __QUEX_INCLUDE_GUARD__TOKEN__GENERATED____CT____LEXER_TOKEN_I
00208 #define __QUEX_INCLUDE_GUARD__TOKEN__GENERATED____CT____LEXER_TOKEN_I
00209 
00210 #include <quex/code_base/definitions>
00211 
00212 QUEX_NAMESPACE_LEXEME_NULL_OPEN
00213 extern QUEX_TYPE_CHARACTER   QUEX_LEXEME_NULL_IN_ITS_NAMESPACE;
00214 QUEX_NAMESPACE_LEXEME_NULL_CLOSE
00215 
00216 
00217 namespace ct {
00218 
00219 
00220 QUEX_INLINE
00221 lexer_Token::lexer_Token()
00222 {
00223 #   define self (*this)
00224 
00225 #   undef  self
00226 }
00227 
00228 QUEX_INLINE
00229 lexer_Token::lexer_Token(const lexer_Token& Other)
00230 {
00231    QUEX_NAME_TOKEN(copy)(this, &Other);
00232 #   define self (*this)
00233 
00234 #   undef  self
00235 }
00236 
00237 QUEX_INLINE
00238 lexer_Token::~lexer_Token()
00239 {
00240 #   define self (*this)
00241 
00242 #   undef  self
00243 }
00244 
00245 QUEX_INLINE void
00246 QUEX_NAME_TOKEN(construct)(lexer_Token* __this)
00247 {
00248     /* Explicit constructor call by 'placement new' */
00249     new ((void*)__this) lexer_Token;
00250 }
00251 
00252 QUEX_INLINE void
00253 QUEX_NAME_TOKEN(destruct)(lexer_Token* __this)
00254 {
00255     __this->lexer_Token::~lexer_Token();  
00256 }
00257 
00258 QUEX_INLINE void
00259 QUEX_NAME_TOKEN(copy)(lexer_Token* __this, const lexer_Token* __That)
00260 {
00261 #   define self  (*__this)
00262 #   define Other (*__That)
00263     (void)__this;
00264     (void)__That;
00265 
00266 #   line 20 "quex/code_base/token/CppDefault.qx"
00267 
00268         self._id    = Other._id;
00269         self.text   = Other.text;
00270         self.number = Other.number;
00271     #   ifdef     QUEX_OPTION_TOKEN_STAMPING_WITH_LINE_AND_COLUMN
00272     #   ifdef     QUEX_OPTION_TOKEN_STAMPING_WITH_LINE_AND_COLUMN
00273         __QUEX_IF_COUNT_LINES(self._line_n     = Other._line_n);
00274         __QUEX_IF_COUNT_COLUMNS(self._column_n = Other._column_n);
00275     #   endif
00276     #   endif
00277    
00278 
00279 #   line 280 "ct_lexer-token.hpp"
00280 
00281 #   undef Other
00282 #   undef self
00283    /* If the user even misses to copy the token id, then there's
00284     * something seriously wrong.                                 */
00285    __quex_assert(__this->_id == __That->_id);
00286 #ifdef     QUEX_OPTION_TOKEN_STAMPING_WITH_LINE_AND_COLUMN
00287 #   ifdef QUEX_OPTION_TOKEN_STAMPING_WITH_LINE_AND_COLUMN
00288     __QUEX_IF_COUNT_LINES(__quex_assert(__this->_line_n == __That->_line_n));
00289     __QUEX_IF_COUNT_COLUMNS(__quex_assert(__this->_column_n == __That->_column_n));
00290 #   endif
00291 #endif
00292 }
00293 
00294 QUEX_INLINE bool 
00295 QUEX_NAME_TOKEN(take_text)(lexer_Token*              __this, 
00296                            QUEX_TYPE_ANALYZER*        __analyzer, 
00297                            const QUEX_TYPE_CHARACTER* Begin, 
00298                            const QUEX_TYPE_CHARACTER* End)
00299 {
00300 #   define self      (*__this)
00301 #   define analyzer  (*__analyzer)
00302     (void)__this;
00303     (void)__analyzer;
00304 
00305 #   line 80 "quex/code_base/token/CppDefault.qx"
00306 
00307 #       if 0
00308         {
00309             /* Hint for debug: To check take_text change "#if 0" to "#if 1". */
00310             QUEX_TYPE_CHARACTER* it = 0x0;
00311             printf("%lX ", (long)__this);
00312             printf("previous:  '");
00313             for(it = (QUEX_TYPE_CHARACTER*)self.text.c_str(); *it ; ++it) printf("%04X.", (int)*it);
00314             printf("'\n");
00315             printf("take_text: '");
00316             for(it = (QUEX_TYPE_CHARACTER*)Begin; it != End; ++it) printf("%04X.", (int)*it);
00317             printf("'\n");
00318         }
00319 #       endif
00320 
00321         /* It cannot be assumed that the lexeme is zero terminated. */
00322         self.text.assign(Begin, End-Begin);
00323 
00324 #       if 0
00325         {
00326             /* Hint for debug: To check take_text change "#if 0" to "#if 1". */
00327             QUEX_TYPE_CHARACTER* it = 0x0;
00328             printf("after:     '");
00329             for(it = (QUEX_TYPE_CHARACTER*)self.text.c_str(); *it ; ++it) printf("%04X.", (int)*it);
00330             printf("'\n");
00331         }
00332 #       endif
00333 
00334         /* This token copied the text from the chunk into the string, 
00335          * so we do not claim owneship over it.                       */
00336         return false;      
00337    
00338 
00339 #   line 340 "ct_lexer-token.hpp"
00340 
00341 #   undef analyzer
00342 #   undef self
00343 }
00344 
00345 #ifdef QUEX_OPTION_TOKEN_REPETITION_SUPPORT
00346 QUEX_INLINE size_t 
00347 QUEX_NAME_TOKEN(repetition_n_get)(lexer_Token* __this)
00348 {
00349 #   define self (*__this)
00350     (void)__this;
00351     
00352 #   line 117 "quex/code_base/token/CppDefault.qx"
00353 
00354        return self.number;
00355    
00356 
00357 #   line 358 "ct_lexer-token.hpp"
00358 
00359 #   undef self
00360 }
00361 
00362 QUEX_INLINE void 
00363 QUEX_NAME_TOKEN(repetition_n_set)(lexer_Token* __this, size_t N)
00364 {
00365 #   define self (*__this)
00366     (void)__this;
00367     (void)N;
00368     
00369 #   line 113 "quex/code_base/token/CppDefault.qx"
00370 
00371        self.number = N;
00372    
00373 
00374 #   line 375 "ct_lexer-token.hpp"
00375 
00376 #   undef  self
00377 }
00378 #endif /* QUEX_OPTION_TOKEN_REPETITION_SUPPORT */
00379 
00380 } /* Closing Namespace 'ct' */
00381 
00382 
00383 
00384 
00385 #endif /* __QUEX_INCLUDE_GUARD__TOKEN__GENERATED____CT____LEXER_TOKEN_I */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines