Ignore:
Timestamp:
Oct 11, 2016, 5:53:17 PM (2 years ago)
Author:
xuedongx
Message:

delete the InitialPostPositionUnit? MarkerType?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r5168 r5189  
    264264        if (markerPos(marker) == MarkerPosition::FinalPostPositionUnit) {
    265265            nextPos = marker;
    266         } else if (name->getType() == Name::Type::Byte) {
    267             nextPos = AdvanceMarker(marker, MarkerPosition::InitialPostPositionUnit, pb);
    268266        } else {
    269267            nextPos = AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb);
     
    331329    // The following may be useful to force a common Advance rather than separate
    332330    // Advances in each alternative.
    333     // MarkerType const base = makeMarker(InitialPostPositionUnit, postPositionVar(marker, pb), pb);
    334331    for (RE * re : *alt) {
    335332        MarkerType rslt = process(re, base, pb);
     
    337334        accum[p] = pb.createOr(accum[p], markerVar(rslt), "alt");
    338335    }
    339     if (isa<Zeroes>(accum[MarkerPosition::InitialPostPositionUnit]) && isa<Zeroes>(accum[MarkerPosition::FinalPostPositionUnit])) {
     336    if (isa<Zeroes>(accum[MarkerPosition::FinalPostPositionUnit])) {
    340337        return makeMarker(MarkerPosition::FinalMatchUnit, accum[MarkerPosition::FinalMatchUnit]);
    341338    }
    342     PabloAST * combine = pb.createOr(accum[InitialPostPositionUnit], pb.createAdvance(accum[MarkerPosition::FinalMatchUnit], 1), "alt");
    343     if (isa<Zeroes>(accum[FinalPostPositionUnit])) {
    344         return makeMarker(InitialPostPositionUnit, combine);
    345     }
     339    PabloAST * combine = pb.createAdvance(accum[MarkerPosition::FinalMatchUnit], 1);
    346340    combine = pb.createOr(pb.createScanThru(pb.createAnd(mInitial, combine), mNonFinal), accum[MarkerPosition::FinalPostPositionUnit], "alt");
    347341    return makeMarker(MarkerPosition::FinalPostPositionUnit, combine);
     
    486480        // Create a mask of positions reachable within ub from current marker.
    487481        // Use matchstar, then apply filter.
    488         PabloAST * match = markerVar(AdvanceMarker(marker, MarkerPosition::InitialPostPositionUnit, pb));
     482        PabloAST * match = markerVar(AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb));
    489483        PabloAST * upperLimitMask = reachable(match, 1, ub, pb);
    490         PabloAST * cursor = markerVar(AdvanceMarker(marker, MarkerPosition::InitialPostPositionUnit, pb));
     484        PabloAST * cursor = markerVar(AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb));
    491485        PabloAST * rep_class_var = markerVar(compile(repeated, pb));
    492         return makeMarker(MarkerPosition::InitialPostPositionUnit, pb.createAnd(pb.createMatchStar(cursor, rep_class_var), upperLimitMask, "bounded"));
     486        return makeMarker(MarkerPosition::FinalPostPositionUnit, pb.createAnd(pb.createMatchStar(cursor, rep_class_var), upperLimitMask, "bounded"));
    493487    }
    494488    // Fall through to general case.  Process the first item and insert the rest into an if-structure.   
     
    510504MarkerType RE_Compiler::processUnboundedRep(RE * repeated, MarkerType marker, PabloBuilder & pb) {
    511505    // always use PostPosition markers for unbounded repetition.
    512     PabloAST * base = markerVar(AdvanceMarker(marker, MarkerPosition::InitialPostPositionUnit, pb));
     506    PabloAST * base = markerVar(AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb));
    513507    if (!mGraphemeBoundaryRule && isByteLength(repeated)  && !AlgorithmOptionIsSet(DisableMatchStar)) {
    514508        PabloAST * cc = markerVar(compile(repeated, pb));
    515509        PabloAST * mstar = nullptr;
    516510        mstar = pb.createMatchStar(base, cc, "unbounded");
    517         return makeMarker(MarkerPosition::InitialPostPositionUnit, mstar);
     511        return makeMarker(MarkerPosition::FinalPostPositionUnit, mstar);
    518512    } else if (isUnicodeUnitLength(repeated) && !AlgorithmOptionIsSet(DisableMatchStar) && !AlgorithmOptionIsSet(DisableUnicodeMatchStar)) {
    519513        PabloAST * cc = markerVar(compile(repeated, pb));
     
    537531        PabloAST * m1 = pb.createOr(base, starPending);
    538532        PabloAST * m2 = pb.createOr(base, starAccum);
    539         MarkerType result = process(repeated, makeMarker(MarkerPosition::InitialPostPositionUnit, m1), pb);
    540         result = AdvanceMarker(result, MarkerPosition::InitialPostPositionUnit, pb);
     533        MarkerType result = process(repeated, makeMarker(MarkerPosition::FinalPostPositionUnit, m1), pb);
     534        result = AdvanceMarker(result, MarkerPosition::FinalPostPositionUnit, pb);
    541535        PabloAST * loopComputation = markerVar(result);
    542536        Next * nextPending = pb.createNext(starPending, pb.createAnd(loopComputation, pb.createNot(m2)));
     
    554548        PabloBuilder wb = PabloBuilder::Create(pb);
    555549        mStarDepth++;
    556         MarkerType result = process(repeated, makeMarker(MarkerPosition::InitialPostPositionUnit, whilePending), wb);
    557         result = AdvanceMarker(result, MarkerPosition::InitialPostPositionUnit, wb);
     550        MarkerType result = process(repeated, makeMarker(MarkerPosition::FinalPostPositionUnit, whilePending), wb);
     551        result = AdvanceMarker(result, MarkerPosition::FinalPostPositionUnit, wb);
    558552        PabloAST * loopComputation = markerVar(result);
    559553        Next * nextWhilePending = wb.createNext(whilePending, wb.createAnd(loopComputation, wb.createNot(whileAccum)));
     
    571565
    572566inline MarkerType RE_Compiler::compileStart(const MarkerType marker, pablo::PabloBuilder & pb) {
    573     MarkerType m = AdvanceMarker(marker, MarkerPosition::InitialPostPositionUnit, pb);
     567    MarkerType m = AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb);
    574568    if (UNICODE_LINE_BREAK) {
    575569        PabloAST * line_end = mPB.createOr(mLineBreak, mCRLF);
    576         PabloAST * sol = pb.createNot(pb.createOr(pb.createAdvance(pb.createNot(line_end), 1), mCRLF));
    577         return makeMarker(MarkerPosition::InitialPostPositionUnit, pb.createAnd(markerVar(m), sol, "sol"));
     570        PabloAST * sol_init = pb.createNot(pb.createOr(pb.createAdvance(pb.createNot(line_end), 1), mCRLF));
     571        PabloAST * sol = pb.createScanThru(pb.createAnd(mInitial, sol_init), mNonFinal);
     572        return makeMarker(MarkerPosition::FinalPostPositionUnit, pb.createAnd(markerVar(m), sol, "sol"));
    578573    } else {
    579574        PabloAST * sol = pb.createNot(pb.createAdvance(pb.createNot(mLineBreak), 1));
     
    583578
    584579inline MarkerType RE_Compiler::compileEnd(const MarkerType marker, pablo::PabloBuilder & pb) {
    585     if (UNICODE_LINE_BREAK) {
    586         PabloAST * nextPos = markerVar(AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb));
    587         return makeMarker(MarkerPosition::FinalPostPositionUnit, pb.createAnd(nextPos, mLineBreak, "eol"));
    588     } else {
    589         PabloAST * nextPos = markerVar(AdvanceMarker(marker, MarkerPosition::InitialPostPositionUnit, pb));  // For LF match
    590         return makeMarker(MarkerPosition::FinalPostPositionUnit, pb.createAnd(nextPos, mLineBreak, "eol"));
    591     }
    592 }
    593 
    594 /*inline MarkerType RE_Compiler::compileGraphemeBoundary(GraphemeBoundary * gb, MarkerType marker, pablo::PabloBuilder & pb) {
    595     auto f = mCompiledName.find(gb->getBoundaryRule());
    596     assert ("Internal error: failed to locate grapheme boundary rule!" && (f != mCompiledName.end()));
    597     if (gb->getExpression()) {
    598         const auto graphemeBoundaryRule = mGraphemeBoundaryRule;
    599         mGraphemeBoundaryRule = markerVar(f->second);
    600         marker = process(gb->getExpression(), marker, pb);
    601         marker = AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb);
    602         mGraphemeBoundaryRule = graphemeBoundaryRule;
    603     } else {
    604         marker = AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb);
    605         PabloAST * rule = markerVar(f->second);
    606         if (gb->getSense() == GraphemeBoundary::Sense::Negative) {
    607             rule = pb.createNot(rule);
    608         }
    609         marker = makeMarker(MarkerPosition::FinalPostPositionUnit, pb.createAnd(markerVar(marker), rule, "gb"));
    610     }
    611     return marker;
    612 }*/
     580    PabloAST * nextPos = markerVar(AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb));
     581    return makeMarker(MarkerPosition::FinalPostPositionUnit, pb.createAnd(nextPos, mLineBreak, "eol"));
     582}
    613583
    614584inline MarkerType RE_Compiler::AdvanceMarker(MarkerType marker, const MarkerPosition newpos, PabloBuilder & pb) {
     
    616586        if (marker.pos == MarkerPosition::FinalMatchUnit) {
    617587            marker.stream = pb.createAdvance(marker.stream, 1, "ipp");
    618             marker.pos = MarkerPosition::InitialPostPositionUnit;
    619         }
    620         if (newpos == MarkerPosition::FinalPostPositionUnit) {
    621588            PabloAST * nonFinal = mNonFinal;
    622589            if (mGraphemeBoundaryRule) {
Note: See TracChangeset for help on using the changeset viewer.