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


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

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


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

示例1: parseKeyword

    bool Parser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner)
    {
        if (!(mOptional && mEmpty))
            reportSeriousError ("Unexpected keyword", loc);
        else
            scanner.putbackKeyword (keyword, loc);

        return false;
    }
开发者ID:AlfredBroda,项目名称:openmw,代码行数:9,代码来源:parser.cpp

示例2: skip

bool Compiler::QuickFileParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner)
{
    if (keyword==Scanner::K_end)
        return false;

    if (keyword==Scanner::K_short || keyword==Scanner::K_long || keyword==Scanner::K_float)
    {
        mDeclarationParser.reset();
        scanner.putbackKeyword (keyword, loc);
        scanner.scan (mDeclarationParser);
        return true;
    }

    SkipParser skip (getErrorHandler(), getContext());
    scanner.scan (skip);
    return true;
}
开发者ID:AAlderman,项目名称:openmw,代码行数:17,代码来源:quickfileparser.cpp

示例3: parseSpecial

    bool ExprParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner)
    {
        if (!mExplicit.empty())
        {
            if (mRefOp && code==Scanner::S_open)
            {
                /// \todo add option to disable this workaround
                mOperators.push_back ('(');
                mTokenLoc = loc;
                return true;
            }

            if (!mRefOp && code==Scanner::S_ref)
            {
                mRefOp = true;
                return true;
            }

            if (!mMemberOp && code==Scanner::S_member)
            {
                mMemberOp = true;
                return true;
            }

            return Parser::parseSpecial (code, loc, scanner);
        }

        if (code==Scanner::S_comma)
        {
            mTokenLoc = loc;

            if (mFirst)
            {
                // leading comma
                mFirst = false;
                return true;
            }

            // end marker
            scanner.putbackSpecial (code, loc);
            return false;
        }

        mFirst = false;

        if (code==Scanner::S_newline)
        {
            // end marker
            mTokenLoc = loc;
            scanner.putbackSpecial (code, loc);
            return false;
        }

        if (code==Scanner::S_minus && mNextOperand)
        {
            // unary
            mOperators.push_back ('m');
            mTokenLoc = loc;
            return true;
        }

        if (code==Scanner::S_open)
        {
            if (mNextOperand)
            {
                mOperators.push_back ('(');
                mTokenLoc = loc;
                return true;
            }
            else
            {
                // no comma was used between arguments
                scanner.putbackKeyword (code, loc);
                return false;
            }
        }

        if (code==Scanner::S_close && !mNextOperand)
        {
            if (isOpen())
            {
                close();
                return true;
            }

            mTokenLoc = loc;
            scanner.putbackSpecial (code, loc);
            return false;
        }

        if (!mNextOperand)
        {
            mTokenLoc = loc;
            char c = 0; // comparison

            switch (code)
            {
                case Scanner::S_plus: c = '+'; break;
                case Scanner::S_minus: c = '-'; break;
                case Scanner::S_mult: pushBinaryOperator ('*'); return true;
//.........这里部分代码省略.........
开发者ID:PLkolek,项目名称:openmw,代码行数:101,代码来源:exprparser.cpp

示例4: parseKeyword


//.........这里部分代码省略.........
                return true;
            }
            else if (keyword==Scanner::K_random)
            {
                start();

                mTokenLoc = loc;
                parseArguments ("l", scanner);

                Generator::random (mCode);
                mOperands.push_back ('l');

                mNextOperand = false;
                return true;
            }
            else if (keyword==Scanner::K_scriptrunning)
            {
                start();

                mTokenLoc = loc;
                parseArguments ("c", scanner);

                Generator::scriptRunning (mCode);
                mOperands.push_back ('l');

                mNextOperand = false;
                return true;
            }
            else if (keyword==Scanner::K_getdistance)
            {
                start();

                mTokenLoc = loc;
                parseArguments ("c", scanner);

                Generator::getDistance (mCode, mLiterals, "");
                mOperands.push_back ('f');

                mNextOperand = false;
                return true;
            }
            else if (keyword==Scanner::K_getsecondspassed)
            {
                start();

                mTokenLoc = loc;

                Generator::getSecondsPassed (mCode);
                mOperands.push_back ('f');

                mNextOperand = false;
                return true;
            }
            else if (keyword==Scanner::K_getdisabled)
            {
                start();

                mTokenLoc = loc;

                Generator::getDisabled (mCode, mLiterals, "");
                mOperands.push_back ('l');

                mNextOperand = false;
                return true;
            }
            else
            {
                // check for custom extensions
                if (const Extensions *extensions = getContext().getExtensions())
                {
                    start();

                    char returnType;
                    std::string argumentType;

                    bool hasExplicit = false;

                    if (extensions->isFunction (keyword, returnType, argumentType, hasExplicit))
                    {
                        mTokenLoc = loc;
                        int optionals = parseArguments (argumentType, scanner);

                        extensions->generateFunctionCode (keyword, mCode, mLiterals, "", optionals);
                        mOperands.push_back (returnType);

                        mNextOperand = false;
                        return true;
                    }
                }
            }
        }
        else
        {
            // no comma was used between arguments
            scanner.putbackKeyword (keyword, loc);
            return false;
        }

        return Parser::parseKeyword (keyword, loc, scanner);
    }
