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


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

本文整理汇总了C++中SymbolTable::FillBack方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolTable::FillBack方法的具体用法?C++ SymbolTable::FillBack怎么用?C++ SymbolTable::FillBack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SymbolTable的用法示例。


在下文中一共展示了SymbolTable::FillBack方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetParaList

int GetParaList(SymbolTable &table)
{
    bool ispara=false;
    int num=0;//The number of para
    if (symbol==VARTK) {
        ispara=true;
        GetNextSym();
    }
    do {
        if (symbol!=IDEN) ErrorHandler("para list should split vars via ,");//Error while define paralist ,should have iden
        if (ispara) table.Push(token,  parask);
        else table.Push(token,  varsk);
        num++;
        GetNextSym();
        if (symbol==COLON) break;
        if (symbol!=COMMA) ErrorHandler("para list should split vars via ,");//Error iden should be split by comma
        GetNextSym();
    } while (true);
    GetNextSym();
    if (symbol==INTTK) table.SetType( integerst);
    else if (symbol==CHARTK) table.SetType( charst);
    else ;//Error should have basic type
    table.FillBack();
    GetNextSym();
    if (symbol==SEMICN) {
        GetNextSym();
        num+=GetParaList(table);
    }
    return num;
}
开发者ID:junpengxiao,项目名称:PL0Compiler,代码行数:30,代码来源:Parser.cpp

示例2: 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

示例3: VarDefinition

void VarDefinition(SymbolTable &table)
{
    if (symbol!=IDEN) ErrorHandler("Error defination shold begin with iden");//Throw Error while define var, expect iden
    table.Push(token,  varsk);
    do {
        GetNextSym();
        if (symbol==COLON) break;
        if (symbol!=COMMA) ErrorHandler("multi-var should be seperate via ,");
        GetNextSym();
        if (symbol!=IDEN) ErrorHandler("Error defination should be iden, but you used "+token); //throw error while define var
        table.Push(token,  varsk);
    } while (true);
    GetNextSym();
    if (symbol==INTTK) table.SetType( integerst);
    else if (symbol==CHARTK) table.SetType( charst);
    //table.SetKind(varsk);
    else if (symbol==ARRAYTK) {
        GetNextSym();
        if (symbol!=LBRACK) ErrorHandler("Error while define arr,miss [");//Throw Error expect [
        GetNextSym();
        if (symbol!=INTCON) ErrorHandler("[k] k should be number");// Throw Error expect number
        table.SetTypeValue( arrOfCh, number);
        GetNextSym();
        if (symbol!=RBRACK) ErrorHandler("define arr, miss ]");//Throw Error expect ]
        GetNextSym();
        if (symbol!=OFTK) ErrorHandler("define arr miss of");//Throw Error expect of
        GetNextSym();
        if (symbol!=INTTK && symbol!=CHARTK) ErrorHandler("define arr miss char or integer"); //Throw error expect char or integer
        if (symbol==INTTK) table.SetType( arrOfInt);
    } else ErrorHandler("var type illegal");
    table.FillBack();
    GetNextSym();
    if (symbol==IDEN) ErrorHandler("miss ;");
}
开发者ID:junpengxiao,项目名称:PL0Compiler,代码行数:34,代码来源:Parser.cpp

示例4: NextTempName

string NextTempName(SymbolTable &table)
{
    string rect="ttemp";
    rect=rect+IntToString(tempGenerator++);
    table.Push(rect, varsk);
    table.SetType(integerst);
    table.FillBack();
    return rect;
}
开发者ID:junpengxiao,项目名称:PL0Compiler,代码行数:9,代码来源:Parser.cpp

示例5: ConstDefinition

void ConstDefinition(SymbolTable &table)
{
    if (symbol!=IDEN) ErrorHandler("Const defination shoule begin with iden");//Throw Error while define const value
    table.Push(token,  constsk);
    GetNextSym();
    if (symbol!=EQL) ErrorHandler("Const defination should use = as symbol");//Throw Error while define const value
    GetNextSym();
    if (symbol==CHARCON) {
      table.SetTypeValue( charst, (int)token[0]);
      table.FillBack();
      GetNextSym();
      return;
    }
    if (symbol==MINU) {
        GetNextSym();
        number*=-1;
    } else if (symbol==PLUS) GetNextSym();
    if (symbol!=INTCON) ErrorHandler("Const should be integer or char");//throw Error while define int const
    table.SetTypeValue( integerst, number);
    table.FillBack();
    GetNextSym();
}
开发者ID:junpengxiao,项目名称:PL0Compiler,代码行数:22,代码来源:Parser.cpp

示例6: 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

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


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