Changeset 6259


Ignore:
Timestamp:
Dec 29, 2018, 4:05:37 PM (3 months ago)
Author:
cameron
Message:

Small fixes for lookaround optimization

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

Legend:

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

    r6256 r6259  
    5252    RE * transformSeq(Seq * s) override {
    5353        if (s->empty()) return s;
    54         RE * t = transform(s->back());
    55         if (s == t) return s;
     54        RE * s_last = s->back();
     55        RE * t = transform(s_last);
     56        if (s_last == t) return s;
    5657        std::vector<RE *> elems;
    5758        for (unsigned i = 0; i < s->size() - 1; i++) {
  • icGREP/icgrep-devel/icgrep/re/re_contextual_simplification.cpp

    r6257 r6259  
    281281        }
    282282    } else {
    283         llvm_unreachable("Context::simplifyAsserted: Unexpected asserted value");
     283        // For other types, we do not apply any simplification rules.
     284        return asserted;
    284285    }
    285286}
  • icGREP/icgrep-devel/icgrep/re/re_rep.cpp

    r6226 r6259  
    88#include "re_assertion.h"
    99#include "re_seq.h"
     10#include "re_empty_set.h"
    1011#include "re_alt.h"
    1112#include "re_nullable.h"
     
    3233    if (LLVM_UNLIKELY(ub != Rep::UNBOUNDED_REP && ub < lb)) {
    3334        report_fatal_error("lower bound cannot exceed upper bound");
     35    }
     36    if (isEmptySet(re)) {
     37        // Match failure.
     38        return re;
     39    }
     40    if (isEmptySeq(re)) {
     41        // Repeated match of empty string: just match once.
     42        return re;
    3443    }
    3544    if (isNullable(re)) {
Note: See TracChangeset for help on using the changeset viewer.