开发者ID:PLkolek,项目名称:openmw,代码行数:101,代码来源:exprparser.cpp

示例5: parseKeyword


//.........这里部分代码省略.........
                        std::auto_ptr<ErrorDowngrade> errorDowngrade (0);
                        if (Misc::StringUtils::lowerCase (loc.mLiteral)=="positioncell")
                            errorDowngrade.reset (new ErrorDowngrade (getErrorHandler()));

                        std::vector<Interpreter::Type_Code> code;
                        optionals = mExprParser.parseArguments (argumentType, scanner, code);
                        mCode.insert (mCode.end(), code.begin(), code.end());
                        extensions->generateInstructionCode (keyword, mCode, mLiterals,
                            mExplicit, optionals);
                    }
                    catch (const SourceException& exception)
                    {
                        // Ignore argument exceptions for positioncell.
                        /// \todo add option to disable this
                        if (Misc::StringUtils::lowerCase (loc.mLiteral)=="positioncell")
                        {
                            SkipParser skip (getErrorHandler(), getContext());
                            scanner.scan (skip);
                            return false;
                        }

                        throw;
                    }

                    mState = EndState;
                    return true;
                }
            }

            if (mAllowExpression)
            {
                if (keyword==Scanner::K_getdisabled || keyword==Scanner::K_getdistance)
                {
                    scanner.putbackKeyword (keyword, loc);
                    parseExpression (scanner, loc);
                    mState = EndState;
                    return true;
                }

                if (const Extensions *extensions = getContext().getExtensions())
                {
                    char returnType;
                    std::string argumentType;

                    bool hasExplicit = !mExplicit.empty();

                    if (extensions->isFunction (keyword, returnType, argumentType, hasExplicit))
                    {
                        if (!hasExplicit && !mExplicit.empty())
                        {
                            getErrorHandler().warning ("stray explicit reference (ignoring it)", loc);
                            mExplicit.clear();
                        }

                        scanner.putbackKeyword (keyword, loc);
                        parseExpression (scanner, loc);
                        mState = EndState;
                        return true;
                    }
                }
            }
        }

        if (mState==ExplicitState)
        {
            // drop stray explicit reference
开发者ID:rafis,项目名称:openmw,代码行数:67,代码来源:lineparser.cpp

示例6: parseKeyword

    bool LineParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner)
    {
        if (mState==BeginState || mState==ExplicitState)
        {
            switch (keyword)
            {
                case Scanner::K_enable:

                    Generator::enable (mCode, mLiterals, mExplicit);
                    mState = EndState;
                    return true;

                case Scanner::K_disable:

                    Generator::disable (mCode, mLiterals, mExplicit);
                    mState = EndState;
                    return true;
            }

            // check for custom extensions
            if (const Extensions *extensions = getContext().getExtensions())
            {
                std::string argumentType;

                if (extensions->isInstruction (keyword, argumentType, mState==ExplicitState))
                {
                    int optionals = mExprParser.parseArguments (argumentType, scanner, mCode, true);

                    extensions->generateInstructionCode (keyword, mCode, mLiterals, mExplicit, optionals);
                    mState = EndState;
                    return true;
                }
            }

            if (mAllowExpression)
            {
                if (keyword==Scanner::K_getdisabled || keyword==Scanner::K_getdistance)
                {
                    scanner.putbackKeyword (keyword, loc);
                    parseExpression (scanner, loc);
                    mState = EndState;
                    return true;
                }

                if (const Extensions *extensions = getContext().getExtensions())
                {
                    char returnType;
                    std::string argumentType;

                    if (extensions->isFunction (keyword, returnType, argumentType,
                        !mExplicit.empty()))
                    {
                        scanner.putbackKeyword (keyword, loc);
                        parseExpression (scanner, loc);
                        mState = EndState;
                        return true;
                    }
                }
            }
        }

        if (mState==BeginState)
        {
            switch (keyword)
            {
                case Scanner::K_short: mState = ShortState; return true;
                case Scanner::K_long: mState = LongState; return true;
                case Scanner::K_float: mState = FloatState; return true;
                case Scanner::K_set: mState = SetState; return true;
                case Scanner::K_messagebox: mState = MessageState; return true;

                case Scanner::K_return:

                    Generator::exit (mCode);
                    mState = EndState;
                    return true;

                case Scanner::K_startscript:

                    mExprParser.parseArguments ("c", scanner, mCode, true);
                    Generator::startScript (mCode);
                    mState = EndState;
                    return true;

                case Scanner::K_stopscript:

                    mExprParser.parseArguments ("c", scanner, mCode, true);
                    Generator::stopScript (mCode);
                    mState = EndState;
                    return true;
            }
        }
        else if (mState==SetLocalVarState && keyword==Scanner::K_to)
        {
            mExprParser.reset();
            scanner.scan (mExprParser);

            std::vector<Interpreter::Type_Code> code;
            char type = mExprParser.append (code);

//.........这里部分代码省略.........
开发者ID:darkf,项目名称:openmw,代码行数:101,代码来源:lineparser.cpp

示例7: parseKeyword


//.........这里部分代码省略.........
                Generator::squareRoot (mCode);
                mOperands.push_back ('f');
                
                mNextOperand = false;
                return true;
            }
            else if (keyword==Scanner::K_menumode)
            {
                mTokenLoc = loc;
                
                Generator::menuMode (mCode);
                mOperands.push_back ('l');
                
                mNextOperand = false;
                return true;
            }
            else if (keyword==Scanner::K_random)
            {
                mTokenLoc = loc;        
                parseArguments ("l", scanner);

                Generator::random (mCode);
                mOperands.push_back ('l');
                
                mNextOperand = false;
                return true;            
            }
            else if (keyword==Scanner::K_scriptrunning)
            {
                mTokenLoc = loc;
                parseArguments ("c", scanner);
                
                Generator::scriptRunning (mCode);
                mOperands.push_back ('l');
                
                mNextOperand = false;
                return true;
            }             
            else if (keyword==Scanner::K_getdistance)
            {
                mTokenLoc = loc;
                parseArguments ("c", scanner);
                
                Generator::getDistance (mCode, mLiterals, "");
                mOperands.push_back ('f');
                
                mNextOperand = false;
                return true;
            }                       
            else if (keyword==Scanner::K_getsecondspassed)
            {
                mTokenLoc = loc;        

                Generator::getSecondsPassed (mCode);
                mOperands.push_back ('f');
                
                mNextOperand = false;
                return true;            
            }
            else if (keyword==Scanner::K_getdisabled)
            {
                mTokenLoc = loc;        

                Generator::getDisabled (mCode, mLiterals, "");
                mOperands.push_back ('l');
                
                mNextOperand = false;
                return true;            
            }
            else
            {
                // check for custom extensions
                if (const Extensions *extensions = getContext().getExtensions())
                {
                    char returnType;
                    std::string argumentType;
                    
                    if (extensions->isFunction (keyword, returnType, argumentType, false))
                    {
                        mTokenLoc = loc;
                        parseArguments (argumentType, scanner);
                        
                        extensions->generateFunctionCode (keyword, mCode, mLiterals, "");
                        mOperands.push_back (returnType);
                        
                        mNextOperand = false;
                        return true;
                    }
                }
            }
        }
        else
        {
            // no comma was used between arguments
            scanner.putbackKeyword (keyword, loc);
            return false;
        }
        
        return Parser::parseKeyword (keyword, loc, scanner);
    }
开发者ID:OndraK,项目名称:openmw,代码行数:101,代码来源:exprparser.cpp


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