32 mMyName(
"SymbolTable"),
33 mMaxIndex(std::numeric_limits<
Idx>::max()),
64 mMaxIndex=std::numeric_limits<Idx>::max();
82 if(index <= std::numeric_limits<Idx>::max()) {
86 std::stringstream errstr;
87 errstr <<
"symboltable overflow in \"" <<
mMyName <<
"\"";
88 throw Exception(
"SymbolTable::MaxIndex(inde))", errstr.str(), 40);
98 if(rName==
"")
return false;
99 for(std::size_t cp=0;cp<rName.size();cp++) {
101 if(iscntrl(ch))
return false;
102 if(isspace(ch))
return false;
103 if(ch==
'"')
return false;
104 if(ch==
'#')
return false;
105 if(isdigit(ch))
continue;
106 if(isalpha(ch))
continue;
107 if(isprint(ch))
continue;
115 if(!
Exists(rName))
return (rName);
117 std::string name=rName;
118 std::string bname=rName;
120 std::size_t up = bname.find_last_of(
"_");
121 if(up != std::string::npos) {
123 for(std::size_t dp=up+1;dp<bname.size();dp++)
124 if(!isdigit(bname[dp])) ad=
false;
140 std::stringstream errstr;
141 errstr <<
"symboltable overflow in \"" <<
mMyName <<
"\"";
142 throw Exception(
"SymbolTable::InsEntry(index,name))", errstr.str(), 40);
145 if((nidx!=0) && (nidx!=index)) {
146 std::stringstream errstr;
147 errstr <<
"Name " << rName <<
" allready exists in \"" <<
mMyName <<
"\"";
148 throw Exception(
"SymbolTable::InsEntry(index,name)", errstr.str(), 41);
150 std::string idxname=
Symbol(index);
151 if((idxname !=
"") && (idxname != rName)) {
152 std::stringstream errstr;
153 errstr <<
"Index " << index <<
" allready exists in \"" <<
mMyName <<
"\"";
154 throw Exception(
"SymbolTable::InsEntry(index,name)", errstr.str(), 42);
157 std::stringstream errstr;
158 errstr <<
"Name " << rName <<
" is not a valid symbol";
159 throw Exception(
"SymbolTable::InsEntry(index,name)", errstr.str(), 43);
172 if( index != 0)
return index;
184 if((nidx!=0) && (nidx!=index)) {
185 std::stringstream errstr;
186 errstr <<
"Name " << rName <<
" allready exists in \"" <<
mMyName <<
"\"";
187 throw Exception(
"SymbolTable::SetEntry(index,name)", errstr.str(), 41);
190 std::stringstream errstr;
191 errstr <<
"Name " << rName <<
" is not a valid symbol";
192 throw Exception(
"SymbolTable::SetEntry(index,name)", errstr.str(), 43);
195 std::map<Idx,std::string>::iterator nit =
mNameMap.find(index);
213 std::map<Idx,std::string>::iterator it =
mNameMap.find(index);
221 std::map<std::string,Idx>::iterator it =
mIndexMap.find(rName);
231 if(
Size()==0)
return;
233 std::map<Idx,std::string>::iterator it, oit;
244 std::map<std::string,Idx>::const_iterator it =
mIndexMap.find(rName);
253 std::map<Idx,std::string>::const_iterator it =
mNameMap.find(index);
264 std::map<Idx,std::string>::const_iterator it =
mNameMap.find(index);
270 std::map<std::string,Idx>::const_iterator it =
mIndexMap.find(rName);
287 std::string label=rLabel;
288 if(label==
"") label=
"SymbolTable";
298 std::map< std::string, Idx >::const_iterator sit =
mIndexMap.begin();
316 std::string label=rLabel;
317 if(label==
"") label=
"SymbolTable";
323 while(!rTr.
Eos(label)) {
void RestrictDomain(const IndexSet &rDomain)
std::map< Idx, std::string > mNameMap
void SetDefaultSymbol(Idx index)
Idx LastIndex(void) const
std::map< std::string, Idx > mIndexMap
static SymbolTable * GlobalEventSymbolTablep(void)
std::string Symbol(Idx index) const
void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
const std::string & Name(void) const
static bool ValidSymbol(const std::string &rName)
void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
bool Exists(Idx index) const
void DoAssign(const SymbolTable &rSrc)
std::string UniqueSymbol(const std::string &rName) const
void SetEntry(Idx index, const std::string &rName)
Idx InsEntry(Idx index, const std::string &rName)
Idx Index(const std::string &rName) const
long int ReadInteger(void)
bool Eos(const std::string &rLabel)
void ReadEnd(const std::string &rLabel)
std::string ReadString(void)
void ReadBegin(const std::string &rLabel)
void WriteString(const std::string &rString)
void WriteEnd(const std::string &rLabel)
void WriteInteger(Idx index)
void WriteBegin(const std::string &rLabel)
bool Exists(const T &rElem) const
std::string ToStringInteger(Int number)