Ignore:
Timestamp:
Dec 23, 2017, 9:16:39 PM (16 months ago)
Author:
cameron
Message:

Additional Alphabet analysis and transformation

File:
1 edited

Legend:

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

    r5770 r5801  
    1515#include <re/re_nullable.h>
    1616#include <re/printer_re.h>
     17#include <cc/alphabet.h>
     18#include <cc/multiplex_CCs.h>
    1719#include <limits.h>
    1820#include <llvm/Support/ErrorHandling.h>
     
    119121    } else if (const Intersect * e = dyn_cast<Intersect>(re)) {
    120122        return isByteLength(e->getLH()) && isByteLength(e->getRH());
    121     } else if (isa<CC>(re)) {
    122         return cast<CC>(re)->max_codepoint() <= 0x7F;
    123     } else if (const Name * n = dyn_cast<Name>(re)) {
    124         if (n->getType() == Name::Type::Byte) {
    125             return true;
    126         } else if (n->getType() == Name::Type::Capture || n->getType() == Name::Type::Reference) {
    127             return isByteLength(n->getDefinition());
    128         }
    129         return false;
     123    } else if (const CC * cc = dyn_cast<CC>(re)) {
     124        const cc::Alphabet * a = cc->getAlphabet();
     125        if (a == &cc::Unicode) return (cc->max_codepoint() <= 0x7F);
     126        else if (a == &cc::Byte) return true;
     127        else if (isa<cc::MultiplexedAlphabet>(a)) {
     128            const cc::Alphabet * srcA = cast<cc::MultiplexedAlphabet>(a)->getSourceAlphabet();
     129            if (srcA == &cc::Byte) {
     130                return true;
     131//            } else if (srcA == &cc::Unicode) {
     132//                return cast<cc::MultiplexedAlphabet>(a)->invertCC(cc)->max_codepoint() <= 0x7F;
     133            } else return (a == &cc::Byte);
     134        }
     135        return false;
     136    } else if (const Name * n = dyn_cast<Name>(re)) {
     137        if (n->getType() == Name::Type::ZeroWidth) {
     138            return false;
     139        }
     140        return isByteLength(n->getDefinition());
    130141    }
    131142    return false; // otherwise
Note: See TracChangeset for help on using the changeset viewer.