Changeset 5565


Ignore:
Timestamp:
Jul 13, 2017, 2:41:50 PM (4 months ago)
Author:
xuedongx
Message:

Separate name resolve and gather for future use. Add re_colloect_unicodesets and re_multiplex.

Location:
icGREP/icgrep-devel/icgrep
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r5564 r5565  
    8787add_library(PabloADT ${PABLO_SRC})
    8888add_library(RegExpADT re/re_re.cpp re/re_cc.cpp re/re_rep.cpp re/re_diff.cpp re/re_intersect.cpp re/printer_re.cpp)
    89 add_library(RegExpCompiler re/re_parser.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_star_normal.cpp re/re_compiler.cpp re/re_analysis.cpp re/re_toolchain.cpp re/re_name_resolve.cpp re/re_parser_pcre.cpp re/re_parser_ere.cpp re/re_parser_bre.cpp re/re_parser_prosite.cpp re/re_utility.cpp)
     89add_library(RegExpCompiler re/re_parser.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_star_normal.cpp re/re_compiler.cpp re/re_analysis.cpp re/re_toolchain.cpp re/re_name_resolve.cpp re/re_name_gather.cpp re/re_collect_unicodesets.cpp re/re_multiplex.cpp re/re_parser_pcre.cpp re/re_parser_ere.cpp re/re_parser_bre.cpp re/re_parser_prosite.cpp re/re_utility.cpp)
    9090add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp cc/alphabet.cpp cc/multiplex_CCs.cpp)
    9191add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r5563 r5565  
    2222#include <re/re_name.h>             // for Name, Name::Type, Name::Type::Zer...
    2323#include <re/re_name_resolve.h>     // for resolveNames
     24#include <re/re_name_gather.h>      // for gatherNames
    2425#include <re/re_rep.h>              // for Rep, Rep::::UNBOUNDED_REP
    2526#include <re/re_seq.h>              // for Seq
     
    4647    mCompiledName = &mBaseMap;
    4748
    48     auto nameMap = resolveNames(re, ZeroWidth);
     49    re = resolveNames(re);
     50    auto nameMap = gatherNames(re, ZeroWidth);
    4951    if (LLVM_LIKELY(nameMap.size() > 0)) {
    5052        UCD::UCDCompiler ucdCompiler(mCCCompiler);
  • icGREP/icgrep-devel/icgrep/re/re_name_resolve.cpp

    r5267 r5565  
    1414#include <boost/container/flat_set.hpp>
    1515#include <sstream>
    16 
    17 using NameMap = UCD::UCDCompiler::NameMap;
    1816
    1917using namespace boost::container;
     
    4038                } else if (LLVM_LIKELY(name->getType() == Name::Type::UnicodeProperty || name->getType() == Name::Type::ZeroWidth)) {
    4139                    if (UCD::resolvePropertyDefinition(name)) {
    42                         if (name->getType() == Name::Type::ZeroWidth) {
    43                             mZeroWidth = name;
    44                         }
    4540                        name->setDefinition(resolve(name->getDefinition()));
    4641                    } else {
    47                         name->setDefinition(makeCC(UCD::resolveUnicodeSet(name)));
     42                        name->setDefinition(makeCC(std::move(UCD::resolveUnicodeSet(name))));
    4843                    }
    4944                } else {
     
    113108    }
    114109
    115     void gather(RE * re) {
    116         assert ("RE object cannot be null!" && re);
    117         if (isa<Name>(re)) {
    118             if (mVisited.insert(cast<Name>(re)).second) {
    119                 if (isa<CC>(cast<Name>(re)->getDefinition())) {
    120                     mNameMap.emplace(cast<Name>(re), nullptr);
    121                 } else {
    122                     gather(cast<Name>(re)->getDefinition());
    123                 }
    124             }
    125         } else if (isa<Seq>(re)) {
    126             for (RE * item : *cast<Seq>(re)) {
    127                 gather(item);
    128             }
    129         } else if (isa<Alt>(re)) {
    130             for (RE * item : *cast<Alt>(re)) {
    131                 gather(item);
    132             }
    133         } else if (isa<Rep>(re)) {
    134             gather(cast<Rep>(re)->getRE());
    135         } else if (isa<Assertion>(re)) {
    136             gather(cast<Assertion>(re)->getAsserted());
    137         } else if (isa<Diff>(re)) {
    138             gather(cast<Diff>(re)->getLH());
    139             gather(cast<Diff>(re)->getRH());
    140         } else if (isa<Intersect>(re)) {
    141             gather(cast<Intersect>(re)->getLH());
    142             gather(cast<Intersect>(re)->getRH());
    143         }
    144     }
    145 
    146     NameResolver(NameMap & nameMap, Name *& zeroWidth)
    147     : mZeroWidth(zeroWidth)
    148     , mNameMap(nameMap) {
     110    NameResolver() {
    149111
    150112    }
    151113
    152114private:
    153 
    154     Name *&                 mZeroWidth;
    155     NameMap &               mNameMap;
    156115    Memoizer                mMemoizer;
    157     flat_set<Name *>        mVisited;
    158 
    159116};
    160117   
    161 NameMap resolveNames(RE *& re, Name *& zeroWidth) {
    162     NameMap nameMap;
    163     NameResolver nameResolver(nameMap, zeroWidth);
    164     re = nameResolver.resolve(re);
    165     nameResolver.gather(re);
    166     return nameMap;
    167    
     118RE * resolveNames(RE *& re) {
     119    NameResolver nameResolver;
     120    return nameResolver.resolve(re);   
    168121}
    169122
  • icGREP/icgrep-devel/icgrep/re/re_name_resolve.h

    r5233 r5565  
    99    class Name;
    1010
    11     UCD::UCDCompiler::NameMap resolveNames(RE * &re, Name * &zerowidth);
     11    RE * resolveNames(RE * &re);
    1212
    1313}
Note: See TracChangeset for help on using the changeset viewer.