Changeset 4408


Ignore:
Timestamp:
Jan 6, 2015, 8:01:25 PM (4 years ago)
Author:
cameron
Message:

Lookbehind assertion logic

File:
1 edited

Legend:

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

    r4405 r4408  
    268268
    269269MarkerType RE_Compiler::process(Assertion * a, MarkerType marker, PabloBlock & pb) {
    270     throw std::runtime_error("Assertions not implemented.");
     270    if (a->getKind() == Assertion::Kind::Lookbehind) {
     271        MarkerType lookback = compile(a->getAsserted(), pb);
     272        if (isFinalPositionMarker(marker) && isFinalPositionMarker(lookback)) {
     273            PabloAST * lb = markerVar(lookback, pb);
     274            if (a->getSense() == Assertion::Sense::Negative) lb = pb.createNot(lb);
     275            return makeFinalPositionMarker("lookback", pb.createAnd(markerVar(marker, pb), lb), pb);
     276        }
     277        else {
     278            Var * m1 = postPositionVar(marker, pb);
     279            PabloAST * lb = postPositionVar(lookback, pb);
     280            if (a->getSense() == Assertion::Sense::Negative) lb = pb.createNot(lb);
     281            return makePostPositionMarker("lookback", pb.createAnd(m1, lb), pb);
     282        }
     283    }
     284    throw std::runtime_error("Lookahead assertions not implemented.");
    271285}
    272286
Note: See TracChangeset for help on using the changeset viewer.