Changeset 5809


Ignore:
Timestamp:
Dec 26, 2017, 10:37:33 AM (3 weeks ago)
Author:
cameron
Message:

Failure case and fix

Location:
icGREP/icgrep-devel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/QA/greptest.xml

    r5807 r5809  
    589589<grepcase regexp="\S" datafile="LineBreaking" grepcount="16"/>
    590590<grepcase regexp="$" datafile="LineBreaking" grepcount="19"/>
     591<grepcase regexp="\p{ascii}" datafile="LineBreaking" grepcount="16"/>
    591592
    592593<grepcase regexp="[a-z]{20}" datafile="4KiB-onepage" grepcount="77"/>
  • icGREP/icgrep-devel/icgrep/re/exclude_CC.cpp

    r5805 r5809  
    2828RE * exclude_CC(RE * re, CC * cc) {
    2929    if (CC * cc0 = dyn_cast<CC>(re)) {
    30         return subtractCC(cc0, cc);
     30        if (intersects(cc0, cc)) return subtractCC(cc0, cc);
     31        else return cc0;
    3132    } else if (Seq * seq = dyn_cast<Seq>(re)) {
    3233        std::vector<RE*> list;
     
    5556    } else if (Name * n = dyn_cast<Name>(re)) {
    5657        switch (n->getType()) {
    57             case Name::Type::Unicode:
    58             case Name::Type::UnicodeProperty:
    59                 return makeName(subtractCC(cast<CC>(n->getDefinition()), cc));
     58            case Name::Type::Reference:
    6059            case Name::Type::ZeroWidth:
    6160                return re;
    6261            case Name::Type::Capture:
    6362                return makeCapture(n->getName(), exclude_CC(n->getDefinition(), cc));
    64             case Name::Type::Reference:
    65                 return re;
    6663            default:
    67                 report_fatal_error("exclude_CC: unhandled Name type");
     64                RE * defn = n->getDefinition();
     65                if (const CC * cc0 = dyn_cast<CC>(defn)) {
     66                    if (!intersects(cc0, cc)) return re;
     67                }
     68                std::string cc_name = n->getName() + "--" + cc->canonicalName(CC_type::UnicodeClass);
     69                return makeName(cc_name, n->getType(), exclude_CC(defn, cc));
     70                /*
     71                return exclude_CC(defn, cc);
     72                */
    6873        }
    6974    } else {
  • icGREP/icgrep-devel/icgrep/re/re_cc.h

    r5797 r5809  
    5151    friend CC * makeCC(std::vector<interval_t> && list, const cc::Alphabet * alphabet);
    5252    friend CC * makeCC(UCD::UnicodeSet && set, const cc::Alphabet * alphabet);
     53    friend bool intersects(const CC * a, const CC * b);
    5354    friend CC * subtractCC(const CC * a, const CC * b);
    5455    friend CC * intersectCC(const CC * a, const CC * b);
     
    145146}
    146147
     148inline bool intersects(const CC * a, const CC * b) {
     149    return (*a).intersects(*b);
     150}
     151
    147152inline CC * makeByte(const codepoint_t codepoint) {
    148153    return new CC(codepoint, &cc::Byte);
  • icGREP/icgrep-devel/icgrep/re/re_name.h

    r5805 r5809  
    4747    friend Name * makeName(const std::string &, Type);
    4848    friend Name * makeName(const std::string &, const std::string &, Type);
     49    friend Name * makeName(const std::string & nm, const Name::Type type, RE * defn);
    4950    Name(const char * nameSpace, const length_t namespaceLength, const char * name, const length_t nameLength, Type type, RE * defn)
    5051    : RE(ClassTypeId::Name)
     
    141142
    142143inline Name * makeName(const std::string & property, const std::string & value, const Name::Type type) {
    143     return new Name(property.c_str(), property.length(), value.c_str(), value.length(),  type, nullptr);
     144    return new Name(property.c_str(), property.length(), value.c_str(), value.length(), type, nullptr);
     145}
     146   
     147inline Name * makeName(const std::string & nm, const Name::Type type, RE * defn) {
     148    return new Name(nullptr, 0, nm.c_str(), nm.length(), type, defn);
    144149}
    145150
Note: See TracChangeset for help on using the changeset viewer.