Ignore:
Timestamp:
Oct 18, 2015, 2:14:59 PM (4 years ago)
Author:
nmedfort
Message:

Bug fix for bounded expressions + grapheme cluster mode.

File:
1 edited

Legend:

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

    r4841 r4846  
    1212#include <re/re_assertion.h>
    1313#include <re/re_grapheme_boundary.hpp>
     14#include <re/re_analysis.h>
    1415#include <algorithm>
    1516#include <memory>
     
    2021RE * RE_Simplifier::simplify(RE * re) {
    2122    if (Alt * alt = dyn_cast<Alt>(re)) {
    22         std::vector<RE*> list;
     23        std::vector<RE *> list;
    2324        list.reserve(alt->size());
    2425        for (RE * re : *alt) {
     
    2728        re = makeAlt(list.begin(), list.end());
    2829    } else if (Seq * seq = dyn_cast<Seq>(re)) {
    29         std::vector<RE*> list;
     30        std::vector<RE *> list;
    3031        list.reserve(seq->size());
    3132        for (RE * re : *seq) {
     
    3637        re = makeAssertion(simplify(a->getAsserted()), a->getKind(), a->getSense());
    3738    } else if (Rep * rep = dyn_cast<Rep>(re)) {
    38         re = makeRep(simplify(rep->getRE()), rep->getLB(), rep->getUB());
     39        RE * expr = simplify(rep->getRE());
     40        if (GraphemeBoundary * gp = dyn_cast<GraphemeBoundary>(expr)) {
     41            if (gp->getExpression() && isUnicodeUnitLength(gp->getExpression())) {
     42                rep->setRE(gp->getExpression());
     43                gp->setExpression(rep);
     44                return gp;
     45            }
     46        }
     47        re = makeRep(expr, rep->getLB(), rep->getUB());
    3948    } else if (Diff * diff = dyn_cast<Diff>(re)) {
    4049        re = makeDiff(simplify(diff->getLH()), diff->getRH());
    4150    } else if (Intersect * e = dyn_cast<Intersect>(re)) {
    4251        re = makeIntersect(simplify(e->getLH()), e->getRH());
     52    } else if (GraphemeBoundary * gp = dyn_cast<GraphemeBoundary>(re)) {
     53        if (gp->getExpression() && isa<GraphemeBoundary>(gp->getExpression())) {
     54            re = gp->getExpression();
     55        }
    4356    }
    4457    return re;
Note: See TracChangeset for help on using the changeset viewer.