Ignore:
Timestamp:
May 19, 2016, 8:50:15 PM (3 years ago)
Author:
cameron
Message:

Add pablo.atEOF; clean out bit4/6 hack for unterminated final lines in icgrep.

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

Legend:

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

    r5037 r5042  
    4646
    4747    Assign * LF = mPB.createAssign("LF", mCCCompiler.compileCC(makeCC(0x0A)));
    48     mLineFeed = LF;
    4948    PabloAST * CR = mCCCompiler.compileCC(makeCC(0x0D));
    5049    PabloAST * LF_VT_FF_CR = mCCCompiler.compileCC(makeCC(0x0A, 0x0D));
     
    121120    mInitial = mPB.createOr(u8single, valid_pfx, "initial");
    122121    mFinal = mPB.createNot(mPB.createOr(mNonFinal, u8invalid), "final");
    123     mUnicodeLineBreak = mPB.createAnd(LB_chars, mPB.createNot(mCRLF));  // count the CR, but not CRLF
    124     PabloAST * const lb = UNICODE_LINE_BREAK ? mUnicodeLineBreak : mLineFeed;
     122    PabloAST * UnicodeLineBreak = mPB.createAnd(LB_chars, mPB.createNot(mCRLF));  // count the CR, but not CRLF
     123    PabloAST * lb = UNICODE_LINE_BREAK ? UnicodeLineBreak : LF;
     124    PabloAST * unterminatedLineAtEOF = mPB.createAtEOF(mPB.createAdvance(mPB.createNot(LB_chars), 1));
     125    mLineBreak = mPB.createOr(lb, unterminatedLineAtEOF);
    125126    mAny = mPB.createNot(lb, "any");
    126     mFunction.setResult(1, mPB.createAssign("lf", mPB.createAnd(lb, mPB.createNot(mCRLF))));
     127    mFunction.setResult(1, mPB.createAssign("lf", mLineBreak));
    127128}
    128129
     
    362363        match_follow = mPB.createNot(match_follow);
    363364    }
    364     mFunction.setResult(0, mPB.createAssign("matches", mPB.createAnd(match_follow, UNICODE_LINE_BREAK ? mUnicodeLineBreak : mLineFeed)));
     365    mFunction.setResult(0, mPB.createAssign("matches", mPB.createAnd(match_follow, mLineBreak)));
    365366}
    366367
     
    398399inline MarkerType RE_Compiler::compileAny(const MarkerType m, PabloBuilder & pb) {
    399400    PabloAST * nextFinalByte = markerVar(AdvanceMarker(m, MarkerPosition::FinalPostPositionByte, pb));
    400     PabloAST * lb = mLineFeed;
     401    PabloAST * lb = mLineBreak;
    401402    if (UNICODE_LINE_BREAK) {
    402         lb = pb.createOr(mUnicodeLineBreak, mCRLF);
     403        lb = pb.createOr(mLineBreak, mCRLF);
    403404    }
    404405    return makeMarker(MarkerPosition::FinalMatchByte, pb.createAnd(nextFinalByte, pb.createNot(lb), "dot"));
     
    698699    MarkerType m = AdvanceMarker(marker, MarkerPosition::InitialPostPositionByte, pb);
    699700    if (UNICODE_LINE_BREAK) {
    700         PabloAST * line_end = mPB.createOr(mUnicodeLineBreak, mCRLF);
     701        PabloAST * line_end = mPB.createOr(mLineBreak, mCRLF);
    701702        PabloAST * sol = pb.createNot(pb.createOr(pb.createAdvance(pb.createNot(line_end), 1), mCRLF));
    702703        return makeMarker(MarkerPosition::InitialPostPositionByte, pb.createAnd(markerVar(m), sol, "sol"));
    703704    } else {
    704         PabloAST * sol = pb.createNot(pb.createAdvance(pb.createNot(mLineFeed), 1));
     705        PabloAST * sol = pb.createNot(pb.createAdvance(pb.createNot(mLineBreak), 1));
    705706        return makeMarker(MarkerPosition::FinalPostPositionByte, pb.createAnd(markerVar(m), sol, "sol"));
    706707    }
     
    710711    if (UNICODE_LINE_BREAK) {
    711712        PabloAST * nextPos = markerVar(AdvanceMarker(marker, MarkerPosition::FinalPostPositionByte, pb));
    712         return makeMarker(MarkerPosition::FinalPostPositionByte, pb.createAnd(nextPos, mUnicodeLineBreak, "eol"));
     713        return makeMarker(MarkerPosition::FinalPostPositionByte, pb.createAnd(nextPos, mLineBreak, "eol"));
    713714    } else {
    714715        PabloAST * nextPos = markerVar(AdvanceMarker(marker, MarkerPosition::InitialPostPositionByte, pb));  // For LF match
    715         return makeMarker(MarkerPosition::FinalPostPositionByte, pb.createAnd(nextPos, mLineFeed, "eol"));
     716        return makeMarker(MarkerPosition::FinalPostPositionByte, pb.createAnd(nextPos, mLineBreak, "eol"));
    716717    }
    717718}
     
    765766RE_Compiler::RE_Compiler(pablo::PabloFunction & function, cc::CC_Compiler & ccCompiler)
    766767: mCCCompiler(ccCompiler)
    767 , mLineFeed(nullptr)
     768, mLineBreak(nullptr)
    768769, mCRLF(nullptr)
    769 , mUnicodeLineBreak(nullptr)
    770770, mAny(nullptr)
    771771, mGraphemeBoundaryRule(nullptr)
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r5030 r5042  
    9494
    9595    cc::CC_Compiler &                               mCCCompiler;
    96     pablo::Assign *                                 mLineFeed;
     96    pablo::PabloAST *                                 mLineBreak;
    9797    pablo::PabloAST *                               mCRLF;
    98     pablo::PabloAST *                               mUnicodeLineBreak;
    9998    pablo::PabloAST *                               mAny;
    10099    pablo::PabloAST *                               mGraphemeBoundaryRule;
Note: See TracChangeset for help on using the changeset viewer.