本文整理汇总了C++中SymbolTable::GetLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolTable::GetLevel方法的具体用法?C++ SymbolTable::GetLevel怎么用?C++ SymbolTable::GetLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolTable
的用法示例。
在下文中一共展示了SymbolTable::GetLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FuncHeader
void FuncHeader(SymbolTable &table)
{
if (symbol!=FUNCTK) ErrorHandler("func should begin with function");//Error symbol should be func
GetNextSym();
if (symbol!=IDEN) ErrorHandler("function should have iden as name");//Error function should have iden
symbolTableList[ptable].ReInitial(table.GetLevel()+1,&table,token, funcsk);
ptable++;
table.Push(token, funcsk);
GetNextSym();
if (symbol!=LPARENT) ErrorHandler("function define should have ( ");//Error function should have (
int num=0;
GetNextSym();
if (symbol!=RPARENT) num=GetParaList(symbolTableList[ptable-1]);
symbolTableList[ptable-1].SetParaNum(num);
if (symbol!=RPARENT) ErrorHandler("function defien should have )");//Error function should have )
GetNextSym();
if (symbol!=COLON) ErrorHandler("function define should have :");//Error fcuntion should have return value
GetNextSym();
if (symbol==INTTK) table.SetType( integerst);
else if (symbol==CHARTK) {
table.SetType( charst);
symbolTableList[ptable-1].SetFuncType(charst);
}
else ;//Error function should have return value;
table.SetValue(num);
table.FillBack();
GetNextSym();
if (symbol!=SEMICN) ErrorHandler("function define should have integer or char as type");//Error function should end with ;
GetNextSym();
}
示例2: ProcHeader
void ProcHeader(SymbolTable &table)
{
if (symbol!=PROCETK) ErrorHandler("Proc should begin with procedure");//Error procedure should begin with procedure
GetNextSym();
if (symbol!=IDEN) ErrorHandler("procedue should have iden as name");//Error procedure should have iden
symbolTableList[ptable].ReInitial(table.GetLevel()+1,&table,token, procsk);
ptable++;
table.Push(token, procsk);
GetNextSym();
if (symbol!=LPARENT) ErrorHandler("proc define should have (");//Error procedure should have (
int num=0;//The number of para
GetNextSym();
if (symbol!=RPARENT) num=GetParaList(symbolTableList[ptable-1]);
symbolTableList[ptable-1].SetParaNum(num);
table.SetTypeValue( integerst, num);
table.FillBack();
if (symbol!=RPARENT) ErrorHandler("Proc define should have )") ;//Error procedure should have )
GetNextSym();
if (symbol!=SEMICN) ErrorHandler("Proc head def should end with ;");//Error Procedure should end with ;
GetNextSym();
}