Changeset 5805


Ignore:
Timestamp:
Dec 24, 2017, 12:05:36 PM (9 months ago)
Author:
cameron
Message:

Name::Type::Byte removed in favor of cc::Byte alphabet; other cleanups

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

Legend:

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

    r5798 r5805  
    513513    for (auto & t : names) {
    514514        Name * const name = t.first;
    515         if (name->getType() == Name::Type::Byte) {
    516             continue;
    517         }       
    518515        CC * const cc = dyn_cast<CC>(name->getDefinition());
    519         if (cc) {
     516        if (cc && (cc->getAlphabet() == &cc::Unicode)) {
    520517            const auto f = CCs.find(cc);
    521518            // This check may not be needed. Memoization ought to detect duplicate classes earlier.
     
    531528            }
    532529        } else {
    533             report_fatal_error(name->getName() + " is not defined by a CC!");
     530            report_fatal_error(name->getName() + " is not defined by a Unicode CC!");
    534531        }
    535532    }
  • icGREP/icgrep-devel/icgrep/combine/stringGen.cpp

    r5613 r5805  
    138138
    139139        switch (re_name->getType()) {
    140                 case Name::Type::Byte:
    141140                case Name::Type::Unicode:
    142141                                retVec = generate(re_name->getDefinition());
  • icGREP/icgrep-devel/icgrep/kernels/charclasses.cpp

    r5787 r5805  
    1212#include <boost/uuid/sha1.hpp>
    1313#include <pablo/builder.hpp>
     14#include <llvm/Support/ErrorHandling.h>
    1415#include <llvm/Support/raw_ostream.h>
    1516
     
    9798        if (t != nameMap.end()) {
    9899            PabloAST * const r = pb.createExtract(getOutput(0), pb.getInteger(i));
    99             if (t->first->getType() == Name::Type::Byte) {
    100                 pb.createAssign(r, ccc.compileCC(dyn_cast<CC>(t->first->getDefinition())));
    101             } else {
    102                 pb.createAssign(r, pb.createInFile(t->second));
    103             }
     100            pb.createAssign(r, pb.createInFile(t->second));
    104101        } else {
    105             throw std::runtime_error("Can't compile character classes.");
     102            llvm::report_fatal_error("Can't compile character classes.");
    106103        }
    107104    }
  • icGREP/icgrep-devel/icgrep/re/exclude_CC.cpp

    r5779 r5805  
    5555    } else if (Name * n = dyn_cast<Name>(re)) {
    5656        switch (n->getType()) {
    57             case Name::Type::Byte:
    5857            case Name::Type::Unicode:
    5958            case Name::Type::UnicodeProperty:
  • icGREP/icgrep-devel/icgrep/re/re_analysis.cpp

    r5801 r5805  
    167167    } else if (const Name * n = dyn_cast<Name>(re)) {
    168168        // Eventually names might be set up for not unit length items.
    169         if (n->getType() == Name::Type::Unicode || n->getType() == Name::Type::UnicodeProperty || n->getType() == Name::Type::Byte) {
     169        if (n->getType() == Name::Type::Unicode || n->getType() == Name::Type::UnicodeProperty) {
    170170            return true;
    171171        } else if (n->getType() == Name::Type::Capture || n->getType() == Name::Type::Reference) {
     
    230230        // Eventually names might be set up for not unit length items.
    231231        switch (n->getType()) {
    232             case Name::Type::Byte:
    233232            case Name::Type::Unicode:
    234233            case Name::Type::UnicodeProperty:
     
    275274        // Eventually names might be set up for not unit length items.
    276275        switch (n->getType()) {
    277             case Name::Type::Byte:
    278276            case Name::Type::Unicode:
    279277            case Name::Type::UnicodeProperty:
  • icGREP/icgrep-devel/icgrep/re/re_name.h

    r5797 r5805  
    2222    using length_t = std::string::size_type;
    2323    enum class Type {
    24         Byte
    25         , Unicode
     24        Unicode
    2625        , UnicodeProperty
    2726        , Capture
     
    150149    }
    151150    else if (llvm::isa<CC>(cc)) {
    152         Name::Type ccType = llvm::cast<CC>(cc)->max_codepoint() <= 0x7F ? Name::Type::Byte : Name::Type::Unicode;
    153         return new Name(nullptr, 0, name.c_str(), name.length(), ccType, cc);
     151        return new Name(nullptr, 0, name.c_str(), name.length(), Name::Type::Unicode, cc);
    154152    }
    155153    else return new Name(nullptr, 0, name.c_str(), name.length(), Name::Type::Unknown, cc);
     
    157155
    158156inline Name * makeName(CC * const cc) {
    159     const bool ascii = cc->max_codepoint() <= 0x7F;
    160     const std::string name = cc->canonicalName(ascii ? CC_type::ByteClass : CC_type::UnicodeClass);
    161     return new Name(nullptr, 0, name.c_str(), name.length(), ascii ? Name::Type::Byte : Name::Type::Unicode, cc);
     157    const std::string name = cc->canonicalName(CC_type::UnicodeClass);
     158    return new Name(nullptr, 0, name.c_str(), name.length(), Name::Type::Unicode, cc);
    162159}
    163160
  • icGREP/icgrep-devel/icgrep/re/re_name_gather.cpp

    r5787 r5805  
    1212#include <re/re_analysis.h>
    1313#include <re/re_memoizer.hpp>
     14#include <cc/alphabet.h>
    1415#include <UCD/ucd_compiler.hpp>
    1516#include <UCD/resolve_properties.h>
     
    3031        if (isa<Name>(re)) {
    3132            if (mVisited.insert(cast<Name>(re)).second) {
    32                 if (cast<Name>(re)->getType() == Name::Type::ZeroWidth) {
    33                     mZeroWidth = cast<Name>(re);
    34                 }
    35                 if (isa<CC>(cast<Name>(re)->getDefinition())) {
    36                     mNameMap.emplace(cast<Name>(re), nullptr);
     33                RE * defn = cast<Name>(re)->getDefinition();
     34                if (isa<CC>(defn)) {
     35                    if (cast<CC>(defn)->getAlphabet() == &cc::Unicode)
     36                        mNameMap.emplace(cast<Name>(re), nullptr);
    3737                } else {
    38                     gather(cast<Name>(re)->getDefinition());
     38                    gather(defn);
    3939                }
    4040            }
     
    6464        }
    6565    }
    66     NameGather(NameMap & nameMap, Name *& zeroWidth)
    67     : mZeroWidth(zeroWidth)
    68     , mNameMap(nameMap) {
     66    NameGather(NameMap & nameMap)
     67    : mNameMap(nameMap) {
    6968
    7069    }
     
    7271private:
    7372
    74     Name *&                 mZeroWidth;
    7573    NameMap &               mNameMap;
    7674    flat_set<Name *>        mVisited;
     
    7876};
    7977   
    80 NameMap gatherNames(RE *& re, Name *& zeroWidth) {
     78NameMap gatherNames(RE *& re) {
    8179    NameMap nameMap;
    82     NameGather nameGather(nameMap, zeroWidth);
     80    NameGather nameGather(nameMap);
    8381    nameGather.gather(re);
    8482    return nameMap;
  • icGREP/icgrep-devel/icgrep/re/re_name_gather.h

    r5565 r5805  
    99    class Name;
    1010
    11     UCD::UCDCompiler::NameMap gatherNames(RE * &re, Name * &zerowidth);
     11    UCD::UCDCompiler::NameMap gatherNames(RE * &re);
    1212
    1313}
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r5797 r5805  
    9090    // Branch reset groups only affect submatch numbering, but
    9191    // this has no effect in icgrep.
    92     return r;
     92    RE_Parser::ParseFailure("Branch reset groups not supported.");
    9393}
    9494
  • icGREP/icgrep-devel/icgrep/re/re_reverse.cpp

    r5777 r5805  
    3131RE * reverse_helper(RE * re, std::map<std::string, Name *> & captureMap) {
    3232    if (CC * cc = dyn_cast<CC>(re)) {
    33         return makeCC(cc, makeCC());
     33        return re;
    3434    } else if (Range * rg = dyn_cast<Range>(re)) {
    3535        return makeRange(rg->getLo(), rg->getHi());
     
    6262    } else if (Name * n = dyn_cast<Name>(re)) {
    6363        switch (n->getType()) {
    64             case Name::Type::Byte:
    6564            case Name::Type::Unicode:
    6665                return makeName(cast<CC>(n->getDefinition()));
Note: See TracChangeset for help on using the changeset viewer.