cpp_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___cpp_token_hh___included
00029 #define lestes__lang__cplus__lex___cpp_token_hh___included
00030 
00031 /*! \file
00032   \brief C++ token.
00033   
00034   Declaration of cpp_token class representing C++ token.
00035   \author pt
00036 */
00037 #include <lestes/common.hh>
00038 #include <lestes/lang/cplus/lex/basic_token.hh>
00039 #include <lestes/std/map.hh>
00040 
00041 package(lestes);
00042 package(std);
00043 // forward declaration to avoid cycle
00044 class source_location;
00045 end_package(std);
00046 package(lang);
00047 package(cplus);
00048 package(lex);
00049 
00050 // forward declaration to avoid cycle
00051 class lex_literal;
00052 class token_value;
00053 
00054 //! Helper typedef.
00055 typedef basic_token<int,ptr<source_location>,ptr<token_value> > basic_cpp_token;
00056 
00057 /*!
00058   \brief C++ token.
00059   
00060   Represents C++ token, which is passed to syntactical analysis.
00061 */
00062 class cpp_token: public basic_cpp_token {
00063 public:
00064         //! The type of literal properties.
00065         typedef ptr<lex_literal> literal_type;
00066         // enum of token types
00067 #include <lestes/lang/cplus/syn/cpp_token_type_enum.s.hh>
00068         //! Tests equality.
00069         bool equals(const ptr<cpp_token> &rhs) const;
00070         //! Returns lex literal properties.
00071         ptr<lex_literal> literal_get(void) const;
00072         //! Returns token description.
00073         lstring description_get(void) const;
00074         //! Returns new token, initializes with token type.
00075         static ptr<cpp_token> create(const location_type &a_location, const type_type &a_type);
00076         //! Returns new token, initializes with token type and value.
00077         static ptr<cpp_token> create(const location_type &a_location,
00078                         const type_type &a_type, const value_type &a_value);
00079         //! Returns new literal token, initializes with literal properties and value.
00080         static ptr<cpp_token> create_literal(const location_type &a_location,
00081                         const literal_type &a_literal, const value_type &a_value);
00082         //! Returns list of reflection info.
00083         virtual ptr<reflection_list> reflection_get(void) const;
00084         //! Returns list of field values.
00085         virtual ptr<field_list_list> field_values_get(void) const;
00086 protected:
00087         //! Creates the object.
00088         cpp_token(const location_type &a_location, const type_type &a_type, const value_type &a_value,
00089                         const literal_type &a_literal);
00090         //! Marks the object.
00091         virtual void gc_mark(void);
00092 private:
00093         //! Type of descriptions map.
00094         typedef map<type_type,lstring> descriptions_type;
00095         //! Literal information for semantic analysis.
00096         srp<lex_literal> literal;
00097         //! Token descriptions.
00098         static ptr<descriptions_type> descriptions;
00099         //! The reflection information.
00100         static ptr<reflection_list> reflection;
00101         //! Hides copy constructor.
00102         cpp_token(const cpp_token &);
00103         //! Hides assignment operator.
00104         cpp_token &operator=(const cpp_token &);
00105 };
00106 
00107 //! Type of token in cpp_token.
00108 typedef cpp_token::type_type cpp_token_type;
00109 
00110 end_package(lex);
00111 end_package(cplus);
00112 end_package(lang);
00113 end_package(lestes);
00114 #endif
00115 /* vim: set ft=lestes : */

Generated on Mon Feb 12 18:22:33 2007 for lestes by doxygen 1.5.1-20070107