Parses the regexp src and then simplifies it and sets *dst to the string representation of the simplified form. Returns true on success. Returns false and sets *error (if error != NULL) on error.
| 21 | // string representation of the simplified form. Returns true on success. |
| 22 | // Returns false and sets *error (if error != NULL) on error. |
| 23 | bool Regexp::SimplifyRegexp(const StringPiece& src, ParseFlags flags, |
| 24 | std::string* dst, RegexpStatus* status) { |
| 25 | Regexp* re = Parse(src, flags, status); |
| 26 | if (re == NULL) |
| 27 | return false; |
| 28 | Regexp* sre = re->Simplify(); |
| 29 | re->Decref(); |
| 30 | if (sre == NULL) { |
| 31 | if (status) { |
| 32 | status->set_code(kRegexpInternalError); |
| 33 | status->set_error_arg(src); |
| 34 | } |
| 35 | return false; |
| 36 | } |
| 37 | *dst = sre->ToString(); |
| 38 | sre->Decref(); |
| 39 | return true; |
| 40 | } |
| 41 | |
| 42 | // Assuming the simple_ flags on the children are accurate, |
| 43 | // is this Regexp* simple? |