Ignore:
Timestamp:
Dec 30, 2017, 4:43:19 PM (22 months ago)
Author:
cameron
Message:

Parsing of byte CCs

Location:
icGREP/icgrep-devel/icgrep/re
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_memoizer.hpp

    r5630 r5814  
    2121    }
    2222
    23     Name * memoize(CC * const cc) {
    24         auto f = find(cc);
    25         if (f != end()) {
    26             return llvm::cast<Name>(*f);
    27         } else {
    28             return memoize(makeName(cc));
    29         }
     23    CC * memoize(CC * const cc) {
     24        return llvm::cast<CC>(memoize(llvm::cast<RE>(cc)));
    3025    }
    3126};
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r5805 r5814  
    348348    else if (atany("xo0")) {
    349349        codepoint_t cp = parse_escaped_codepoint();
    350         if ((cp >= 0x80) && (cp <= 0xFF)) {
     350        if ((cp <= 0xFF)) {
    351351            return makeByte(cp);
    352352        }
     
    715715RE * RE_Parser::parse_escaped_char_item() {
    716716    if (accept('N')) return parseNamePatternExpression();
     717    else if (atany("xo0")) {
     718        codepoint_t cp = parse_escaped_codepoint();
     719        if ((cp <= 0xFF)) {
     720            return makeByte(cp);
     721        }
     722        else return createCC(cp);
     723    }
    717724    else return makeCC(parse_escaped_codepoint());
    718725}
     
    811818}
    812819
    813 Name * RE_Parser::createCC(const codepoint_t cp) {
    814     CC * cc = makeCC(cp);
    815     return mMemoizer.memoize(cc);
    816 }
    817 
    818 void RE_Parser::insert(CC * cc, const codepoint_t cp) {
    819     cc->insert(cp);
    820 }
    821 
    822 void RE_Parser::insert_range(CC * cc, const codepoint_t lo, const codepoint_t hi) {
    823     cc->insert_range(lo, hi);
     820CC * RE_Parser::createCC(const codepoint_t cp) {
     821    CC * cc = mMemoizer.memoize(makeCC(cp));
     822    return cc;
    824823}
    825824
     
    828827}
    829828
    830            
    831 
    832                            
    833829RE * RE_Parser::makeWordBoundary() {
    834830    Name * wordC = makeWordSet();
  • icGREP/icgrep-devel/icgrep/re/re_parser.h

    r5792 r5814  
    233233    codepoint_t parse_octal_codepoint(int mindigits, int maxdigits);
    234234
    235     // CC insertion dependent on case-insensitive flag.
    236     Name * createCC(const codepoint_t cp);
    237     void insert(CC * cc, const codepoint_t cp);
    238     void insert_range(CC * cc, const codepoint_t lo, const codepoint_t hi);
     235    CC * createCC(const codepoint_t cp);
    239236
    240237    static std::string canonicalize(const cursor_t begin, const cursor_t end);
  • icGREP/icgrep-devel/icgrep/re/re_range.cpp

    r5792 r5814  
    2121        auto lo_val = dyn_cast<CC>(lo)->front().first;
    2222        auto hi_val = dyn_cast<CC>(hi)->front().first;
    23         if (hi_val < lo_val) llvm::report_fatal_error("illegal range");
    24         return makeCC(lo_val, hi_val);
     23        return makeCC(lo_val, hi_val, dyn_cast<CC>(hi)->getAlphabet());
    2524    }
    2625    else if (isa<Name>(lo) && (cast<Name>(lo)->getDefinition() != nullptr)) {
Note: See TracChangeset for help on using the changeset viewer.