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


C++ CharReach类代码示例

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


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

示例1: getBackwardReach

static
void getBackwardReach(const NGHolder &g, ReportID report, u32 lag,
                      map<s32, CharReach> &look) {
    ue2::flat_set<NFAVertex> curr, next;

    for (auto v : inv_adjacent_vertices_range(g.accept, g)) {
        if (contains(g[v].reports, report)) {
            curr.insert(v);
        }
    }

    for (u32 i = lag + 1; i <= MAX_BACK_LEN; i++) {
        if (curr.empty() || contains(curr, g.start) ||
            contains(curr, g.startDs)) {
            break;
        }

        next.clear();
        CharReach cr;

        for (auto v : curr) {
            assert(!is_special(v, g));
            cr |= g[v].char_reach;
            insert(&next, inv_adjacent_vertices(v, g));
        }

        assert(cr.any());
        look[0 - i] |= cr;
        curr.swap(next);
    }
}
开发者ID:01org,项目名称:hyperscan,代码行数:31,代码来源:rose_build_lookaround.cpp

示例2: TEST

TEST(ReverseTruffle, ExecMatch3) {
    m128 mask1, mask2;

    CharReach chars;
    chars.set('a');
    chars.set('B');

    truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);

    /*          0123456789012345678901234567890 */
    char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaBbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
    size_t len = strlen(t1);

    for (size_t i = 0; i < 16; i++) {
        const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
        ASSERT_NE((const u8 *)t1 - 1, rv); // not found
        EXPECT_EQ('B', (char)*rv);
        ASSERT_EQ((const u8 *)t1 + 32, rv);
    }

    // check that we match the 'a' bytes as well.
    ASSERT_EQ('B', t1[32]);
    t1[32] = 'b';
    for (size_t i = 0; i < 16; i++) {
        const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
        ASSERT_NE((const u8 *)t1 - 1, rv); // not found
        EXPECT_EQ('a', (char)*rv);
        ASSERT_EQ((const u8 *)t1 + 31, rv);
    }
}
开发者ID:tomzhang,项目名称:hyperscan,代码行数:30,代码来源:truffle.cpp

示例3: describeEdge

void describeEdge(FILE *f, const u16 *t, u16 i) {
    for (u16 s = 0; s < N_CHARS; s++) {
        if (!t[s]) {
            continue;
        }

        u16 ss;
        for (ss = 0; ss < s; ss++) {
            if (t[s] == t[ss]) {
                break;
            }
        }

        if (ss != s) {
            continue;
        }

        CharReach reach;
        for (ss = s; ss < 256; ss++) {
            if (t[s] == t[ss]) {
                reach.set(ss);
            }
        }

        fprintf(f, "%u -> %u [ label = \"", i, t[s]);

        describeClass(f, reach, 5, CC_OUT_DOT);

        fprintf(f, "\" ];\n");
    }
}
开发者ID:tomzhang,项目名称:hyperscan,代码行数:31,代码来源:mcclellandump.cpp

示例4: getForwardReach

static
void getForwardReach(const raw_dfa &rdfa, map<s32, CharReach> &look) {
    if (rdfa.states.size() < 2) {
        return;
    }

    ue2::flat_set<dstate_id_t> curr, next;
    curr.insert(rdfa.start_anchored);

    for (u32 i = 0; i < MAX_FWD_LEN && !curr.empty(); i++) {
        next.clear();
        CharReach cr;

        for (const auto state_id : curr) {
            const dstate &ds = rdfa.states[state_id];

            if (!ds.reports.empty() || !ds.reports_eod.empty()) {
                return;
            }

            for (unsigned c = 0; c < N_CHARS; c++) {
                dstate_id_t succ = ds.next[rdfa.alpha_remap[c]];
                if (succ != DEAD_STATE) {
                    cr.set(c);
                    next.insert(succ);
                }
            }
        }

        assert(cr.any());
        look[i] |= cr;
        curr.swap(next);
    }
}
开发者ID:01org,项目名称:hyperscan,代码行数:34,代码来源:rose_build_lookaround.cpp

示例5: findStopAlphabet

/** Find the set of characters that are not present in the reachability of
 * graph \p g after a certain depth (currently 8). If a character in this set
 * is encountered, it means that the NFA is either dead or has not progressed
 * more than 8 characters from its start states. */
CharReach findStopAlphabet(const NGHolder &g, som_type som) {
    const depth max_depth(MAX_STOP_DEPTH);
    const InitDepths depths(g);
    const map<NFAVertex, BoundedRepeatSummary> no_vertices;

    CharReach stopcr;

    for (auto v : vertices_range(g)) {
        if (is_special(v, g)) {
            continue;
        }

        if (depths.maxDist(g, v) >= max_depth) {
            if (som == SOM_NONE) {
                stopcr |= reduced_cr(v, g, no_vertices);
            } else {
                stopcr |= g[v].char_reach;
            }
        }
    }

    // Turn alphabet into stops.
    stopcr.flip();

    return stopcr;
}
开发者ID:0x4e38,项目名称:hyperscan,代码行数:30,代码来源:ng_stop.cpp

