Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

precompiler.h

Go to the documentation of this file.
00001 #ifndef precompiler_h
00002 #define precompiler_h
00003 
00004 #include <fstream>
00005 
00006 #include "file.h"
00007 #include "lexer.h"
00008 #include "error.h"
00009 #include "macro.h"
00010 #include "sitemap.h"
00011 #include "strings.h"
00012 #include <cstdio>
00013 #include "tmp.h"
00014 #include <Format.hh>
00015 #include "init.h"
00016 #include "ih.h"
00017 #include "user.h"
00018 
00020 class Precompiler
00021 {
00022  private:
00024 
00025   typedef struct Macros; 
00026   
00027   bool eof_reached;
00028 
00029   File in;
00030   File out;
00031 
00032  public:
00033   typedef std::list<Line> line_list;
00034   typedef line_list::iterator line_list_it;
00035 
00036  private:
00037   typedef struct Where_link
00038   {
00039     Where_link() {}
00040     Link where;
00041     line_list_it line;
00042   };
00043   
00044   typedef std::list<Where_link> where_link_list;
00045   typedef where_link_list::iterator where_link_list_it;
00046 
00047   typedef struct Where
00048   {
00049     SitemapBase where;
00050     line_list_it line;
00051   };
00052 
00053   typedef std::list<Where> where_list;
00054   typedef std::list<Where>::iterator where_list_it;
00055 
00056   Tmp *temp;
00057 
00058   typedef std::list<InitTableEntry> init_list;
00059   typedef init_list::iterator init_list_it;
00060   
00061   init_list init_table;
00062   
00063   InterpreterHandler ip_handler;
00064 
00065   UserHandler::def_list defines;
00066   Strings::string_list  user_scans; 
00067 
00068   std::string current_path;
00069 
00070   bool use_default_init_table;
00071 
00072   struct Init_Scan
00073   {
00074     enum Mode
00075       {
00076         NONE,
00077         RESET,
00078         INSERT,
00079         APPEND,
00080         DELETE
00081       };
00082 
00083     Mode mode;
00084     init_list table;
00085   };
00086 
00087   typedef std::list<Init_Scan> init_scan_list;
00088   typedef init_scan_list::iterator init_scan_list_it;
00089 
00090  public:
00091   class Error;
00092 
00094   class tmp_parse_error;
00095 
00097   class cannot_open_file;
00098 
00100   class cannot_create_tmp_file;
00101 
00102  private:
00103   macro_list predef_soft_macros; 
00104   macro_list predef_hard_macros; 
00105   Strings::string_list locale_list;
00106 
00107   bool use_tmp;
00108   bool auto_init_detection;
00109 
00110  public:
00111   Precompiler( std::string infile, std::string outfile, bool use_tmp, bool no_erase );
00113   Precompiler( std::string infile, std::string outfile,
00114                macro_list predef_soft_macros,   
00115                macro_list predef_hard_macros,   
00116                Strings::string_list locale,     
00117                bool use_tmp,                    
00118                bool no_erase                    
00119                );
00120   ~Precompiler();
00121 
00122   void compile();
00123   
00124   static void warning( std::string message );
00125   static void warning( Line line, std::string message );
00126 
00128   static bool emacs_warning; 
00129 
00130   // print init level infos
00131   static bool init_info;
00132 
00133   std::string get_tmp_file();
00134 
00135  private:
00137   Line read_line( File &in );
00138   
00140   inline void write_line( const Line &line, File& out );
00141   
00143   void lex_file( File in, File out );
00144   
00146   void include_scan( File in, File out, std::string last_cur_dir = "" );
00147   
00149   Macros read_macros( File in, Init::Range range );
00150   
00152   void rebuilt_file( File in, File out );
00153   
00154   void substitude_soft_macros( Macros &macros, File in , File out, Init::Range range );
00155   
00156   void substitude_hard_macros( Macros &macros, File in, File out, Init::Range range );
00157   
00159   bool built_menu( File in, File out );
00160   
00161   bool locale_support( File in, File out ); 
00162   line_list_it find_locale_start( line_list& ll, line_list_it start ); 
00163   line_list_it find_locale_end( line_list& ll, line_list_it start ); 
00164 
00165   friend bool operator == ( const Line& l1, const Line& l2 );
00166 
00167   void script_support( File in  );
00168 
00169   void image_scan( File in, File out, Init::Range range );
00170   void filelink_scan( File in, File out );
00171   void filelist_scan( File in, File out );
00172 
00174   init_scan_list init_scan( File in, File out );
00175 
00177   bool script_function_scan( File in, File out );
00178 
00180   void compile( File in, File out );
00181 
00183   void include_at_line( Line line, File out );
00184 
00186   void char_set_scan( File in, File out );
00187 
00189   inline void set( Init::Type  type );
00190 
00192   inline void auto_init_check( std::string& tag_type );
00193 
00195   bool delete_scan( File in, File out, Init::Range range );
00196 
00198   void define_scan( File in );
00199 
00201   bool user_scan( File in, File out, std::string init_name );
00202 
00204   std::string get_path( std::string file );
00205 
00207   static std::string simplify_path( std::string path );
00208 
00209   init_list get_default_init_table();
00210 
00211   void init_check( File in, File out ); 
00212 };
00213 
00214 bool operator == ( const Line& l1, const Line& l2 );
00215 
00217 class Precompiler::Error : public ::Error
00218 {
00219  public:
00220   Error( std::string error_string ) 
00221     : ::Error( Line(), "Precompiler", error_string ) {}
00222   template <class T>Error( std::string error_string, T what )
00223                            : ::Error( Line(), "Precompiler", error_string, what ) {}
00224   template <class T>Error( Line line, std::string error_string, T what )
00225                            : ::Error( line, "Precompiler", error_string, what ) {}
00226   Error( Line line, std::string error_string ) 
00227     : ::Error( line, "Precompiler", error_string ) {}
00228 };
00229 
00231 class Precompiler::tmp_parse_error : public Precompiler::Error
00232 {
00233  public:
00234   tmp_parse_error()
00235     : Error( _("Parse error at tmp file") )
00236     {}
00237   template <class T> tmp_parse_error( T what )
00238     : Error( _("Parse error at tmp file"), what )
00239     {}
00240 
00241   template <class T> tmp_parse_error( Line line, T what )
00242     : Error( line, _("Parse error at tmp file"), what )
00243     {}
00244 
00245   tmp_parse_error( Line line )
00246     : Error( line, _("Parse error at tmp file") )
00247     {}
00248 };
00249 
00251 class Precompiler::cannot_open_file : public Precompiler::Error
00252 {
00253  public:
00254   cannot_open_file( std::string file )
00255     : Error( _("Cannot open file"), file )
00256     { }
00257 
00258   cannot_open_file( Line line, std::string file )
00259     : Error( line, _("Cannot open file"), file )
00260     { }
00261 };
00262 
00264 class Precompiler::cannot_create_tmp_file : public Precompiler::Error
00265 {
00266  public:
00267   cannot_create_tmp_file( std::string file )
00268     : Error( _("Cannot create tmp file"), file )
00269     { }
00270 };
00271 
00272 #endif

Generated on Tue Nov 20 02:19:52 2001 for Leo<HTML> by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001