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


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

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


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

示例1: parseKeyword

bool ScriptParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner)
{
    if (keyword==Scanner::K_while || keyword==Scanner::K_if || keyword==Scanner::K_elseif)
    {
        mControlParser.reset();
        if (mControlParser.parseKeyword (keyword, loc, scanner))
            scanner.scan (mControlParser);

        mControlParser.appendCode (mOutput.getCode());

        return true;
    }

    /// \todo add an option to disable this nonsense
    if (keyword==Scanner::K_endif)
    {
        // surplus endif
        getErrorHandler().warning ("endif without matching if/elseif", loc);

        SkipParser skip (getErrorHandler(), getContext());
        scanner.scan (skip);
        return true;
    }

    if (keyword==Scanner::K_end && mEnd)
    {
        return false;
    }

    mLineParser.reset();
    if (mLineParser.parseKeyword (keyword, loc, scanner))
        scanner.scan (mLineParser);

    return true;
}
开发者ID:TraurigeNarr,项目名称:openmw,代码行数:35,代码来源:scriptparser.cpp

示例2: parseWhileBody

    bool ControlParser::parseWhileBody (int keyword, const TokenLoc& loc, Scanner& scanner)
    {
        if (keyword==Scanner::K_endwhile)
        {
            Codes loop;

            Codes expr;
            mExprParser.append (expr);

            Generator::jump (loop, -static_cast<int> (mCodeBlock.size()+expr.size()));

            std::copy (expr.begin(), expr.end(), std::back_inserter (mCode));

            Codes skip;

            Generator::jumpOnZero (skip, mCodeBlock.size()+loop.size()+1);

            std::copy (skip.begin(), skip.end(), std::back_inserter (mCode));

            std::copy (mCodeBlock.begin(), mCodeBlock.end(), std::back_inserter (mCode));

            Codes loop2;

            Generator::jump (loop2, -static_cast<int> (mCodeBlock.size()+expr.size()+skip.size()));

            if (loop.size()!=loop2.size())
                throw std::logic_error (
                    "internal compiler error: failed to generate a while loop");

            std::copy (loop2.begin(), loop2.end(), std::back_inserter (mCode));

            mState = WhileEndwhileState;
            return true;
        }
        else if (keyword==Scanner::K_if || keyword==Scanner::K_while)
        {
            // nested
            ControlParser parser (getErrorHandler(), getContext(), mLocals, mLiterals);

            if (parser.parseKeyword (keyword, loc, scanner))
                scanner.scan (parser);

            parser.appendCode (mCodeBlock);

            return true;
        }
        else
        {
            mLineParser.reset();
            if (mLineParser.parseKeyword (keyword, loc, scanner))
                scanner.scan (mLineParser);

            return true;
        }
    }
开发者ID:A1-Triard,项目名称:openmw,代码行数:55,代码来源:controlparser.cpp

示例3: parseArguments

    void ExprParser::parseArguments (const std::string& arguments, Scanner& scanner,
        std::vector<Interpreter::Type_Code>& code, bool invert)
    {
        ExprParser parser (getErrorHandler(), getContext(), mLocals, mLiterals, true);
        StringParser stringParser (getErrorHandler(), getContext(), mLiterals);
        
        std::stack<std::vector<Interpreter::Type_Code> > stack;
        
        for (std::string::const_iterator iter (arguments.begin()); iter!=arguments.end();
            ++iter)
        {
            if (*iter=='S' || *iter=='c')
            {
                stringParser.reset();
                if (*iter=='c') stringParser.smashCase();
                scanner.scan (stringParser);            
                
                if (invert)
                {
                    std::vector<Interpreter::Type_Code> tmp;
                    stringParser.append (tmp);
                    
                    stack.push (tmp);
                }
                else
                    stringParser.append (code);
            }
            else
            {
                parser.reset();    
                scanner.scan (parser);

                std::vector<Interpreter::Type_Code> tmp;

                char type = parser.append (tmp);

                if (type!=*iter)
                    Generator::convert (tmp, type, *iter);
                    
                if (invert)
                    stack.push (tmp);
                else
                    std::copy (tmp.begin(), tmp.end(), std::back_inserter (code));
            }
        }
        
        while (!stack.empty())
        {
            std::vector<Interpreter::Type_Code>& tmp = stack.top();
        
            std::copy (tmp.begin(), tmp.end(), std::back_inserter (code));
        
            stack.pop();
        }
    }    
开发者ID:OndraK,项目名称:openmw,代码行数:55,代码来源:exprparser.cpp

示例4: main

