parser.cpp

来自「ICE-3.2 一个开源的中间件」· C++ 代码 · 共 92 行

CPP
92
字号
// **********************************************************************//// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.//// This copy of Ice is licensed to you under the terms described in the// ICE_LICENSE file included in this distribution.//// **********************************************************************#include <IceUtil/DisableWarnings.h>#include <Parser.h>using namespace std;//// The current bison/flex parser//Parser* parser = 0;Parser::Parser(){}Parser::~Parser(){}Complex::NodePtrParser::parse(const string& commands, bool debug){    extern int yydebug;    yydebug = debug ? 1 : 0;    _result = 0;    _errors = 0;    _buf = commands;    assert(!_buf.empty());    extern FILE* yyin;    yyin = 0;    assert(!parser);    parser = this;    yyparse();    parser = 0;    if(_errors)    {        return 0;    }    return _result;}voidParser::error(const char* s){    cerr << "error: " << s << endl;    _errors++;}voidParser::error(const std::string& s){    error(s.c_str());}voidParser::getInput(char* buf, int& result, int maxSize){    if(!_buf.empty())    {#if defined(_MSC_VER) && !defined(_STLP_MSVC)        // COMPILERBUG: Stupid Visual C++ defines min and max as macros        result = _MIN(maxSize, static_cast<int>(_buf.length()));#else        result = min(maxSize, static_cast<int>(_buf.length()));#endif        strncpy(buf, _buf.c_str(), result);        _buf.erase(0, result);    }    else    {        result = 0;    }}voidParser::setResult(const Complex::NodePtr& node){    _result = node;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?