Changeset 4520


Ignore:
Timestamp:
Feb 26, 2015, 10:42:30 AM (4 years ago)
Author:
cameron
Message:

Favor FinaPostPositionByte? positioning; fix for lookahead assertion

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

Legend:

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

    r4510 r4520  
    5151, mInitial(nullptr)
    5252, mNonFinal(nullptr)
     53, mFinal(nullptr)
    5354, mStarDepth(0)
    5455{
     
    5960MarkerType RE_Compiler::AdvanceMarker(MarkerType m, MarkerPosition newpos, PabloBlock & pb) {
    6061    if (m.pos == newpos) return m;
    61     if (m.pos > newpos) throw std::runtime_error("icgrep internal error: attempt to AdvanceMarker backwards");
    6262    PabloAST * a = m.stream;
    6363    if (m.pos == FinalMatchByte) {
     
    149149    PabloAST * pfx_invalid = it.createXor(u8pfx, legalpfx);
    150150    Assign * u8invalid = it.createAssign("u8invalid", it.createOr(pfx_invalid, it.createOr(mismatch, EF_invalid)));
    151     //
    152     //
    153    
    154     Assign * valid_pfx = it.createAssign("valid_pfx", it.createAnd(u8pfx, it.createNot(u8invalid)));
    155     mNonFinal = it.createAssign("nonfinal", it.createAnd(it.createOr(it.createOr(u8pfx, u8scope32), u8scope4nonfinal), it.createNot(u8invalid)));
     151    Assign * u8valid = it.createAssign("u8valid", it.createNot(u8invalid));
     152    //
     153    //
     154   
     155    Assign * valid_pfx = it.createAssign("valid_pfx", it.createAnd(u8pfx, u8valid));
     156    mNonFinal = it.createAssign("nonfinal", it.createAnd(it.createOr(it.createOr(u8pfx, u8scope32), u8scope4nonfinal), u8valid));
    156157   
    157158    Assign * NEL_LS_PS = it.createAssign("NEL_LS_PS", it.createOr(NEL, LS_PS));
     
    161162    PabloAST * u8single = mPB.createAnd(ccc.compileCC(makeCC(0x00, 0x7F)), mPB.createNot(u8invalid));
    162163    mInitial = mPB.createOr(u8single, valid_pfx, "initial");
     164    mFinal = mPB.createNot(mPB.createOr(mNonFinal, u8invalid), "final");
    163165    mUnicodeLineBreak = mPB.createAnd(LB_chars, mPB.createNot(mCRLF));  // count the CR, but not CRLF
    164166}
     
    173175
    174176MarkerType RE_Compiler::compile(RE * re, PabloBlock & pb) {
    175     return process(re, makeMarker(InitialPostPositionByte, pb.createOnes()), pb);
     177    return process(re, makeMarker(FinalPostPositionByte, pb.createOnes()), pb);
    176178}
    177179
     
    224226        else {
    225227            PabloAST * sol = pb.createNot(pb.createAdvance(pb.createNot(mLineFeed), 1));
    226             return makeMarker(InitialPostPositionByte, pb.createAnd(markerVar(m), sol, "sol"));
     228            return makeMarker(FinalPostPositionByte, pb.createAnd(markerVar(m), sol, "sol"));
    227229        }
    228230    }
    229231    else if (isa<End>(re)) {
    230232        if (UNICODE_LINE_BREAK) {
    231             PabloAST * nextPos = nextUnicodePosition(marker, pb);
     233            PabloAST * nextPos = markerVar(AdvanceMarker(marker, FinalPostPositionByte, pb));
    232234            return makeMarker(FinalPostPositionByte, pb.createAnd(nextPos, mUnicodeLineBreak, "end"));
    233235        }
    234236        PabloAST * nextPos = markerVar(AdvanceMarker(marker, InitialPostPositionByte, pb));  // For LF match
    235         return makeMarker(InitialPostPositionByte, pb.createAnd(nextPos, mLineFeed, "eol"));
     237        return makeMarker(FinalPostPositionByte, pb.createAnd(nextPos, mLineFeed, "eol"));
    236238    }
    237239    return marker;
     
    485487    else if (isUnicodeUnitLength(repeated) && !DisableMatchStar && !DisableUnicodeMatchStar) {
    486488        PabloAST * cc = markerVar(compile(repeated, pb));
    487         return makeMarker(InitialPostPositionByte, pb.createAnd(pb.createMatchStar(base, pb.createOr(mNonFinal, cc)), mInitial, "unbounded"));
     489        return makeMarker(FinalPostPositionByte, pb.createAnd(pb.createMatchStar(base, pb.createOr(mNonFinal, cc)), mFinal, "unbounded"));
    488490    }
    489491    else {
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r4486 r4520  
    9696    pablo::PabloAST *                               mInitial;
    9797    pablo::Assign *                                 mNonFinal;
     98    pablo::PabloAST *                               mFinal;
    9899    int                                             mStarDepth;
    99100};
Note: See TracChangeset for help on using the changeset viewer.