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


C++ Scanner::eatToken方法代码示例

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


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

示例1: Factor_Tail

//  Factor_Tail-> "*" power Factor_Tail |  "/"" power Factor_Tail | Epsolon
void Parser::Factor_Tail()
{
    switch (scanner.nextToken()) {
        case T_MULTIPLY:        // *
        {
            scanner.eatToken(T_MULTIPLY);
            Power();
            if (scanner.nextToken() == T_MULTIPLY || scanner.nextToken() == T_DIVIDE)
                Factor_Tail();
            break;
        }
        case T_DIVIDE:          // /
        {
            scanner.eatToken(T_DIVIDE);
            Power();
            if (scanner.nextToken() == T_MULTIPLY || scanner.nextToken() == T_DIVIDE)
                Factor_Tail();
            break;
        }
        case T_EOF:
            break;  
        default:
        {
            parseError(scanner.lineNumber(), scanner.nextToken());
            break;
        }
    }

}
开发者ID:freddyyang,项目名称:scanner_parser_calc,代码行数:30,代码来源:calculator.cpp

示例2: Exp_Tail

//Exp_Tail -> "+" Factor Exp_Tail | "-" Factor Exp_Tail | EPSOLON
void Parser::Exp_Tail()
{
    switch (scanner.nextToken())
    {
        case T_PLUS:            // +
        {
            scanner.eatToken(T_PLUS);
            Factor();
            if (scanner.nextToken() == T_PLUS || scanner.nextToken() == T_MINUS)
                Exp_Tail();
            break;
        }
        case T_MINUS:           // -
        {
            scanner.eatToken(T_MINUS);
            Factor();
            if (scanner.nextToken() == T_PLUS || scanner.nextToken() == T_MINUS)
                Exp_Tail();
            break;
        }
        case T_EOF:
            break;  
        default:
        {
            parseError(scanner.lineNumber(), scanner.nextToken());
            break;
        }
    }

}
开发者ID:freddyyang,项目名称:scanner_parser_calc,代码行数:31,代码来源:calculator.cpp

示例3: parseMnemoGcnAddr

Inst parseMnemoGcnAddr(unsigned opCode, Scanner& scanner, Brigantine& bw, int* vx)
{
    unsigned const type = scanner.eatToken(EMType);
    
    scanner.eatToken(EMNone);

    InstAddr res = bw.addInst<InstAddr>(opCode);

    res.segment() = BRIG_SEGMENT_AMD_GCN;
    res.type() = type;

    return res;
}
开发者ID:HSAFoundation,项目名称:HSAIL-Tools,代码行数:13,代码来源:gcn.cpp

示例4: match

void Parser::match(token current_token) {
    if(current_token == lookahead) {
      scanner.eatToken(current_token);
      lookahead = scanner.nextToken();
     }
     else {
       mismatchError(scanner.lineNumber(),current_token , lookahead);
       
     }       
}
开发者ID:sarahdarwiche,项目名称:Compiler_Projects,代码行数:10,代码来源:calculator.cpp

示例5: parseMnemoGcnAtomic

Inst parseMnemoGcnAtomic(unsigned opCode, Scanner& scanner, Brigantine& bw, int*)
{
    unsigned  const atomicOperation = scanner.eatToken(EMAtomicOp);
    OptionalU const segment         = scanner.tryEatToken(EMSegment);
    unsigned  const memoryOrder     = scanner.eatToken(EMMemoryOrder);
    unsigned  const memoryScope     = scanner.eatToken(EMMemoryScope);
    OptionalU const equivClass      = tryParseEquiv(scanner);
    unsigned  const type            = scanner.eatToken(EMType);
    
    scanner.eatToken(EMNone);

    InstAtomic res = bw.addInst<InstAtomic>(opCode,type);

    res.atomicOperation() = atomicOperation;
    res.segment()         = BrigSegment(segment.isInitialized() ? segment.value() : BRIG_SEGMENT_AMD_GCN);
    res.equivClass()      = equivClass.isInitialized() ? equivClass.value() : 0;
    res.memoryOrder()     = memoryOrder;
    res.memoryScope()     = memoryScope;
    return res;
}
开发者ID:HSAFoundation,项目名称:HSAIL-Tools,代码行数:20,代码来源:gcn.cpp

示例6: Final

