Changeset 5898


Ignore:
Timestamp:
Mar 10, 2018, 2:37:49 PM (12 months ago)
Author:
cameron
Message:

Fix Unicode unit length calculations to allow for assertions

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/resolve_properties.cpp

    r5881 r5898  
    3737   
    3838RE * UnicodeBreakRE() {
    39     return makeAlt({makeCC(0x0A, 0x0C), makeSeq({makeCC(0x0D), makeCC(0x0A)}), makeSeq({makeCC(0x0D), makeNegativeLookAheadAssertion(makeCC(0x0A))})});
     39    return makeAlt({makeCC(0x0A, 0x0C), makeCC(0x85), makeCC(0x2028,0x2029), makeSeq({makeCC(0x0D), makeNegativeLookAheadAssertion(makeCC(0x0A))})});
    4040}
    4141
  • icGREP/icgrep-devel/icgrep/re/re_analysis.cpp

    r5892 r5898  
    155155        return true;
    156156    } else if (const Seq * seq = dyn_cast<Seq>(re)) {
    157         return (seq->size() == 1) && isUnicodeUnitLength(&seq[0]);
     157        bool unitLengthSeen = false;
     158        for (const RE * e : *seq) {
     159            if (isa<Assertion>(e)) continue;
     160            else if (unitLengthSeen) return false;
     161            else if (isUnicodeUnitLength(e)) unitLengthSeen = true;
     162            else return false;
     163        }
     164        return unitLengthSeen;
    158165    } else if (const Rep * rep = dyn_cast<Rep>(re)) {
    159166        return (rep->getLB() == 1) && (rep->getUB() == 1) && isUnicodeUnitLength(rep->getRE());
     
    172179        if (n->getType() == Name::Type::Unicode || n->getType() == Name::Type::UnicodeProperty) {
    173180            return true;
    174         } else if (n->getType() == Name::Type::Capture || n->getType() == Name::Type::Reference) {
    175             return isUnicodeUnitLength(n->getDefinition());
    176         }
    177         return false;
     181        } else if (n->getType() == Name::Type::ZeroWidth) {
     182            return false;
     183        }
     184        return isUnicodeUnitLength(n->getDefinition());
    178185    }
    179186    return false; // otherwise
Note: See TracChangeset for help on using the changeset viewer.