Changeset 5910 for icGREP


Ignore:
Timestamp:
Mar 14, 2018, 11:03:07 AM (15 months ago)
Author:
cameron
Message:

hasEndAnchor

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

Legend:

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

    r5908 r5910  
    495495}
    496496
     497   
     498bool hasEndAnchor(const RE * re) {
     499    if (const Alt * alt = dyn_cast<Alt>(re)) {
     500        for (const RE * re : *alt) {
     501            if (!hasEndAnchor(re)) {
     502                return false;
     503            }
     504        }
     505        return true;
     506    } else if (const Seq * seq = dyn_cast<Seq>(re)) {
     507        return (!seq->empty()) && isa<End>(seq->back());
     508    } else if (const Rep * rep = dyn_cast<Rep>(re)) {
     509        return hasEndAnchor(rep->getRE());
     510    } else if (const Diff * diff = dyn_cast<Diff>(re)) {
     511        return hasEndAnchor(diff->getLH()) && !hasEndAnchor(diff->getRH());
     512    } else if (const Intersect * e = dyn_cast<Intersect>(re)) {
     513        return hasEndAnchor(e->getLH()) && hasEndAnchor(e->getRH());
     514    } else if (isa<End>(re)) {
     515        return true;
     516    }
     517    return false; // otherwise
     518}
     519   
     520
    497521void UndefinedNameError(const Name * n) {
    498522    report_fatal_error("Error: Undefined name in regular expression: \"" + n->getName() + "\".");
  • icGREP/icgrep-devel/icgrep/re/re_analysis.h

    r5908 r5910  
    3434bool hasTriCCwithinLimit(RE * r, unsigned byteCClimit, RE * & prefixRE, RE * & suffixRE);
    3535
     36bool hasEndAnchor(const RE * r);
    3637   
    3738void UndefinedNameError (const Name * n);
Note: See TracChangeset for help on using the changeset viewer.