本文整理汇总了C++中SymbolTable::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolTable::GetName方法的具体用法?C++ SymbolTable::GetName怎么用?C++ SymbolTable::GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolTable
的用法示例。
在下文中一共展示了SymbolTable::GetName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsBasicVar
bool IsBasicVar(SymbolItem &item,SymbolTable &table){
bool rect=false;
rect=(item.GetKind()== varsk || item.GetKind()== parask);
rect=rect&&(item.GetType()== charst || item.GetType()== integerst);
rect = rect ||(table.GetKind()== funcsk && table.GetName()==item.GetName() && TouchNextChar()!='(');
return rect;
}
示例2: CheckItem
bool CheckItem(string str,SymbolKind kind,SymbolType type,SymbolTable &table)
{
SymbolItem* item = table.GetItem(str);
if (item->GetKind()== parask && kind== varsk) return true;//if var is para then return true
if (kind== varsk && table.GetName()==str && table.GetKind()== funcsk) return true;//if var is the name of this table, and current table is a function then return true.
if (item->GetKind()!=kind) return false;
if (item->GetType()!=type) return false;
return true;
}
示例3: SubProgram
void SubProgram(SymbolTable &table)
{
if (symbol==CONSTTK) ConstDeclaration(table);
if (symbol==VARTK) VarDeclaration(table);
while (symbol==PROCETK || symbol==FUNCTK) {
if (symbol==PROCETK) ProcDeClaration(table);
else if (symbol==FUNCTK) FuncDeClaration(table);
}
if (symbol!=BEGINTK) ErrorHandler("SubProgram should begin with begin"); //Throw Error while define Subprogram, can not find begin tk.
if (table.GetKind()==procsk) interResult<<"Proc ";
if (table.GetKind()==funcsk) interResult<<"Func ";
interResult<<table.GetName();
for (int i=0;i!=ptable;++i) if ((&symbolTableList[i])==&table) {
interResult<<' '<<i<<endl;
break;
}
CompoundStatement(table);
table.Push(table.GetName(), varsk);
table.SetType(table.GetFuncType());
table.FillBack();
}
示例4: AssignStatement
void AssignStatement(SymbolTable &table)
{
Emit tmp;
tmp.SetTP( assignet);
if (symbol!=IDEN) ErrorHandler("Assign should have iden to be assigned");//Error assign should have iden
SymbolItem* item = table.GetItem(token);
if (item==NULL && token!=table.GetName()) ErrorHandler("iden not exist while assign");//Error iden not exist;
if (IsBasicVar(*item, table)) tmp.SetD1(token);
else if (IsArrayVar(*item)) tmp.SetD1(GetArrayOffset(table));
else ;//Error This must be somthing I don't expect.
GetNextSym();
if (symbol!=ASSIGN) ErrorHandler("assign must have :=") ;//Error should be assign
GetNextSym();
tmp.SetS1(Expression(table));
tmp.emitResult();
}