ucn_token.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___ucn_token_hh___included
00029 #define lestes__lang__cplus__lex___ucn_token_hh___included
00030 
00031 /*! \file
00032   \brief Single character token.
00033   
00034   Declaration of ucn_token class representing single source character token.
00035   \author pt
00036 */
00037 #include <lestes/common.hh>
00038 #include <lestes/lang/cplus/lex/simple_location.hh>
00039 #include <lestes/lang/cplus/lex/basic_token.hh>
00040 #include <lestes/msg/message.hh>
00041 
00042 package(lestes);
00043 package(lang);
00044 package(cplus);
00045 package(lex);
00046 
00047 //! Helper typedef.
00048 typedef basic_token<lc_host_uint_least9,ptr<simple_location>,ucn> basic_ucn_token;
00049 
00050 /*!
00051   \brief Single source character token.
00052   
00053   Represents single source character token.
00054   For character translation and other processing before lex phase.
00055 */
00056 class ucn_token: public basic_ucn_token {
00057 public:
00058         //! The type of stored error message.
00059         typedef ptr< ::lestes::msg::message > error_type;
00060         //! Returns error for token.
00061         error_type error_get(void) const;
00062         //! Returns copy of token with changed type.
00063         ptr<ucn_token> clone_type(const type_type &a_type) const;
00064         //! Returns copy of token with changed value.
00065         ptr<ucn_token> clone_value(const value_type &a_value) const;
00066         //! Returns copy of token with changed location.
00067         ptr<ucn_token> clone_location(const location_type &a_location) const;
00068         //! Returns new token, initializes with token type.
00069         static ptr<ucn_token> create(const type_type &a_type);
00070         //! Returns new token, initializes with token type and token value.
00071         static ptr<ucn_token> create(const type_type &a_type, const value_type &a_value);
00072         //! Returns new token, initializes with location, token type and value.
00073         static ptr<ucn_token> create(const type_type &a_type, const value_type &a_value,
00074                         const location_type &a_location);
00075         //! Returns new error token, initializes with error and location.
00076         static ptr<ucn_token> create_error(const error_type &a_error, const location_type &a_location);
00077         //! Returns new error token, initializes with the error.
00078         static ptr<ucn_token> create_error(const error_type &a_error);
00079         //! Tests equality.
00080         bool equals(const ptr<ucn_token> &rhs) const;
00081         //! Token type constants.
00082         enum token_types {
00083                 //! End of file.
00084                 TOK_EOF = 0,
00085                 //! Anything which is not basic source character.
00086                 TOK_TRANSLATED = 1,
00087                 //! Any character in early stages of processing.
00088                 TOK_NOT_EOF = 2,
00089                 //! Basic source character.
00090                 TOK_BASIC = 3,
00091                 //! Token for propagation of messages.
00092                 TOK_ERROR = 4
00093         };
00094 protected:
00095         //! Creates the object, initializes with location, type and value.
00096         ucn_token(const location_type &a_location, const type_type &a_type, const value_type &a_value);
00097         //! Creates the object, initializes with location and error.
00098         ucn_token(const location_type &a_location, const error_type &a_error);
00099         //! Marks the object.
00100         virtual void gc_mark(void);
00101 private:
00102         //! Message to report for token.
00103         srp< ::lestes::msg::message > error;
00104         //! Hides copy constructor.
00105         ucn_token(const ucn_token &);
00106         //! Hides assignment operator.
00107         ucn_token &operator=(const ucn_token &);
00108 };
00109 
00110 //! Type of token in ucn_token.
00111 typedef ucn_token::type_type ucn_token_type;
00112 
00113 end_package(lex);
00114 end_package(cplus);
00115 end_package(lang);
00116 end_package(lestes);
00117 #endif
00118 /* vim: set ft=lestes : */

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