Ignore:
Timestamp:
Feb 25, 2018, 12:38:51 PM (14 months ago)
Author:
cameron
Message:

Grapheme Cluster Break kernel

File:
1 edited

Legend:

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

    r5880 r5881  
    3030#include <cc/cc_compiler.h>
    3131#include "pablo/builder.hpp"        // for PabloBuilder
    32 #include <IR_Gen/idisa_target.h>    // for AVX2_available
    3332#include <llvm/ADT/STLExtras.h> // for make_unique
    3433#include <llvm/Support/raw_ostream.h>
     
    5049    mAlphabets.push_back(a);
    5150    mAlphabetCompilers.push_back(make_unique<cc::Parabix_CC_Compiler>(mEntryScope, basis_set));
     51}
     52
     53void RE_Compiler::addPrecompiled(std::string precompiledName, PabloAST * precompiledStream) {
     54    PabloBuilder pb(mEntryScope);
     55    mExternalNameMap.insert(std::make_pair(precompiledName, precompiledStream));
     56    if (precompiledName == "UTF8_nonfinal") {
     57        mNonFinal = precompiledStream;
     58        mFinal = pb.createNot(precompiledStream);
     59    }
     60    if (precompiledName == "UTF8_LB") {
     61        mLineBreak = precompiledStream;
     62    }
    5263}
    5364
     
    156167        return nameMarker;
    157168    } else if (name->getType() == Name::Type::ZeroWidth) {
     169        auto f = mExternalNameMap.find(nameString);
     170        if (f != mExternalNameMap.end()) {
     171            MarkerType z = makeMarker(FinalPostPositionUnit, f->second);
     172            AlignMarkers(marker, z, pb);
     173            PabloAST * ze = markerVar(z);
     174            return makeMarker(markerPos(marker), pb.createAnd(markerVar(marker), ze, "zerowidth"));
     175        }
    158176        RE * zerowidth = name->getDefinition();
    159177        MarkerType zero = compile(zerowidth, pb);
     
    179197
    180198MarkerType RE_Compiler::compileSeq(Seq * const seq, MarkerType marker, PabloBuilder & pb) {
     199
    181200    // if-hierarchies are not inserted within unbounded repetitions
    182201    if (mStarDepth > 0) {
     
    589608, mStarDepth(0)
    590609, mCompiledName(&mBaseMap) {
    591     PabloBuilder mPB(mEntryScope);
    592     Var * const linebreak = kernel->getInputStreamVar("linebreak");
    593     mLineBreak = mPB.createExtract(linebreak, 0);
    594     Var * const required = kernel->getInputStreamVar("required");
    595     mNonFinal = mPB.createExtract(required, 0);
    596     mFinal = mPB.createNot(mNonFinal);
     610    PabloBuilder pb(mEntryScope);
     611    mLineBreak = pb.createZeroes();  // default so "^/$" matches start/end of text only
     612    mNonFinal = pb.createZeroes();
     613    mFinal = pb.createOnes();
    597614}
    598615
Note: See TracChangeset for help on using the changeset viewer.