Changeset 4256 for icGREP


Ignore:
Timestamp:
Oct 21, 2014, 1:03:34 PM (5 years ago)
Author:
cameron
Message:

Remove the negated attribute for unicode categories; use Diff(any, cat)

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

Legend:

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

    r4255 r4256  
    129129        cc = pb.createVar(name->getName());
    130130    }
    131     if (name->isNegated()) {
    132         cc = pb.createNot(pb.createOr(pb.createOr(cc, mLineFeed), mNonFinal));
    133     }
    134131    return pb.createAssign("m", pb.createAdvance(pb.createAnd(cc, marker)));
    135132}
     
    198195        }
    199196
    200         if (rep_name->isNegated()) {
    201             cc = pb.createNot(pb.createOr(cc, pb.createOr(mLineFeed, mNonFinal)));
    202         }
    203 
    204197        unbounded = pb.createVar(target);
    205198        if (rep_name->getType() == Name::Type::FixedLength) {
  • icGREP/icgrep-devel/icgrep/re/re_name.h

    r4249 r4256  
    3030    };
    3131    const std::string & getName() const;
    32     bool isNegated() const;
    3332    Type getType() const;
    3433    RE *getCC() const;
     
    4342protected:
    4443    friend Name * makeName(const std::string, RE *);
    45     friend Name * makeName(const std::string, const bool, const Type);
     44    friend Name * makeName(const std::string, const Type);
    4645
    47     Name(const std::string && name, const bool negated, const Type type, RE * cc)
     46    Name(const std::string && name, const Type type, RE * cc)
    4847    : RE(ClassTypeId::Name)
    4948    , mName(std::move(name))
    50     , mNegated(negated)
    5149    , mType(type)
    5250    , mCC(cc)
     
    5856private:
    5957    const std::string   mName;
    60     const bool          mNegated;
    6158    const Type          mType;
    6259    RE *                mCC;
     
    6663inline const std::string & Name::getName() const {
    6764    return mName;
    68 }
    69 
    70 inline bool Name::isNegated() const {
    71     return mNegated;
    7265}
    7366
     
    8477}
    8578
    86 inline Name * makeName(const std::string name, const bool negated = false, const Name::Type type = Name::Type::FixedLength) {
    87     return new Name(std::move(name), negated, type, nullptr);
     79inline Name * makeName(const std::string name, const Name::Type type = Name::Type::FixedLength) {
     80    return new Name(std::move(name), type, nullptr);
    8881}
    8982
     
    9285        return cast<Name>(cc);
    9386    }
    94     return new Name(std::move(name), false, Name::Type::FixedLength, cc);
     87    return new Name(std::move(name), Name::Type::FixedLength, cc);
    9588}
    9689
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r4255 r4256  
    191191    ++_cursor;
    192192    throw_incomplete_expression_error_if_end_of_stream();
    193     bool negated = false;
    194193    switch (*_cursor) {
    195194        case '(': case ')': case '*': case '+':
     
    200199            return makeCC(parse_hex());
    201200        case 'P':
    202             negated = true;
     201            return makeDiff(makeAny(), parse_unicode_category());
    203202        case 'p':
    204             return parse_unicode_category(negated);
     203            return parse_unicode_category();
    205204    }
    206205    throw ParseFailure("Illegal backslash escape!");
     
    249248}
    250249
    251 inline Name * RE_Parser::parse_unicode_category(const bool negated) {
     250inline Name * RE_Parser::parse_unicode_category() {
    252251    if (++_cursor != _end && *_cursor == '{') {
    253252        const cursor_t start = _cursor + 1;
     
    261260            ++_cursor;
    262261        }
    263         return makeName(std::string(start, _cursor++), negated, Name::Type::UnicodeCategory);
     262        return makeName(std::string(start, _cursor++), Name::Type::UnicodeCategory);
    264263    }
    265264    throw ParseFailure("Incorrect Unicode character class format!");
  • icGREP/icgrep-devel/icgrep/re/re_parser.h

    r4255 r4256  
    4848    unsigned parse_utf8_codepoint();
    4949
    50     Name * parse_unicode_category(const bool negated);
     50    Name * parse_unicode_category();
    5151
    5252    RE * parse_charset();
Note: See TracChangeset for help on using the changeset viewer.