Changeset 4283


Ignore:
Timestamp:
Nov 1, 2014, 12:27:43 PM (5 years ago)
Author:
cameron
Message:

MatchStar? for negated character classes.

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

Legend:

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

    r4280 r4283  
    7474}
    7575
     76PabloAST * RE_Compiler::character_class_strm(Name * name, PabloBlock & pb) {
     77    if (name->getType() == Name::Type::UnicodeCategory) {
     78        return pb.createCall(name->getName());
     79    }
     80    else {
     81        return name->getVar();
     82    }
     83}
    7684
    7785Assign * RE_Compiler::process(RE * re, Assign * marker, PabloBlock & pb) {
     
    116124        markerVar = pb.createScanThru(markerVar, mNonFinal);
    117125    }
    118     PabloAST * cc = nullptr;
    119     if (name->getType() == Name::Type::UnicodeCategory) {
    120         cc = pb.createCall(name->getName());
    121     }
    122     else {
    123         cc = name->getVar();
    124     }
    125     return pb.createAssign("m", pb.createAdvance(pb.createAnd(cc, markerVar), 1));
     126    return pb.createAssign("m", pb.createAdvance(pb.createAnd(character_class_strm(name, pb), markerVar), 1));
    126127}
    127128
     
    240241        Name * name = cast<Name>(repeated);
    241242
    242         PabloAST * cc;
    243         if (name->getType() == Name::Type::UnicodeCategory) {
    244             cc = pb.createCall(name->getName());
    245         }
    246         else {
    247             cc = name->getVar();
    248         }
     243        PabloAST * cc = character_class_strm(name, pb);
    249244
    250245        unbounded = pb.createVar(marker);
     
    261256        unbounded = pb.createAnd(pb.createMatchStar(unbounded, pb.createOr(mNonFinal, dot)), mInitial);
    262257    }
     258    else if (isa<Diff>(repeated) && isa<Any>(cast<Diff>(repeated)->getLH()) && isa<Name>(cast<Diff>(repeated)->getRH())) {
     259        Name * name = cast<Name>(cast<Diff>(repeated)->getRH());
     260        PabloAST * cc = pb.createNot(pb.createOr(character_class_strm(name, pb), mLineFeed));
     261        unbounded = pb.createVar(marker);
     262        unbounded = pb.createAnd(pb.createMatchStar(unbounded, pb.createOr(mNonFinal, cc)), mInitial);
     263    }
    263264    else {
    264265        Var * markerVar = pb.createVar(marker);
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r4280 r4283  
    3939    void compile(RE * re, pablo::PabloBlock & cg);
    4040
     41    pablo::PabloAST * character_class_strm(Name * name, pablo::PabloBlock & pb);
    4142    pablo::Assign * process(RE * re, pablo::Assign *marker, pablo::PabloBlock & pb);
    4243    pablo::Assign * process(Name * name, pablo::Assign * marker, pablo::PabloBlock & pb);
Note: See TracChangeset for help on using the changeset viewer.