Changeset 4833


Ignore:
Timestamp:
Oct 13, 2015, 4:11:33 PM (2 years ago)
Author:
nmedfort
Message:

Bug fix for last check in.

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

Legend:

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

    r4831 r4833  
    157157
    158158    Memoizer memoizer;
    159     Name * gcbRule = nullptr;
     159    Name * graphemeClusterRule = nullptr;
    160160
    161161    std::function<RE*(RE*)> resolve = [&](RE * re) -> RE * {
     
    241241            }
    242242        } else if (GraphemeBoundary * gb = dyn_cast<GraphemeBoundary>(re)) {
    243             if (LLVM_LIKELY(gb->getGraphemeBoundaryRule() == nullptr)) {
     243            if (LLVM_LIKELY(gb->getGraphemeExtenderRule() == nullptr)) {
    244244                switch (gb->getType()) {
    245245                    case GraphemeBoundary::Type::ClusterBoundary:
    246                         if (gcbRule == nullptr) {
    247                             gcbRule = cast<Name>(resolve(generateGraphemeClusterBoundaryRule()));
     246                        if (graphemeClusterRule == nullptr) {
     247                            graphemeClusterRule = cast<Name>(resolve(generateGraphemeClusterExtenderRule()));
    248248                        }
    249                         gb->setBoundaryRule(gcbRule);
     249                        gb->setBoundaryRule(graphemeClusterRule);
    250250                        break;
    251251                    default:
     
    290290        } else if (GraphemeBoundary * gb = dyn_cast<GraphemeBoundary>(re)) {
    291291            gather(gb->getExpression());
    292             gather(gb->getGraphemeBoundaryRule());
     292            gather(gb->getGraphemeExtenderRule());
    293293        }
    294294    };
     
    308308
    309309    // Now precompile any grapheme segmentation rules
    310     if (gcbRule) {
    311         mCompiledName.insert(std::make_pair(gcbRule, compileName(gcbRule, mPB)));
     310    if (graphemeClusterRule) {
     311        mCompiledName.insert(std::make_pair(graphemeClusterRule, compileName(graphemeClusterRule, mPB)));
    312312    }
    313313    return re;
     
    318318}
    319319
    320 Name * RE_Compiler::generateGraphemeClusterBoundaryRule() {
     320Name * RE_Compiler::generateGraphemeClusterExtenderRule() {
    321321    // 3.1.1 Grapheme Cluster Boundary Rules
    322322    #define Behind(x) makeLookBehindAssertion(x)
     
    639639        PabloAST * mstar = nullptr;
    640640        PabloAST * nonFinal = mNonFinal;
    641         if (mGraphemeBoundaryRule) {
    642             nonFinal = pb.createOr(nonFinal, pb.createNot(mGraphemeBoundaryRule));
     641        if (mGraphemeExtenderRule) {
     642            nonFinal = pb.createOr(nonFinal, mGraphemeExtenderRule);
    643643        }
    644644        cc = pb.createOr(cc, nonFinal);
     
    649649        }
    650650        PabloAST * final = mFinal;
    651         if (mGraphemeBoundaryRule) {
    652             final = pb.createOr(final, mGraphemeBoundaryRule);
     651        if (mGraphemeExtenderRule) {
     652            final = pb.createOr(final, pb.createNot(mGraphemeExtenderRule));
    653653        }
    654654        return makeMarker(MarkerPosition::FinalPostPositionByte, pb.createAnd(mstar, final, "unbounded"));
     
    714714
    715715inline MarkerType RE_Compiler::compileGraphemeBoundary(GraphemeBoundary * gb, const MarkerType marker, pablo::PabloBuilder & pb) {
    716     const auto inGraphemeBoundaryRule = mGraphemeBoundaryRule;
    717     auto f = mCompiledName.find(gb->getGraphemeBoundaryRule());
     716    const auto inGraphemeBoundaryRule = mGraphemeExtenderRule;
     717    auto f = mCompiledName.find(gb->getGraphemeExtenderRule());
    718718    if (LLVM_UNLIKELY(f == mCompiledName.end())) {
    719719        throw std::runtime_error("Internal error: failed to locate grapheme boundary rule!");
    720720    }
    721     mGraphemeBoundaryRule = markerVar(f->second);
    722     assert (mGraphemeBoundaryRule);
     721    mGraphemeExtenderRule = markerVar(f->second);
     722    assert (mGraphemeExtenderRule);
    723723    MarkerType result = process(gb->getExpression(), marker, pb);
    724     mGraphemeBoundaryRule = inGraphemeBoundaryRule;
     724    mGraphemeExtenderRule = inGraphemeBoundaryRule;
    725725    return result;
    726726}
     
    737737        // Must advance through nonfinal bytes
    738738        PabloAST * nonFinal = mNonFinal;
    739         if (mGraphemeBoundaryRule) {
    740             nonFinal = pb.createOr(nonFinal, mGraphemeBoundaryRule, "gext");
     739        if (mGraphemeExtenderRule) {
     740            nonFinal = pb.createOr(nonFinal, mGraphemeExtenderRule, "gext");
    741741        }
    742742        a = pb.createScanThru(pb.createAnd(mInitial, a), nonFinal, "fpp");
     
    759759, mUnicodeLineBreak(nullptr)
    760760, mAny(nullptr)
    761 , mGraphemeBoundaryRule(nullptr)
     761, mGraphemeExtenderRule(nullptr)
    762762, mInitial(nullptr)
    763763, mNonFinal(nullptr)
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r4831 r4833  
    8484    RE * resolveUnicodeProperties(RE * re);
    8585
    86     Name * generateGraphemeClusterBoundaryRule();
     86    Name * generateGraphemeClusterExtenderRule();
    8787    MarkerType compileName(Name * name, pablo::PabloBuilder & pb);
    8888    MarkerType compileAny(const MarkerType m, pablo::PabloBuilder & pb);
     
    9898    pablo::PabloAST *                               mUnicodeLineBreak;
    9999    pablo::PabloAST *                               mAny;
    100     pablo::PabloAST *                               mGraphemeBoundaryRule;
     100    pablo::PabloAST *                               mGraphemeExtenderRule;
    101101    pablo::PabloAST *                               mInitial;
    102102    pablo::Assign *                                 mNonFinal;   
  • icGREP/icgrep-devel/icgrep/re/re_grapheme_boundary.hpp

    r4829 r4833  
    2424    inline RE * getExpression() const {return mExpression;}
    2525    inline void setExpression(RE * const r) {mExpression = r; }
    26     inline Name * getGraphemeBoundaryRule() const {return mBoundaryRule;}
     26    inline Name * getGraphemeExtenderRule() const {return mBoundaryRule;}
    2727    inline void setBoundaryRule(Name * const r) {mBoundaryRule = r; }
    2828    inline Type getType() const {return mType;}
Note: See TracChangeset for help on using the changeset viewer.