//  final -> Num | "(" Expression ")" | m [ Expression ]
void Parser:: Final()
{
    switch (scanner.nextToken())
    {
        case T_OPENPAREN:       // (
        {
            scanner.eatToken(T_OPENPAREN);
            
            switch(scanner.nextToken())
            {
                case T_M:
                case T_NUMBER:
                case T_OPENPAREN:
                    Expression();
                case T_EOF:
                    break;
            }



            scanner.eatToken(T_CLOSEPAREN);
            break;
        }
        case T_M:               // m
        {
            scanner.eatToken(T_M);
            scanner.eatToken(T_OPENBRACKET);
            

            switch(scanner.nextToken())
            {
                case T_M:
                case T_NUMBER:
                case T_OPENPAREN:
                    Expression();
                case T_EOF:
                    break;
            }



            scanner.eatToken(T_CLOSEBRACKET);
            break;
        }
        case T_NUMBER:          // num
        {
            scanner.eatToken(T_NUMBER);
            num_parser = scanner.getNumberValue(); 
            break;
        }
        case T_EOF:
            break;  
        default:
        {
            parseError(scanner.lineNumber(), scanner.nextToken());
            break;
        }
    }
}
开发者ID:freddyyang,项目名称:scanner_parser_calc,代码行数:60,代码来源:calculator.cpp

示例7: main

int main(int argc, char* argv[]) {
    if (argc == 2 && (strcmp(argv[1], "-s") == 0)) {
        Scanner scanner;
        while (scanner.nextToken() != T_EOF) {
            std::cout << tokenToString(scanner.nextToken()) << " ";
            scanner.eatToken(scanner.nextToken());
        }
        std::cout<<std::endl;
    } else if (argc == 2 && (strcmp(argv[1], "-e") == 0)) {
        Parser parser(true);
        parser.parse();
    } else {
        Parser parser(false);
        parser.parse();
    }
    return 0;
}
开发者ID:sarahdarwiche,项目名称:Compiler_Projects,代码行数:17,代码来源:calculator.cpp

示例8: Power_Tail

//  power_Tail -> "**" final power_Tail | Epsilon
void Parser::Power_Tail()
{
    switch (scanner.nextToken()) {
        case T_POWER:           // **
        {
            scanner.eatToken(T_POWER);
            Final();
            if (scanner.nextToken() == T_POWER)
                Power_Tail();
            break;
        }
        case T_EOF:
            break;  
        default:
        {
            parseError(scanner.lineNumber(), scanner.nextToken());
            break;
        }
    }
}
开发者ID:freddyyang,项目名称:scanner_parser_calc,代码行数:21,代码来源:calculator.cpp

示例9: Term

//  Term -> ; Statement Term | Epsolon
void Parser::Term()
{
    //cout<< tokenToString(scanner.nextToken()) <<endl;
    switch (scanner.nextToken()) {
        case T_SEMICOLON:       //;
        {
            scanner.eatToken(T_SEMICOLON);
            Statement();
            if (scanner.nextToken() == T_SEMICOLON)
                Term();
            //Term();
            break;
        }
        case T_EOF:
            break;
        default:
        {
            parseError(scanner.lineNumber(), scanner.nextToken());
            break;
        }
    }
}
开发者ID:freddyyang,项目名称:scanner_parser_calc,代码行数:23,代码来源:calculator.cpp

示例10: Statement

// Statement  -> "m" "[" Expression "]" "=" Expression | print Expression
void Parser::Statement()
{
    switch(scanner.nextToken())
    {
        case T_M:
        {

            scanner.eatToken(T_M);
            scanner.eatToken(T_OPENBRACKET);


            switch(scanner.nextToken())
            {
                case T_M:
                case T_NUMBER:
                case T_OPENPAREN:
                    Expression();
                case T_EOF:
                    break;
            }

            scanner.eatToken(T_CLOSEBRACKET);
            scanner.eatToken(T_EQUALS);
            

            switch(scanner.nextToken())
            {
                case T_M:
                case T_NUMBER:
                case T_OPENPAREN:
                    Expression();
                case T_EOF:
                    break;
            }


            break;
        }


        case T_PRINT:
        {
            scanner.eatToken(T_PRINT);
            switch(scanner.nextToken())
            {
                case T_M:
                case T_NUMBER:
                case T_OPENPAREN:
                    Expression();
                case T_EOF:
                    break;
            }
            break;
        }
        case T_EOF:
            break;
        default:
        {
            parseError(scanner.lineNumber(), scanner.nextToken());
            break;
        }
  }
}
开发者ID:freddyyang,项目名称:scanner_parser_calc,代码行数:64,代码来源:calculator.cpp


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