int main(int argc, char** argv)
{
	if (argc<3)
	{
		cout << "Not enough arguments. You must provide a valid infile." << endl;
		return 0;
	}

	ofstream out;
  out.open(argv[2]);
	Scanner* s = new Scanner();
	try
	{
 		s->scan(argv[1]);
		print_toks(s->toks,out);
		out << "Total Tokens = " << s->toks.size() << endl;
  	out.close();
		delete s;
	}
	catch (exception& e)
	{
		print_toks(s->toks, out);
		// cout << e.what();
		out << e.what();
		out.close();
		delete s;
	}
}
开发者ID:bpachev,项目名称:CS_236,代码行数:28,代码来源:main.cpp

示例5: skip

bool Compiler::QuickFileParser::parseName (const std::string& name, const TokenLoc& loc,
    Scanner& scanner)
{
    SkipParser skip (getErrorHandler(), getContext());
    scanner.scan (skip);
    return true;
}
开发者ID:AAlderman,项目名称:openmw,代码行数:7,代码来源:quickfileparser.cpp

示例6: parseSpecial

    bool FileParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner)
    {
        if (code==Scanner::S_newline)
        {
            if (mState==BeginState)
            {
                // ignore empty lines
                return true;
            }

            if (mState==BeginCompleteState)
            {
                // parse the script body
                mScriptParser.reset();

                scanner.scan (mScriptParser);

                mState = EndNameState;
                scanner.allowNameStartingwithDigit();
                return true;
            }

            if (mState==EndCompleteState || mState==EndNameState)
            {
                // we are done here -> ignore the rest of the script
                return false;
            }
        }

        return Parser::parseSpecial (code, loc, scanner);
    }
开发者ID:ace13,项目名称:openmw,代码行数:31,代码来源:fileparser.cpp

示例7: runScanner

void ScannerPage::runScanner ()
{
  QString s;
  config.getData(Config::ScannerPath, s);
  QString s2("*");
  SymbolDialog *dialog = new SymbolDialog(this,
                                          s,
  					  s,
					  s2,
					  Q3FileDialog::ExistingFiles);
  dialog->setCaption(tr("Select scanners to run"));

  int rc = dialog->exec();

  if (rc == QDialog::Accepted)
  {
    QStringList l = dialog->selectedFiles();
    int loop;
    QDir dir;
    for (loop = 0; loop < (int) l.count(); loop++)
    {
      QFileInfo fi(l[loop]);
      Scanner *sdialog = new Scanner(fi.fileName(), chartIndex);
      connect(sdialog, SIGNAL(exitScanner()), this, SLOT(refreshList()));
      connect(sdialog, SIGNAL(message(QString)), this, SIGNAL(message(QString)));
      sdialog->show();
      sdialog->scan();
      delete sdialog;
    }
  }

  delete dialog;
}
开发者ID:DigitalPig,项目名称:qtstalker-qt4,代码行数:33,代码来源:ScannerPage.cpp

示例8: parseExpression

    void LineParser::parseExpression (Scanner& scanner, const TokenLoc& loc)
    {
        mExprParser.reset();

        if (!mExplicit.empty())
        {
            mExprParser.parseName (mExplicit, loc, scanner);
            if (mState==MemberState)
                mExprParser.parseSpecial (Scanner::S_member, loc, scanner);
            else
                mExprParser.parseSpecial (Scanner::S_ref, loc, scanner);
        }

        scanner.scan (mExprParser);

        char type = mExprParser.append (mCode);
        mState = EndState;

        switch (type)
        {
            case 'l':

                Generator::report (mCode, mLiterals, "%g");
                break;

            case 'f':

                Generator::report (mCode, mLiterals, "%f");
                break;

            default:

                throw std::runtime_error ("unknown expression result type");
        }
    }
开发者ID:rafis,项目名称:openmw,代码行数:35,代码来源:lineparser.cpp

示例9: parseName

bool ScriptParser::parseName (const std::string& name, const TokenLoc& loc,
                              Scanner& scanner)
{
    mLineParser.reset();
    if (mLineParser.parseName (name, loc, scanner))
        scanner.scan (mLineParser);

    return true;
}
开发者ID:TraurigeNarr,项目名称:openmw,代码行数:9,代码来源:scriptparser.cpp

示例10: parseProgram

Status* Parser::parseProgram(const string& code) {
    Scanner scanner;
    try {
         Status* s = scanner.scan(code, _tokens);
         if (s) {
             return s;
         }
    } catch (ErrorInfoHolder* error) {
        return new Status(error->getMessage(), error->getPosition());
    }
    return parseTopLevel();
}
开发者ID:nvmd,项目名称:spbau-mathvm,代码行数:12,代码来源:parser.cpp

