Program: bbtk
Module: $RCSfile: bbtkInterpreter.cxx,v $ $
Language: C++
- Date: $Date: 2008/02/20 11:58:32 $
- Version: $Revision: 1.35 $
+ Date: $Date: 2008/03/03 11:43:52 $
+ Version: $Revision: 1.38 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// For the time being, comment out previous line, and
// uncomment next line to check Transcriptor
- // mExecuter = new bbtk::Transcriptor("GeneratedProgram.txt");
+ //mExecuter = new bbtk::Transcriptor("GeneratedProgram.txt");
// Builds the commands dict
CommandInfoType info;
*/
Interpreter::~Interpreter()
{
+
+std::cout << "=========================================~Interpreter()" << std::endl;
bbtkDebugMessageInc("Interpreter",9,"Interpreter::~Interpreter()" <<std::endl);
delete mExecuter;
//delete mFactory;
/**
*
*/
- void Interpreter::InterpretFile( const std::string& filename,
- bool use_configuration_file)
+ void Interpreter::InterpretFile( const std::string& filename )
{
bbtkDebugMessageInc("Interpreter",9,"Interpreter::InterpretFile(\""<<filename<<"\")"<<std::endl);
try
{
-printf("EED: Interpreter::InterpretFile 01\n");
-InterpretLine("message ALL 9", exm);
- SwitchToFile(filename, use_configuration_file);
+ SwitchToFile(filename);
bool insideComment = false; // for multiline comment
while (mFile.size()>0)
{
bbtkDecTab("Interpreter",9);
mCommandLine = exm;
- printf("EED: Interpreter::InterpretFile 02\n");
}
//=======================================================================
break;
case cPrint :
- Print(words[1]); /// \todo use mExecuter
+ Print(words[1]); /// \todo use generate command
break;
case cExec :
case cInclude :
if (mCommandLine)
{
- InterpretFile(words[1], true ); // true : better pass use_config_file
+ InterpretFile(words[1]);
}
else
{
- SwitchToFile(words[1], true ); // true : better pass use_config_file
+ SwitchToFile(words[1]);
}
// if 'source' was given
if (words.size()==3)
break;
case cLoad:
- LoadPackage(words[1], true ); // true : better pass use_config_file
+ LoadPackage(words[1]);
break;
case cUnload:
{
if (mExecuter->GetNoExecMode()) return;
- bbtkDebugMessageInc("Interpreter",9,"Interpreter::SplitLine(\""<<str<<"\")"<<std::endl);
+ bbtkDebugMessageInc("Interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl);
+
+ // TO DO :
+ // InterpretLine ("load std")
+ // InterpretLine("new ConcatStrings _C_ ") -> trouver un nom unique : # commande
+ // InterpretLine("new Print _P_")
+ // InterpretLine("connect _C_.Out _P_.In")
+ // int num = 1
+
std::vector<std::string> chains;
std::string delimiters("$");
{
// Found a text token, add it to the vector.
chains.push_back(str.substr(lastPos, pos - lastPos));
+ // std::string token = str.substr(lastPos, pos - lastPos)
+ // InterpretLine("set _C_.In%num% %token%")
+
}
else
{
+
// is an output (between $$) : decode
std::string tok,box,output;
tok = str.substr(lastPos, pos - lastPos);
Utilities::SplitAroundFirstDot(tok,box,output);
chains.push_back( mExecuter->Get(box,output) );
+
+// InterpretLine("connect %tok% _C_.In%num%")
+
}
// Skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiters, pos);
pos = str.find_first_of(delimiters, lastPos);
//
is_text = !is_text;
+// num ++;
}
+// InterpretLine("exec _P_")
+// if (IS_IN_WORKSPACE) InterpretLine("delete _C_; delete _P_");
+
std::vector<std::string>::iterator i;
for (i= chains.begin(); i!=chains.end(); ++i)
{
// ===================================================================================
- void Interpreter::SwitchToFile( const std::string& name,
- bool use_configuration_file )
+ void Interpreter::SwitchToFile( const std::string& name )
{
// Note : in the following :
// name : the user supplied name
std::string pkgname; // e.g. <scriptname>.bbs
std::vector<std::string> Filenames;
- if (use_configuration_file)
- {
- // The following is *NOT* a debug time message :
- // It's a user intended message.
- // Please don't remove it.
- bbtkMessage("Interpreter",1,
- "look for : [" << name
- << "] (use_configuration_file == TRUE)" << std::endl);
- script_paths = ConfigurationFile::GetInstance().Get_bbs_paths();
- }
+ // The following is *NOT* a debug time message :
+ // It's a user intended message.
+ // Please don't remove it.
+ bbtkMessage("Interpreter",1,
+ "look for : [" << name
+ << "]" << std::endl);
+ script_paths = ConfigurationFile::GetInstance().Get_bbs_paths();
+
std::string upath;
pkgname = Utilities::ExtractScriptName(name,upath);