| Index: runtime/vm/regexp_parser.cc
|
| diff --git a/runtime/vm/regexp_parser.cc b/runtime/vm/regexp_parser.cc
|
| index 30acc5515c173fe3ff820751917c39a634058086..1b2df30ede8e0f975d76892182c6bad062b08fdf 100644
|
| --- a/runtime/vm/regexp_parser.cc
|
| +++ b/runtime/vm/regexp_parser.cc
|
| @@ -249,6 +249,32 @@ void RegExpParser::Reset(intptr_t pos) {
|
| }
|
|
|
|
|
| +bool RegExpParser::ParseFunction(ParsedFunction *parsed_function) {
|
| + Isolate* isolate = parsed_function->isolate();
|
| + JSRegExp& regexp = JSRegExp::Handle(parsed_function->function().regexp());
|
| +
|
| + const String& pattern = String::Handle(regexp.pattern());
|
| + const bool multiline = regexp.is_multi_line();
|
| +
|
| + RegExpCompileData* compile_data = new(isolate) RegExpCompileData();
|
| + if (!RegExpParser::ParseRegExp(pattern, multiline, compile_data)) {
|
| + // Parsing failures are handled in the JSRegExp factory constructor.
|
| + UNREACHABLE();
|
| + }
|
| +
|
| + regexp.set_num_bracket_expressions(compile_data->capture_count);
|
| + if (compile_data->simple) {
|
| + regexp.set_is_simple();
|
| + } else {
|
| + regexp.set_is_complex();
|
| + }
|
| +
|
| + parsed_function->SetRegExpCompileData(compile_data);
|
| +
|
| + return true;
|
| +}
|
| +
|
| +
|
| bool RegExpParser::ParseRegExp(const String& input,
|
| bool multiline,
|
| RegExpCompileData* result) {
|
| @@ -266,10 +292,15 @@ bool RegExpParser::ParseRegExp(const String& input,
|
| result->capture_count = capture_count;
|
| } else {
|
| ASSERT(!result->error.IsNull());
|
| -
|
| - // TODO(jgruber): Throw a format exception once we are ready to replace
|
| - // jscre. For now, we ignore the error set by LongJump.
|
| Isolate::Current()->object_store()->clear_sticky_error();
|
| +
|
| + // Throw a FormatException on parsing failures.
|
| + const String& message = String::Handle(
|
| + String::Concat(result->error, input));
|
| + const Array& args = Array::Handle(Array::New(1));
|
| + args.SetAt(0, message);
|
| +
|
| + Exceptions::ThrowByType(Exceptions::kFormat, args);
|
| }
|
| return !parser.failed();
|
| }
|
|
|