示例11: parseName

    bool ControlParser::parseName (const std::string& name, const TokenLoc& loc, Scanner& scanner)
    {
        if (mState==IfBodyState || mState==IfElseifBodyState || mState==IfElseBodyState ||
            mState==WhileBodyState)
        {
            scanner.putbackName (name, loc);
            mLineParser.reset();
            scanner.scan (mLineParser);
            return true;
        }

        return Parser::parseName (name, loc, scanner);
    }
开发者ID:A1-Triard,项目名称:openmw,代码行数:13,代码来源:controlparser.cpp

示例12: parseKeyword

    bool ControlParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner)
    {
        if (mState==StartState)
        {
            if (keyword==Scanner::K_if || keyword==Scanner::K_elseif)
            {
                if (keyword==Scanner::K_elseif)
                    getErrorHandler().warning ("elseif without matching if", loc);

                mExprParser.reset();
                scanner.scan (mExprParser);

                mState = IfEndState;
                return true;
            }
            else if (keyword==Scanner::K_while)
            {
                mExprParser.reset();
                scanner.scan (mExprParser);

                mState = WhileEndState;
                return true;
            }
        }
        else if (mState==IfBodyState || mState==IfElseifBodyState || mState==IfElseBodyState ||
            mState==IfElseJunkState)
        {
            if (parseIfBody (keyword, loc, scanner))
                return true;
        }
        else if (mState==WhileBodyState)
        {
            if ( parseWhileBody (keyword, loc, scanner))
                return true;
        }

        return Parser::parseKeyword (keyword, loc, scanner);
    }
开发者ID:A1-Triard,项目名称:openmw,代码行数:38,代码来源:controlparser.cpp

示例13: parseExtInstMnemo

Inst ExtManager::parseExtInstMnemo(Scanner& scanner, Brigantine& bw, int* vx) const
{
    assert(scanner.peek().kind() == EExtInstName);

    // Parse mnemo prefix adding suffices until there is an extension which can handle it.
    // This prefix has the form <vendor>_<extension>

    string prefix = scanner.scan().text();
    while (!isMnemoPrefix(prefix) && scanner.peek().kind() == EExtInstSuff) 
    {
        prefix += scanner.scan().text();
    }

    // Parse remaining part of instruction mnemo (typically in the form <opcode>_<suff>)

    if (const Extension* e = getByPrefix(prefix)) return e->parseInstMnemo(prefix, scanner, bw, vx);

    // Enabled extensions failed to parse this mnemo.
    // Search for a disabled extension which might have handled it
    const char* s = 0;
    for (unsigned i = 0; i < size(); ++i)
    {
        if (!isEnabled[i] && (s = extension[i]->matchInstMnemo(prefix)) != 0)
        {
            scanner.syntaxError(string("Instruction \"") + s + "\" cannot be used (extension \"" + extension[i]->getName() + "\" is not enabled)");
            return Inst();
        }
    }

    // Extensions (including disabled) cannot handle this mnemo

    if (!hasEnabled()) scanner.scan(); // show offending token
    scanner.syntaxError("Undefined instruction");

    return Inst();
}
开发者ID:HSAFoundation,项目名称:HSAIL-Tools,代码行数:36,代码来源:HSAILExtManager.cpp

示例14: parseSpecial

bool ScriptParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner)
{
    if (code==Scanner::S_newline) // empty line
        return true;

    if (code==Scanner::S_open) /// \todo Option to switch this off
    {
        scanner.putbackSpecial (code, loc);
        return parseKeyword (Scanner::K_if, loc, scanner);
    }

    mLineParser.reset();
    if (mLineParser.parseSpecial (code, loc, scanner))
        scanner.scan (mLineParser);

    return true;
}
开发者ID:TraurigeNarr,项目名称:openmw,代码行数:17,代码来源:scriptparser.cpp

示例15: parseMnemoGcnMem

Inst parseMnemoGcnMem(unsigned opCode, Scanner& scanner, Brigantine& bw, int* vx) 
{
    OptionalU const vector  = scanner.tryEatToken(EMVector);
    string    const segment = scanner.scan().text();

    if (segment != AMD_GCN_SEGMENT_SUFF) scanner.syntaxError("missing or invalid segment name");

    int vx2 = -1;
    InstMem res = parseMnemoMem(opCode, scanner, bw, &vx2);
    if (res.segment() != BRIG_SEGMENT_FLAT) scanner.syntaxError("invalid segment");
    if (vx2 != 1) scanner.syntaxError("invalid vX suffix");

    res.segment() = BRIG_SEGMENT_AMD_GCN;
    if (vx) *vx = vector.isInitialized() ? vector.value() : 1;

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


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