Changeset 4625 for icGREP


Ignore:
Timestamp:
Jun 30, 2015, 10:32:44 AM (4 years ago)
Author:
nmedfort
Message:

Couple more bug fixes for UCD Compiler.

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/ucd_compiler.cpp

    r4624 r4625  
    175175 ** ------------------------------------------------------------------------------------------------------------- */
    176176PabloAST * UCDCompiler::ifTestCompiler(const codepoint_t lo, const codepoint_t hi, const unsigned byte_no, PabloBuilder & block, PabloAST * target) {
     177
    177178    codepoint_t lo_byte = UTF8_Encoder::encodingByte(lo, byte_no);
    178179    codepoint_t hi_byte = UTF8_Encoder::encodingByte(hi, byte_no);
    179180    const bool at_lo_boundary = (lo == 0 || UTF8_Encoder::encodingByte(lo - 1, byte_no) != lo_byte);
    180181    const bool at_hi_boundary = (hi == 0x10FFFF || UTF8_Encoder::encodingByte(hi + 1, byte_no) != hi_byte);
     182
    181183    if (at_lo_boundary && at_hi_boundary) {
    182184        if (lo_byte != hi_byte) {
     
    193195        target = ifTestCompiler(lo, hi, byte_no + 1, block, target);
    194196    }
    195     else if (at_hi_boundary) {
    196         const auto mid = UTF8_Encoder::maxCodePointWithCommonBytes(hi, byte_no);
    197         PabloAST * e1 = ifTestCompiler(lo, mid, byte_no, block, target);
    198         PabloAST * e2 = ifTestCompiler(mid + 1, hi, byte_no, block, target);
    199         target = block.createOr(e1, e2);
    200     }
    201     else {
     197    else if (!at_hi_boundary) {
    202198        const auto mid = UTF8_Encoder::minCodePointWithCommonBytes(hi, byte_no);
    203199        PabloAST * e1 = ifTestCompiler(lo, mid - 1, byte_no, block, target);
    204200        PabloAST * e2 = ifTestCompiler(mid, hi, byte_no, block, target);
     201        target = block.createOr(e1, e2);
     202    }
     203    else {
     204        const auto mid = UTF8_Encoder::maxCodePointWithCommonBytes(lo, byte_no);
     205        PabloAST * e1 = ifTestCompiler(lo, mid, byte_no, block, target);
     206        PabloAST * e2 = ifTestCompiler(mid + 1, hi, byte_no, block, target);
    205207        target = block.createOr(e1, e2);
    206208    }
     
    253255template <typename RangeListOrUnicodeSet>
    254256UCDCompiler::RangeList UCDCompiler::rangeIntersect(const RangeListOrUnicodeSet & list, const codepoint_t lo, const codepoint_t hi) {
    255     RangeList intersection;
     257    RangeList result;
    256258    for (const auto i : list) {
    257259        if ((lo_codepoint(i) <= hi) && (hi_codepoint(i) >= lo)) {
    258             intersection.emplace_back(std::max(lo, lo_codepoint(i)), std::min(hi, hi_codepoint(i)));
    259         }
    260     }
    261     return intersection;
     260            result.emplace_back(std::max(lo, lo_codepoint(i)), std::min(hi, hi_codepoint(i)));
     261        }
     262    }
     263    return result;
    262264}
    263265
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4623 r4625  
    271271        if (DisablePregeneratedUnicode) {
    272272            // Note: using a fixed set while testing whether the UCD compiler works.
    273             var = mUCDCompiler.generateWithDefaultIfHierarchy(UCD::GC_ns::z_Set, pb);
     273            var = mUCDCompiler.generateWithDefaultIfHierarchy(UCD::GC_ns::ll_Set, pb);
    274274        }
    275275        else {
Note: See TracChangeset for help on using the changeset viewer.