hinter.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__syn__hinter_hh__included
00029 #define lestes__lang__cplus__syn__hinter_hh__included
00030 
00031 #include <lestes/common.hh>
00032 #include <lestes/lang/cplus/syn/token.hh>
00033 
00034 #include <map>
00035 
00036 package(lestes);
00037 package(lang);
00038 package(cplus);
00039 package(sem);
00040 class ss_decl_seq;
00041 end_package(sem);
00042 package(syn);
00043 
00044 // completed in hinter.g.hh
00045 class elab_spec_key;
00046 
00047 class hinter {
00048 public:
00049 
00050         enum mode_type {
00051                 HINTER_NORMAL,  // hinter works full-time, ignores user hints
00052                 HINTER_CHECK,   // compares its hints with user's ones (if available)
00053                                 //   it is fatal when they don't agree
00054                 HINTER_USER,    // trusts user hints, only hints itself when no user hint is available
00055                 HINTER_OFF      // hinter off; every identifier must be user-hinted
00056         };
00057 
00058         // possibly returns a new token
00059         // the hinted token has its origin saved in the flags
00060         static ptr<bison_token> hint( const ptr<bison_token> & t,
00061                         const ptr<bison_token> & lookahead );
00062 
00063         //! Initializes the hinter; manager must be already initialized when calling this function.
00064         static void init( mode_type );
00065         static mode_type mode_get();
00066 
00067 //      static void forced_scope_set( const ptr< ::lestes::lang::cplus::sem::ss_decl_seq > & );
00068         static void qual_scope_set( const ptr< ::lestes::lang::cplus::sem::ss_decl_seq > & );
00069         static void elab_spec_set( const ptr<elab_spec_key> & );
00070 
00071         static void namespace_mode_set( bool );
00072 
00073         static void qual_scope_set_root();
00074 protected:
00075         //! maps identifier type hints to token types; note that not all hints are covered!
00076         static ::std::map<bison_token::hint_type,bison_token::yytokentype> id_hint2tok_type_map;
00077 
00078 //      static ptr< ::lestes::lang::cplus::sem::ss_decl_seq > forced_scope_get();
00079         static ptr< ::lestes::lang::cplus::sem::ss_decl_seq > qual_scope_get();
00080         static ptr<elab_spec_key> elab_spec_get();
00081 
00082         static bool namespace_mode_get();
00083 
00084         static ptr<bison_token> use_user_hint( const ptr<bison_token> & t );
00085         static ptr<bison_token> compute_hint( const ptr<bison_token> & t,
00086                                         const ptr<bison_token> & lookahead );
00087 private:
00088         //! Do not allow instantiating this class.
00089         hinter();
00090         //! Hide copy-constructor.
00091         hinter( const hinter & );
00092 
00093         static mode_type mode;
00094 };
00095 
00096 end_package(syn);
00097 end_package(cplus);
00098 end_package(lang);
00099 end_package(lestes);
00100 
00101 #endif  // lestes__lang__cplus__syn__hinter_hh__included

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