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

pattern_based_code_generator.hh

00001 /*
00002 *  Name:      pattern_based_code_generator.hh
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   Pattern based code generator       
00005 *  Date:      $Date: 2003/04/14 00:18:32 $
00006 *  Revision:  $Revision: 1.1 $
00007 *
00008 *  Copyright (C) 1994-2002  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00009 *
00010 *  This program is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
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 *  You should have received a copy of the GNU General Public License
00021 *  along with this program; if not, write to the Free Software
00022 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 *  MA 02111-1307, USA.
00024 */
00025 
00026 #ifndef _MPCL_TEXT_CODEGEN_PATTERN_BASED_CODE_GENERATOR__
00027 #define _MPCL_TEXT_CODEGEN_PATTERN_BASED_CODE_GENERATOR__
00028 
00029 #include "../../io/streamable.hh"
00030 #include "../../io/streamable_map.hh"
00031 #include "../string.hh"
00032 #include "clause_body_string.hh"
00033 #include "defs.hh"
00034 #include "instruction_body.hh"
00035 #include "instruction_tag_string.hh"
00036 
00037 
00039 namespace mpcl
00040 {
00041 
00043   namespace text
00044   {
00045 
00047     namespace codegen
00048     {
00049 
00050       using io::IStreamable;
00051       using io::TStreamableMap;
00052 
00070       class TPatternBasedCodeGenerator: public IStreamable<>
00071       {
00072 
00073         private:
00074 
00076           typedef
00077             TStreamableMap<TInstructionTagString, TInstructionBody>
00078             TInstructionMap;
00079 
00081           TInstructionMap   tInstructionMap;
00082 
00084           TStringToVariableMap   tVariableMap;
00085 
00087           TString   yCdmlPath;
00088 
00090           TString   yDescription;
00091 
00093           TString   yInherit;
00094 
00096           TString   yPublic;
00097 
00099           TString   ySystem;
00100 
00102           TString   yTarget;
00103 
00104 
00105         public:
00106 
00107           //
00108           //  C O N S T R U C T O R S
00109           //
00110 
00119           TPatternBasedCodeGenerator ( const TString& rkySOURCE_CDML_FILE ,
00120                                        const TString& rkyCDML_PATH        );
00121 
00123           TPatternBasedCodeGenerator (void) :
00124             IStreamable<>   ()              ,
00125             tInstructionMap ()              ,
00126             tVariableMap    ()              ,
00127             yCdmlPath       ()              ,
00128             yDescription    ()              ,
00129             yInherit        ()              ,
00130             yPublic         ()              ,
00131             ySystem         ()              ,
00132             yTarget         ()
00133           {
00134             initConstants();
00135           }
00136 
00138           void clear (void);
00139 
00141           void clearCode (void);
00142 
00148           void compile (void);
00149 
00155           void loadFrom (const TString& rkySOURCE_CDML_FILE);
00156 
00160           void preprocessVariables (void);
00161 
00166           void setDescription (const char* pkcSOURCE_DESCRIPTION);
00167 
00174           void setCdmlPath (const TString& rkyCDML_PATH);
00175 
00176 
00177         protected:
00178 
00179           //
00180           //  C O N S T R U C T O R S
00181           //
00182 
00184           void initConstants (void) const;
00185 
00193           void inheritFrom (const TString& rkySOURCE_CDML_FILE);
00194 
00199           void read (std::basic_istream<char_type, traits_type>& rtSOURCE_STREAM);
00200 
00201 
00202         public:
00203 
00204           //
00205           //  S E L E C T O R S
00206           //
00207 
00213           const TStringToVariableMap& variables (void) const;
00214 
00215           const TClauseBodyString& codePatternFor ( const char* pkcINSTRUCTION_NAME ,
00216                                                     const char* pkcCLAUSE_NAME      ) const;
00217 
00218           TInstructionBody& instruction (const char* pkcINSTRUCTION_NAME);
00219 
00220           const TInstructionBody& instruction (const char* pkcINSTRUCTION_NAME) const;
00221 
00227           bool existsVariable (const char* pkcVARIABLE_NAME) const;
00228 
00229           bool existsClause (const char* pkcINSTRUCTION_NAME, const char* pkcCLAUSE_NAME) const;
00230 
00238           const TInstructionBody& operator [] (const char* pkcINSTRUCTION_NAME) const
00239           {
00240             return instruction (pkcINSTRUCTION_NAME);
00241           }
00242 
00250           TInstructionBody& operator [] (const char* pkcINSTRUCTION_NAME)
00251           {
00252             return instruction (pkcINSTRUCTION_NAME);
00253           }
00254 
00255 
00256         protected:
00257 
00258           //
00259           //  S E L E C T O R S
00260           //
00261 
00266           void write (std::basic_ostream<char_type, traits_type>& rtTARGET_OSTREAM) const;
00267 
00268       };  // class TPatternBasedCodeGenerator
00269 
00270     }  // namespace codegen
00271 
00272   }  // namespace text
00273 
00274 }  // namespace mpcl
00275 
00276 
00277 #endif  // not _MPCL_TEXT_CODEGEN_PATTERN_BASED_CODE_GENERATOR__

Generated on Mon Oct 13 02:35:23 2003 for MPCL by doxygen1.2.18