#include <VariableLexerRepository.hpp>


Public Member Functions | |
| Type | find (const std::string &name) const |
| void | add (const std::string &name, const Type &type) |
| void | markAsUnknown (const std::string &name) |
| void | beginBlock () |
| void | endBlock () |
| VariableLexerRepository () | |
| ~VariableLexerRepository () | |
Static Public Member Functions | |
| static VariableLexerRepository & | instance () |
| static void | create () |
| static void | destroy () |
Static Protected Attributes | |
| static VariableLexerRepository * | __pInstance |
Private Types | |
| typedef int | Type |
| typedef std::map< std::string, Type > | Container |
| The container of variables. | |
Private Attributes | |
| std::vector< Container > | __repository |
| size_t | __blockLevel |
Definition at line 35 of file VariableLexerRepository.hpp.
typedef int VariableLexerRepository::Type [private] |
Definition at line 39 of file VariableLexerRepository.hpp.
typedef std::map<std::string, Type> VariableLexerRepository::Container [private] |
| VariableLexerRepository::VariableLexerRepository | ( | ) |
Constructor
Definition at line 202 of file VariableLexerRepository.cpp.
References __repository.
00203 : __blockLevel(0) 00204 { 00205 __repository.push_back(Container()); 00206 }
| VariableLexerRepository::~VariableLexerRepository | ( | ) |
| VariableLexerRepository::Type VariableLexerRepository::find | ( | const std::string & | name | ) | const |
Search for a variable in the list
| name | name of the variable to find |
Definition at line 126 of file VariableLexerRepository.cpp.
References __blockLevel, and __repository.
Referenced by FFLexer::isVariable().
00127 { 00128 Container::const_iterator i; 00129 size_t level=0; 00130 for (; level<=__blockLevel;++level) { 00131 i = __repository[level].find(name); 00132 if (i != __repository[level].end()) break; 00133 } 00134 if (level>__blockLevel) return -1; 00135 if (i == __repository[level].end()) return -1; 00136 else { 00137 return i->second; 00138 } 00139 }
| void VariableLexerRepository::add | ( | const std::string & | name, | |
| const Type & | type | |||
| ) |
Adds a variable to the list
Definition at line 169 of file VariableLexerRepository.cpp.
References __blockLevel, and __repository.
00170 { 00171 __repository[__blockLevel][name]=type; 00172 }
| void VariableLexerRepository::markAsUnknown | ( | const std::string & | name | ) |
Marks a function as a variable
| name | name of the variable |
Definition at line 142 of file VariableLexerRepository.cpp.
References __blockLevel, __repository, and ErrorHandler::unexpected.
00143 { 00144 Container::iterator i; 00145 size_t level=0; 00146 for (; level<=__blockLevel;++level) { 00147 i = __repository[level].find(name); 00148 if (i != __repository[level].end()) break; 00149 } 00150 00151 if (level>__blockLevel) { 00152 throw ErrorHandler(__FILE__,__LINE__, 00153 "cannot find variable "+name, 00154 ErrorHandler::unexpected); 00155 } 00156 00157 if (i == __repository[level].end()) 00158 { 00159 throw ErrorHandler(__FILE__,__LINE__, 00160 "cannot find variable "+name, 00161 ErrorHandler::unexpected); 00162 } else { 00163 i->second = VARUNKNOWNID; 00164 } 00165 }
| void VariableLexerRepository::beginBlock | ( | ) |
Begins a new block
Definition at line 175 of file VariableLexerRepository.cpp.
References __blockLevel, and __repository.
00176 { 00177 __blockLevel++; 00178 __repository.push_back(Container()); 00179 }
| void VariableLexerRepository::endBlock | ( | ) |
Ends a block
Definition at line 182 of file VariableLexerRepository.cpp.
References __blockLevel, __repository, and ASSERT.
00183 { 00184 ASSERT(__blockLevel>0); 00185 __repository[__blockLevel].clear(); 00186 __blockLevel--; 00187 00188 __repository.pop_back(); 00189 00190 // At the end of a block, unknowns are always variables! 00191 for (size_t level=0; level<=__blockLevel;++level) { 00192 for (Container::iterator ivariable = __repository[level].begin(); 00193 ivariable != __repository[level].end(); ++ivariable) { 00194 if (ivariable->second == VARUNKNOWNID) { 00195 ivariable->second = VARFNCTID; 00196 } 00197 } 00198 } 00199 }
| static VariableLexerRepository & StaticBase< VariableLexerRepository >::instance | ( | ) | [inline, static, inherited] |
Access to auto instanciated static;
Definition at line 46 of file StaticBase.hpp.
Referenced by FFLexer::isVariable().
00047 { 00048 return *__pInstance; 00049 }
| static void StaticBase< VariableLexerRepository >::create | ( | ) | [inline, static, inherited] |
Creates __pInstance in Embedding class.
Definition at line 55 of file StaticBase.hpp.
Referenced by ThreadStaticCenter::ThreadStaticCenter().
00056 { 00057 __pInstance = new EmbeddingClass(); 00058 }
| static void StaticBase< VariableLexerRepository >::destroy | ( | ) | [inline, static, inherited] |
Destroyes __autoInstanciated in Embedding class.
Definition at line 64 of file StaticBase.hpp.
Referenced by ThreadStaticCenter::~ThreadStaticCenter().
00065 { 00066 delete __pInstance; 00067 }
std::vector<Container> VariableLexerRepository::__repository [private] |
per level variable lists
Definition at line 46 of file VariableLexerRepository.hpp.
Referenced by add(), beginBlock(), endBlock(), find(), markAsUnknown(), and VariableLexerRepository().
size_t VariableLexerRepository::__blockLevel [private] |
current level
Definition at line 48 of file VariableLexerRepository.hpp.
Referenced by add(), beginBlock(), endBlock(), find(), and markAsUnknown().
VariableLexerRepository * StaticBase< VariableLexerRepository >::__pInstance [static, protected, inherited] |
The static variable
Definition at line 37 of file StaticBase.hpp.
1.5.6