Ignore:
Timestamp:
Jun 25, 2015, 3:47:56 PM (4 years ago)
Author:
nmedfort
Message:

Upload of an untested (inactive) UCD compiler.

File:
1 edited

Legend:

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

    r4614 r4617  
    156156    return cci;
    157157}
    158 
    159 /** ------------------------------------------------------------------------------------------------------------- *
    160  * @brief rangeIntersect
    161  * @param cc
    162  * @param lo
    163  * @param hi
    164  ** ------------------------------------------------------------------------------------------------------------- */
    165 CC * rangeIntersect(const CC * cc, const codepoint_t lo, const codepoint_t hi) {
    166     assert ("cc cannot be null" && cc);
    167     CC * intersect = makeCC();
    168     for (const auto & i : *cc) {
    169         if ((lo_codepoint(i) <= hi) && (hi_codepoint(i) >= lo)) {
    170             intersect->insert_range(std::max(lo, lo_codepoint(i)), std::min(hi, hi_codepoint(i)));
    171         }
    172     }
    173     return intersect;
    174 }
    175 
    176 /** ------------------------------------------------------------------------------------------------------------- *
    177  * @brief rangeGaps
    178  * @param cc
    179  * @param lo
    180  * @param hi
    181  ** ------------------------------------------------------------------------------------------------------------- */
    182 CC * rangeGaps(const CC * cc, const codepoint_t lo, const codepoint_t hi) {
    183     assert ("cc cannot be null" && cc);
    184     CC * gaps = makeCC();
    185     codepoint_t cp = lo;
    186     if (cp < hi) {
    187         auto i = cc->cbegin(), end = cc->cend();
    188         for (; i != end && cp < hi; ++i) {
    189             if (hi_codepoint(i) < cp) {
    190                 continue;
    191             }
    192             else if (lo_codepoint(i) > cp) {
    193                 gaps->insert_range(cp, lo_codepoint(i) - 1);
    194             }
    195             cp = hi_codepoint(i) + 1;
    196         }
    197         if (cp < hi) {
    198             gaps->insert_range(cp, hi);
    199         }
    200     }
    201     return gaps;
    202 }
    203 
    204 /** ------------------------------------------------------------------------------------------------------------- *
    205  * @brief outerRanges
    206  * @param cc
    207  ** ------------------------------------------------------------------------------------------------------------- */
    208 CC * outerRanges(const CC * cc) {
    209     assert ("cc cannot be null" && cc);
    210     CC * ranges = makeCC();
    211     auto i = cc->cbegin();
    212     const auto end = cc->cend();
    213     for (auto j = i; ++j != end; ) {
    214         if (hi_codepoint(j) > hi_codepoint(i)) {
    215             ranges->insert_range(lo_codepoint(i), hi_codepoint(i));
    216             i = j;
    217         }
    218     }
    219     return ranges;
    220 }
    221 
    222 /** ------------------------------------------------------------------------------------------------------------- *
    223  * @brief innerRanges
    224  * @param cc
    225  ** ------------------------------------------------------------------------------------------------------------- */
    226 CC * innerRanges(const CC * cc) {
    227     assert ("cc cannot be null" && cc);
    228     CC * ranges = makeCC();
    229     auto i = cc->cbegin();
    230     const auto end = cc->cend();
    231     for (auto j = i; ++j != end; ) {
    232         if (hi_codepoint(j) <= hi_codepoint(i)) {
    233             ranges->insert_range(lo_codepoint(j), hi_codepoint(j));
    234         }
    235         else {
    236             i = j;
    237         }
    238     }
    239     return ranges;
    240 }
    241158   
    242159}
Note: See TracChangeset for help on using the changeset viewer.