Changeset 6213


Ignore:
Timestamp:
Nov 26, 2018, 1:35:57 PM (3 months ago)
Author:
cameron
Message:

Matches can be moved to EOL by RE modification

Location:
icGREP/icgrep-devel/icgrep/grep
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep/grep_engine.cpp

    r6209 r6213  
    2626#include <cc/alphabet.h>
    2727#include <re/re_cc.h>
     28#include <re/re_diff.h>
     29#include <re/re_seq.h>
     30#include <re/re_rep.h>
    2831#include <re/re_alt.h>
    2932#include <re/re_end.h>
    3033#include <re/re_name.h>
     34#include <re/re_assertion.h>
    3135#include <re/casing.h>
    3236#include <re/exclude_CC.h>
     
    9599}
    96100
    97 
    98101inline static size_t ceil_log2(const size_t v) {
    99102    assert ("log2(0) is undefined!" && v != 0);
     
    184187}
    185188
    186 
    187189bool GrepEngine::hasComponent(Component compon_set, Component c) {
    188190    return (static_cast<component_t>(compon_set) & static_cast<component_t>(c)) != 0;
     
    275277    re::RE * prefixRE;
    276278    re::RE * suffixRE;
     279
    277280    // For simple regular expressions with a small number of characters, we
    278281    // can bypass transposition and use the Direct CC compiler.
     
    283286
    284287    bool requiresComplexTest = true;
    285 
     288    Component internalComponents = Component::NoComponents;
    286289
    287290
    288291    if (isSimple) {
     292        if (hasComponent(mRequiredComponents, Component::MoveMatchesToEOL)) {
     293            re::RE * notBreak = re::makeDiff(re::makeByte(0x00, 0xFF), mBreakCC);
     294            mREs[0] = re::makeSeq({mREs[0], re::makeRep(notBreak, 0, re::Rep::UNBOUNDED_REP), makeNegativeLookAheadAssertion(notBreak)});
     295            setComponent(internalComponents, Component::MoveMatchesToEOL);
     296        }
    289297        const auto isWithinByteTestLimit = byteTestsWithinLimit(mREs[0], ByteCClimit);
    290298        const auto hasTriCC = hasTriCCwithinLimit(mREs[0], ByteCClimit, prefixRE, suffixRE);
     
    412420        Matches = MergedMatches;
    413421    }
    414     if (hasComponent(mRequiredComponents, Component::MoveMatchesToEOL)) {
     422    if (hasComponent(mRequiredComponents, Component::MoveMatchesToEOL) && !hasComponent(internalComponents, Component::MoveMatchesToEOL)) {
    415423        StreamSet * const MovedMatches = P->CreateStreamSet();
    416424        P->CreateKernelCall<MatchedLinesKernel>(Matches, LineBreakStream, MovedMatches);
     
    705713            printIdx = mNextFileToPrint++;
    706714        }
     715        //sched_yield();
    707716    }
    708717
     
    710719        pthread_exit(nullptr);
    711720    } else {
    712         // Always perform one final cache cleanup step.
    713721        if (mGrepStdIn) {
    714722            std::ostringstream s;
     
    720728    return nullptr;
    721729}
    722 
    723 
    724730
    725731InternalSearchEngine::InternalSearchEngine(BaseDriver &driver) :
     
    769775    StreamSet * RecordBreakStream = E->CreateStreamSet();
    770776    const auto RBname = (mGrepRecordBreak == GrepRecordBreakKind::Null) ? "Null" : "LF";
    771 
    772777
    773778    StreamSet * BasisBits = nullptr;
  • icGREP/icgrep-devel/icgrep/grep/grep_engine.h

    r6207 r6213  
    9494    typedef uint32_t component_t;
    9595    enum class Component : component_t {
     96        NoComponents = 0,
    9697        MoveMatchesToEOL = 0x01,
    9798        GraphemeClusterBoundary = 0x02
Note: See TracChangeset for help on using the changeset viewer.