Changeset 4429


Ignore:
Timestamp:
Jan 21, 2015, 8:58:20 AM (4 years ago)
Author:
cameron
Message:

Throw exception for unsupported mode flags and repetition bounds > limits

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

Legend:

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

    r4413 r4429  
    221221                    switch (*_cursor++) {
    222222                        case 'i': modeBit = CASE_INSENSITIVE_MODE_FLAG; break;
    223                         case 'm': modeBit = MULTILINE_MODE_FLAG; break;
    224                         case 's': modeBit = DOTALL_MODE_FLAG; break;
    225                         case 'x': modeBit = IGNORE_SPACE_MODE_FLAG; break;
    226                         case 'd': modeBit = UNIX_LINES_MODE_FLAG; break;
    227                         default: throw ParseFailure("Unrecognized mode flag.");
     223                        //case 'm': modeBit = MULTILINE_MODE_FLAG; break;
     224                        //case 's': modeBit = DOTALL_MODE_FLAG; break;
     225                        //case 'x': modeBit = IGNORE_SPACE_MODE_FLAG; break;
     226                        //case 'd': modeBit = UNIX_LINES_MODE_FLAG; break;
     227                        default: throw ParseFailure("Unsupported mode flag.");
    228228                    }
    229229                    if (negateMode) {
     
    283283        default:
    284284            return re;
     285    }
     286    if (lower_bound > MAX_REPETITION_LOWER_BOUND || upper_bound > MAX_REPETITION_UPPER_BOUND) {
     287        throw ParseFailure("Bounded repetition exceeds icgrep implementation limit");
     288    }
     289    if ((upper_bound != Rep::UNBOUNDED_REP) && (lower_bound > upper_bound)) {
     290        throw ParseFailure("Lower bound cannot exceed upper bound in bounded repetition");
    285291    }
    286292    ++_cursor;
  • icGREP/icgrep-devel/icgrep/re/re_parser.h

    r4412 r4429  
    2929     IGNORE_SPACE_MODE_FLAG = 8,   // not currently implemented
    3030     UNIX_LINES_MODE_FLAG = 16};   // not currently implemented
     31   
     32const int MAX_REPETITION_LOWER_BOUND = 1024;
     33const int MAX_REPETITION_UPPER_BOUND = 2048;
     34
    3135typedef unsigned ModeFlagSet;
    3236   
Note: See TracChangeset for help on using the changeset viewer.