Ignore:
Timestamp:
Dec 14, 2017, 2:02:40 PM (15 months ago)
Author:
cameron
Message:

Strip out local mode from RE compiler

File:
1 edited

Legend:

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

    r5779 r5780  
    6969}
    7070   
    71 MarkerType RE_Compiler::compile_local(RE * re, MarkerType marker, PabloBuilder & pb) {
    72     CC * first = RE_Local::first(re);
    73     CC * final = RE_Local::final(re);
    74 
    75     if (first == nullptr || final == nullptr) {
    76         mLocal = false;
    77         return process(re, marker, pb);
    78     }
    79 
    80     PabloAST * pablo_first = mCCCompiler.compileCC(first);
    81     PabloAST * pablo_final = mCCCompiler.compileCC(final);
    82     std::map<CC*, CC*> follow_map;
    83     RE_Local::follow(re, follow_map);
    84 
    85     PabloAST * pablo_follow = pb.createZeroes();
    86     for (auto i = follow_map.begin(); i != follow_map.end(); i++) {
    87         CC * one = makeCC(std::move(*i->first));
    88         CC * two = makeCC(std::move(*i->second));
    89         PabloAST * pablo_one = mCCCompiler.compileCC(one);
    90         PabloAST * pablo_two = mCCCompiler.compileCC(two);
    91         PabloAST * one1 = pb.createAdvance(pablo_one, 1, "one1");
    92         PabloAST * follow = pb.createAnd(pb.createScanThru(pb.createAnd(mInitial, one1), mNonFinal), pablo_two);
    93         pablo_follow = pb.createOr(pablo_follow, follow);
    94     }
    95     PabloAST * result = pb.createAnd(pb.createMatchStar(pb.createAdvance(pablo_first, 1),
    96                                                         pb.createOr(pablo_follow, mNonFinal)),
    97                                      pb.createAdvance(pablo_final, 1));
    98     return makeMarker(MarkerPosition::FinalPostPositionUnit, result);
    99 }
    100 
    101    
    10271MarkerType RE_Compiler::process(RE * re, MarkerType marker, PabloBuilder & pb) {
    103     if (mLocal) {
    104         if (isa<Name>(re) || isa<Seq>(re) || isa<Alt>(re) || isa<Rep>(re) || isa<CC>(re)) {
    105             return compile_local(re, marker, pb);
    106         } else if (isa<Any>(re)) {
    107             return compileAny(marker, pb);
    108         } else if (isa<Diff>(re)) {
    109             return compileDiff(cast<Diff>(re), marker, pb);
    110         } else if (isa<Intersect>(re)) {
    111             return compileIntersect(cast<Intersect>(re), marker, pb);
    112         } else {
    113             UnsupportedRE("RE Compiler for local language failed to process " + Printer_RE::PrintRE(re));
    114         }
     72    if (isa<Name>(re)) {
     73        return compileName(cast<Name>(re), marker, pb);
     74    } else if (isa<Seq>(re)) {
     75        return compileSeq(cast<Seq>(re), marker, pb);
     76    } else if (isa<Alt>(re)) {
     77        return compileAlt(cast<Alt>(re), marker, pb);
     78    } else if (isa<Rep>(re)) {
     79        return compileRep(cast<Rep>(re), marker, pb);
     80    } else if (isa<Assertion>(re)) {
     81        return compileAssertion(cast<Assertion>(re), marker, pb);
     82    } else if (isa<Any>(re)) {
     83        return compileAny(marker, pb);
     84    } else if (isa<Diff>(re)) {
     85        return compileDiff(cast<Diff>(re), marker, pb);
     86    } else if (isa<Intersect>(re)) {
     87        return compileIntersect(cast<Intersect>(re), marker, pb);
     88    } else if (isa<Start>(re)) {
     89        return compileStart(marker, pb);
     90    } else if (isa<End>(re)) {
     91        return compileEnd(marker, pb);
     92    } else if (isa<CC>(re)) {
     93        // CCs may be passed through the toolchain directly to the compiler.
     94        return compileCC(cast<CC>(re), marker, pb);
    11595    } else {
    116         if (isa<Name>(re)) {
    117             return compileName(cast<Name>(re), marker, pb);
    118         } else if (isa<Seq>(re)) {
    119             return compileSeq(cast<Seq>(re), marker, pb);
    120         } else if (isa<Alt>(re)) {
    121             return compileAlt(cast<Alt>(re), marker, pb);
    122         } else if (isa<Rep>(re)) {
    123             return compileRep(cast<Rep>(re), marker, pb);
    124         } else if (isa<Assertion>(re)) {
    125             return compileAssertion(cast<Assertion>(re), marker, pb);
    126         } else if (isa<Any>(re)) {
    127             return compileAny(marker, pb);
    128         } else if (isa<Diff>(re)) {
    129             return compileDiff(cast<Diff>(re), marker, pb);
    130         } else if (isa<Intersect>(re)) {
    131             return compileIntersect(cast<Intersect>(re), marker, pb);
    132         } else if (isa<Start>(re)) {
    133             return compileStart(marker, pb);
    134         } else if (isa<End>(re)) {
    135             return compileEnd(marker, pb);
    136         } else if (isa<CC>(re)) {
    137             // CCs may be passed through the toolchain directly to the compiler.
    138             return compileCC(cast<CC>(re), marker, pb);
    139         } else {
    140             UnsupportedRE("RE Compiler failed to process " + Printer_RE::PrintRE(re));
    141         }
     96        UnsupportedRE("RE Compiler failed to process " + Printer_RE::PrintRE(re));
    14297    }
    14398}
     
    653608   
    654609
    655 RE_Compiler::RE_Compiler(PabloKernel * kernel, cc::CC_Compiler & ccCompiler, bool local)
     610RE_Compiler::RE_Compiler(PabloKernel * kernel, cc::CC_Compiler & ccCompiler)
    656611: mKernel(kernel)
    657612, mCCCompiler(ccCompiler)
    658 , mLocal(local)
    659613, mLineBreak(nullptr)
    660614, mCRLF(nullptr)
Note: See TracChangeset for help on using the changeset viewer.