示例6: TEST

TEST(ng_charreach, bitwise) {
    CharReach cr;
    CharReach cr2;
    CharReach cr3;
    CharReach cr4;

    cr.set('a');

    cr2.set('z');


    cr3.set('a');
    cr3.set('z');

    ASSERT_TRUE(cr < cr3);

    cr4 |= cr;
    cr4 |= cr2;

    ASSERT_TRUE(cr3 == cr4);

    ASSERT_TRUE(cr3 == (cr | cr2));
    ASSERT_TRUE(cr4 == (cr | cr2));

    ASSERT_TRUE(cr == (cr & cr3));
    ASSERT_TRUE(cr2 == (cr2 & cr3));

    cr3 &= cr;

    ASSERT_FALSE(cr3.test('z'));
}
开发者ID:0x4e38,项目名称:hyperscan,代码行数:31,代码来源:charreach.cpp

示例7: describeEdge

static
void describeEdge(FILE *f, const mcsheng *m, const u16 *t, u16 i) {
    for (u16 s = 0; s < N_CHARS; s++) {
        if (!t[s]) {
            continue;
        }

        u16 ss;
        for (ss = 0; ss < s; ss++) {
            if (t[s] == t[ss]) {
                break;
            }
        }

        if (ss != s) {
            continue;
        }

        CharReach reach;
        for (ss = s; ss < 256; ss++) {
            if (t[s] == t[ss]) {
                reach.set(ss);
            }
        }

        fprintf(f, "%u -> %u [ ", i, t[s]);
        if (i < m->sheng_end && t[s] < m->sheng_end) {
            fprintf(f, "color = red, fontcolor = red ");
        }
        fprintf(f, "label = \"");
        describeClass(f, reach, 5, CC_OUT_DOT);

        fprintf(f, "\" ];\n");
    }
}
开发者ID:tomzhang,项目名称:hyperscan,代码行数:35,代码来源:mcsheng_dump.cpp

示例8: make_pattern

 // Ugly but simple.
 string make_pattern() {
     std::ostringstream oss;
     oss << "^[";
     for (size_t i = reach.find_first(); i != CharReach::npos;
          i = reach.find_next(i)) {
         oss << "\\x" << std::hex << std::setw(2) << std::setfill('0')
             << (unsigned)(i & 0xff) << std::dec;
     }
     oss << "]{" << min << "," << max << "}";
     return oss.str();
 }
开发者ID:starius,项目名称:hyperscan,代码行数:12,代码来源:lbr.cpp

示例9: mcclellanStartReachSize

u32 mcclellanStartReachSize(const raw_dfa *raw) {
    if (raw->states.size() < 2) {
        return 0;
    }

    const dstate &ds = raw->states[raw->start_anchored];

    CharReach out;
    for (unsigned i = 0; i < N_CHARS; i++) {
        if (ds.next[raw->alpha_remap[i]] != DEAD_STATE) {
            out.set(i);
        }
    }

    return out.count();
}
开发者ID:0x4e38,项目名称:hyperscan,代码行数:16,代码来源:mcclellancompile.cpp

示例10: nfaExecLbrTruf_dump

void nfaExecLbrTruf_dump(const NFA *nfa, const string &base) {
    assert(nfa);
    assert(nfa->type == LBR_NFA_TRUF);

    StdioFile f(base + ".txt", "w");

    const lbr_truf *lt = (const lbr_truf *)getImplNfa(nfa);
    lbrDumpCommon(&lt->common, f);

    CharReach cr = truffle2cr((const u8 *)&lt->mask1,
                              (const u8 *)&lt->mask2);
    fprintf(f, "TRUFFLE model, scanning for: %s (%zu chars)\n",
            describeClass(cr, 20, CC_OUT_TEXT).c_str(), cr.count());
    fprintf(f, "\n");
    dumpTextReverse(nfa, f);
}
开发者ID:tomzhang,项目名称:hyperscan,代码行数:16,代码来源:lbr_dump.cpp

示例11: nfaExecLbrShuf_dump

void nfaExecLbrShuf_dump(const NFA *nfa, const string &base) {
    assert(nfa);
    assert(nfa->type == LBR_NFA_SHUF);

    StdioFile f(base + ".txt", "w");

    const lbr_shuf *ls = (const lbr_shuf *)getImplNfa(nfa);
    lbrDumpCommon(&ls->common, f);

    CharReach cr = shufti2cr((const u8 *)&ls->mask_lo,
                             (const u8 *)&ls->mask_hi);
    fprintf(f, "SHUF model, scanning for: %s (%zu chars)\n",
            describeClass(cr, 20, CC_OUT_TEXT).c_str(), cr.count());
    fprintf(f, "\n");
    dumpTextReverse(nfa, f);
}
开发者ID:tomzhang,项目名称:hyperscan,代码行数:16,代码来源:lbr_dump.cpp


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