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


C++ Symbol::clear方法代码示例

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


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

示例1: error

ParseResults parser::SLR1::parse(const std::vector<Token>& tokens) {
    assert(canParse());
    ParseResults results;
    std::stack<std::size_t> stateStack;
    stateStack.push(0);
    std::size_t inputPointer = 0;
    Symbol nonTerminalBuffer;
    while (true) {
        TokenType currToken;
        if (!nonTerminalBuffer.empty()) {
            currToken = nonTerminalBuffer;
        } else if (inputPointer < tokens.size()) {
            currToken = tokens[inputPointer].type;
        } else {
            currToken = "EOS";
        }
        auto& currState = table[stateStack.top()];
        if (currState.count(currToken) == 0) {
            return error(tokens, inputPointer, "Unexpected token '" + currToken + "'");
        }

        AscendingAction& action = currState[currToken];
        switch (action.action) {
            case Action::ACCEPT:
                results.accepted = true;
                return results;
            case Action::GOTO:
                stateStack.push(action.target);
                nonTerminalBuffer.clear();
                break;
            case Action::REDUCE: {
                const Production& prod = getCFG()[action.target];
                for (std::size_t i = 0; i < prod.size(); i++) {
                    stateStack.pop();
                }
                nonTerminalBuffer = prod.getName();
                break;
            }
            case Action::SHIFT:
                stateStack.push(action.target);
                inputPointer++;
                break;
            default:
                assert(false);
        }
    }
}
开发者ID:Ghabriel,项目名称:FormalLanguageUtils,代码行数:47,代码来源:SLR1.cpp

示例2: execute

int ReferencesJob::execute()
{
    const bool rename = queryFlags() & QueryMessage::Rename;
    std::shared_ptr<Project> proj = project();
    if (!proj)
        return 1;
    Set<Symbol> refs;
    Map<Location, std::pair<bool, CXCursorKind> > references;
    if (!symbolName.isEmpty()) {
        const bool hasFilter = QueryJob::hasFilter();
        auto inserter = [this, hasFilter](Project::SymbolMatchType type, const String &string, const Set<Location> &locs) {
            if (type == Project::StartsWith) {
                const size_t paren = string.indexOf('(');
                if (paren == String::npos || paren != symbolName.size() || RTags::isFunctionVariable(string))
                    return;
            }

            for (const auto &l : locs) {
                if (!hasFilter || filter(l.path())) {
                    locations.insert(l);
                }
            }
        };
        proj->findSymbols(symbolName, inserter, queryFlags());
    }
    const bool declarationOnly = queryFlags() & QueryMessage::DeclarationOnly;
    const bool definitionOnly = queryFlags() & QueryMessage::DefinitionOnly;
    Location startLocation;
    bool first = true;
    for (auto it = locations.begin(); it != locations.end(); ++it) {
        const Location pos = *it;
        Symbol sym = proj->findSymbol(pos);
        if (sym.isNull())
            continue;
        if (first && !(queryFlags() & QueryMessage::NoSortReferencesByInput)) {
            first = false;
            startLocation = sym.location;
        }

        if (sym.isReference()) {
            const Symbol target = proj->findTarget(sym);
            if (!target.isNull() && target.kind != CXCursor_MacroExpansion)
                sym = target;
        }
        if (sym.isNull())
            continue;

        if (rename && sym.isConstructorOrDestructor()) {
            const Location loc = sym.location;
            sym.clear();
            const Set<String> usrs = proj->findTargetUsrs(loc);
            for (const String &usr : usrs) {
                for (const Symbol &s : proj->findByUsr(usr, loc.fileId(), Project::ArgDependsOn, loc)) {
                    if (s.isClass()) {
                        sym = s;
                        if (s.isDefinition())
                            break;
                    }
                }
            }

            if (sym.isNull())
                continue;
        }
        if (queryFlags() & QueryMessage::AllReferences) {
            const Set<Symbol> all = proj->findAllReferences(sym);
            for (const auto &symbol : all) {
                if (rename) {
                    if (symbol.kind == CXCursor_MacroExpansion && sym.kind != CXCursor_MacroDefinition)
                        continue;
                    if (symbol.flags & Symbol::AutoRef)
                        continue;
                } else if (sym.isClass() && symbol.isConstructorOrDestructor()) {
                    continue;
                }
                const bool def = symbol.isDefinition();
                if (def) {
                    if (declarationOnly)
                        continue;
                } else if (definitionOnly) {
                    continue;
                }
                references[symbol.location] = std::make_pair(def, symbol.kind);
            }
        } else if (queryFlags() & QueryMessage::FindVirtuals) {
            const Set<Symbol> virtuals = proj->findVirtuals(sym);
            for (const auto &symbol : virtuals) {
                const bool def = symbol.isDefinition();
                if (def) {
                    if (declarationOnly)
                        continue;
                } else if (definitionOnly) {
                    continue;
                }
                references[symbol.location] = std::make_pair(def, symbol.kind);
            }
        } else {
            const Set<Symbol> symbols = proj->findCallers(sym);
            for (const auto &symbol : symbols) {
                const bool def = symbol.isDefinition();
//.........这里部分代码省略.........
开发者ID:EmuxEvans,项目名称:rtags,代码行数:101,代码来源:ReferencesJob.cpp


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