X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=kernel%2Fsrc%2FbbtkInterpreter.cxx;h=2147d0ca35c1b84760ca57380c523ad77b85b89a;hb=3924782985e3d7c795af6bb46c602157cfad59f0;hp=22bd9fb69d3a20d0805876730979521c247c1065;hpb=b253812964e57b9592fe64bb3bc97f2aac72d3a7;p=bbtk.git diff --git a/kernel/src/bbtkInterpreter.cxx b/kernel/src/bbtkInterpreter.cxx index 22bd9fb..2147d0c 100644 --- a/kernel/src/bbtkInterpreter.cxx +++ b/kernel/src/bbtkInterpreter.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.cxx,v $ $ Language: C++ - Date: $Date: 2008/03/14 14:58:53 $ - Version: $Revision: 1.44 $ + Date: $Date: 2008/03/18 12:51:26 $ + Version: $Revision: 1.46 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -179,7 +179,7 @@ bufferNb =0; info.help = "Creates an html index of known boxes. If filename is provided then save it to the file 'filename'. The default index entries are the initial letters of the names of the boxes. If 'Packages' or 'Categories' is provided then the entries are either the packages names or the categories. If 'Adaptors' is provided then an alphabetical index of all adaptors is created."; mCommandDict[info.category] = info; - info.category = "reset"; //EED + info.category = "reset"; info.argmin = 0; info.argmax = 0; info.code = cReset; @@ -290,8 +290,6 @@ bufferNb =0; */ Interpreter::~Interpreter() { - -std::cout << "=========================================~Interpreter()" << std::endl; bbtkDebugMessageInc("Interpreter",9,"Interpreter::~Interpreter()" <0) && !mFile.back()->eof() ) //{ // std::cout << "mFile.size() "<< mFile.size() << " mFileName.back() [" << mFileName.back() << "]" << std::endl; - while (!mFile.back()->eof()) { mLine.back()++; char buf[500]; @@ -349,13 +344,11 @@ std::cout << "=========================================~Interpreter()" << std::e str.erase(size-1,1); } - InterpretLine(str, insideComment); - -//printf("EED Interpreter::InterpretFile %s\n", str.c_str() ); + InterpretLine(str, insideComment); - } - //if (mFile.size()>0) - CloseCurrentFile(); + }//while + //if (mFile.size()>0) + CloseCurrentFile(); } } catch (QuitException e) @@ -395,6 +388,97 @@ std::cout << "=========================================~Interpreter()" << std::e //======================================================================= + //======================================================================= + /** + * + */ + void Interpreter::InterpretBuffer( std::stringstream* buffer ) + { + bbtkDebugMessageInc("Interpreter",9,"Interpreter::InterpretBuffer()"<::iterator it =mFileName.begin(); it!=mFileName.end(); ++it) + { + std::cout << "A=== [" << (*it) << "]" << std::endl; + } +*/ + bool insideComment = false; // for multiline comment + while (mFile.size()>0) + { +/* + for( std::vector::iterator it =mFileName.begin(); it!=mFileName.end(); ++it) + { + std::cout << "B=== [" << (*it) << "]" << std::endl; + } +*/ + + //while ((mFile.size()>0) && !mFile.back()->eof() ) + //{ +// std::cout << "mFile.size() "<< mFile.size() << " mFileName.back() [" << mFileName.back() << "]" << std::endl; + while (!mFile.back()->eof()) { + mLine.back()++; + char buf[500]; + mFile.back()->getline(buf,500); + std::string str(buf); +// std::cout << " in InterpretFile mFile.back()->getline [" << str << "]" << std::endl; + int size=str.length(); + if ( str[ size-1 ]==13 ) + { + str.erase(size-1,1); + } + + InterpretLine(str, insideComment); + + }//while + //if (mFile.size()>0) + CloseCurrentFile(); + } + } + catch (QuitException e) + { + // std::cout << "**QuitException caught**"<mExecuter->Reset(); break; @@ -836,17 +919,21 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& continue; // ignore '-appli.bbs' files } */ - (*stream) << "include " << *i << "\n"; + + (*stream) << "include " << *i << "\n"; +//EED InterpretFile(*i); + nbBssFiles++; - } - if (nbBssFiles==0) + } // for vector + if (nbBssFiles==0){ bbtkMessage("Interpreter",2, "WARNING : No '.bbs' file found in [" << upath << "]" << std::endl); - else - SwitchToStream(stream); + } else { + SwitchToStream(stream); + } return; - } + } // if upath std::string path; std::vector::iterator i; @@ -861,11 +948,10 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& char * currentDir = getcwd(buf, 2048); std::string cwd(currentDir); path = currentDir; - } + } // if path fullDirectoryName = Utilities::MakePkgnameFromPath(path, upath, false); - //EED 18 Fev 2008 // without last slash "\" std::string fullDirectoryNameClean = fullDirectoryName.substr(0,fullDirectoryName.size()-1); @@ -878,7 +964,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& bbtkMessage("Interpreter",1," [" <& nbBssFiles = 0; for (std::vector::iterator i = Filenames.begin(); i!= Filenames.end(); ++i) { -//EEDprintf("EED Interpreter::SwitchToFile %s\n",(*i).c_str() ); // std::cout << "JPR================== iterate [" << *i << "]" << std::endl; int lgr = (*i).size(); if (lgr < 5) @@ -901,21 +986,25 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& continue; // ignore '-appli.bbs' files } */ - (*stream) << "include " << *i << "\n"; + + (*stream) << "include " << *i << "\n"; +//EED InterpretFile(*i); + nbBssFiles++; - } - if (nbBssFiles==0) + } // for vector + if (nbBssFiles==0){ bbtkMessage("Interpreter",1, "WARNING : No '.bbs' file found in [" << fullDirectoryName << "]" << std::endl); - else + } else { SwitchToStream(stream); + } //break; // a directory was found; we stop iterating // LG : No! We want all files included ! - } + } // for vector return; - } + } // if * //std::string::size_type slash_position = name.find_last_of("/\\"); @@ -1014,7 +1103,8 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& void Interpreter::SwitchToStream( std::stringstream* stream ) { //std::cout << "== 1 Entry in Interpreter::SwitchToStream " << std::endl; - mFile.push_back(stream); + + mFile.push_back(stream); //std::cout << " mFile.size() " << mFile.size() << std::endl; std::ostringstream buffer_name; bufferNb++; @@ -1054,18 +1144,14 @@ void Interpreter::SwitchToStream( std::stringstream* stream ) void Interpreter::LoadScript( std::string fullPathScriptName, std::string includeScriptName) { -//std::cout << "--------------------------EED Interpreter::LoadScript >>01\n" << std::endl; Utilities::replace( fullPathScriptName , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); bool okScriptExist=false; int iStrScript,sizeVecStricpt=mFileName.size(); for ( iStrScript=0;iStrScript>__ %s\n", iStrScript,mFileName[iStrScript].c_str(),fullPathScriptName.c_str() ); - if (mFileName[iStrScript] == fullPathScriptName ) { - printf(" EED %d Interpreter::LoadScript iguales\n",iStrScript ); okScriptExist=true; } // if } // for @@ -1073,7 +1159,6 @@ void Interpreter::SwitchToStream( std::stringstream* stream ) if (find(mFileName.begin(),mFileName.end(),fullPathScriptName)!=mFileName.end()) // if (okScriptExist==true) { -//EED printf("EED Interpreter::LoadScript Exit method\n"); bbtkMessage("Interpreter",1,"file '"<>02\n"); return; } @@ -1124,15 +1208,6 @@ void Interpreter::SwitchToStream( std::stringstream* stream ) mFileName.pop_back(); mIncludeFileName.pop_back(); mLine.pop_back(); -/*EED3 - bbtkDebugMessage("Interpreter",9," Closing file '"<close(); - delete mFile[0]; - mFile.erase( mFile.begin() ); - mFileName.erase( mFileName.begin() ); - mIncludeFileName.erase( mIncludeFileName.begin() ); - mLine.erase( mLine.begin() ); -*/ bbtkDebugMessage("Interpreter",9," Remains " <