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


C++ Symbols::Clear方法代码示例

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


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

示例1: LoadFile

int Main::LoadFile(text file,
                   bool updateContext,
                   Context *importContext,
                   Symbols *importSymbols)
// ----------------------------------------------------------------------------
//   Load an individual file
// ----------------------------------------------------------------------------
{
    Tree_p tree = NULL;
    bool hadError = false;

    IFTRACE(fileload)
        std::cout << "Loading: " << file << "\n";

    // Find which source file we are referencing
    SourceFile &sf = files[file];

    // Parse program - Local parser to delete scanner and close file
    // This ensures positions are updated even if there is a 'load'
    // being called during execution.
    if (options.readSerialized)
    {
        if (!reader)
            reader = new Deserializer(std::cin);
        tree = reader->ReadTree();
        if (!reader->IsValid())
        {
            errors->Log(Error("Serialized stream cannot be read: $1")
                        .Arg(file));
            hadError = true;
            return hadError;
        }
    }
    else
    {
        utf8_ifstream ifs(file.c_str(), std::ios::in | std::ios::binary);
        Deserializer ds(ifs);
        tree = ds.ReadTree();
        if (!ds.IsValid())
        {
            std::string decrypted = MAIN->Decrypt(file.c_str());
            if (decrypted != "")
            {
                // Parse decrypted string as XL source
                IFTRACE(fileload)
                    std::cerr << "Info: file was succesfully decrypted\n";
                std::istringstream iss;
                iss.str(decrypted);
                Parser parser (iss, syntax, positions, topLevelErrors);
                tree = parser.Parse();
            }
            else
            {
                // Parse as XL source
                Parser parser (file.c_str(), syntax, positions, topLevelErrors);
                tree = parser.Parse();
            }
        }
        else
        {
            IFTRACE(fileload)
                std::cerr << "Info: file is in serialized format\n";
        }
    }

    if (options.writeSerialized)
    {
        if (!writer)
            writer = new Serializer(std::cout);
        if (tree)
            tree->Do(writer);
    }

    if (tree)
    {
        tree = Normalize(tree);
    }
    else
    {
        if (options.doDiff)
        {
            files[file] = SourceFile (file, NULL, NULL, NULL);
            hadError = false;
        }
    }

    // Create new symbol table for the file, or clear it if we had one
    Context *ctx = MAIN->context;
    Context *savedCtx = ctx;
    Symbols *syms = MAIN->globals;
    Symbols *savedSyms = syms;
    if (sf.context)
    {
        updateContext = false;
        ctx = sf.context;
        syms = sf.symbols;
        ctx->Clear();
        syms->Clear();
    }
    else
//.........这里部分代码省略.........
开发者ID:trustifier,项目名称:xlr,代码行数:101,代码来源:main.cpp


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