当前位置: 首页>>代码示例>>C++>>正文


C++ SymbolTable::GetLevel方法代码示例

本文整理汇总了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();
}
开发者ID:junpengxiao,项目名称:PL0Compiler,代码行数:30,代码来源:Parser.cpp

示例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();
}
开发者ID:junpengxiao,项目名称:PL0Compiler,代码行数:21,代码来源:Parser.cpp


注:本文中的SymbolTable::GetLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。