OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/longjump.h" | 5 #include "vm/longjump.h" |
6 #include "vm/object_store.h" | 6 #include "vm/object_store.h" |
7 #include "vm/regexp_parser.h" | 7 #include "vm/regexp_parser.h" |
8 | 8 |
9 namespace dart { | 9 namespace dart { |
10 | 10 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 RegExpTree* tree = parser.ParsePattern(); | 260 RegExpTree* tree = parser.ParsePattern(); |
261 ASSERT(tree != NULL); | 261 ASSERT(tree != NULL); |
262 ASSERT(result->error.IsNull()); | 262 ASSERT(result->error.IsNull()); |
263 result->tree = tree; | 263 result->tree = tree; |
264 intptr_t capture_count = parser.captures_started(); | 264 intptr_t capture_count = parser.captures_started(); |
265 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0; | 265 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0; |
266 result->contains_anchor = parser.contains_anchor(); | 266 result->contains_anchor = parser.contains_anchor(); |
267 result->capture_count = capture_count; | 267 result->capture_count = capture_count; |
268 } else { | 268 } else { |
269 ASSERT(!result->error.IsNull()); | 269 ASSERT(!result->error.IsNull()); |
| 270 Isolate::Current()->object_store()->clear_sticky_error(); |
270 | 271 |
271 // TODO(jgruber): Throw a format exception once we are ready to replace | 272 // Throw a FormatException on parsing failures. |
272 // jscre. For now, we ignore the error set by LongJump. | 273 const String& message = String::Handle( |
273 Isolate::Current()->object_store()->clear_sticky_error(); | 274 String::Concat(result->error, input)); |
| 275 const Array& args = Array::Handle(Array::New(1)); |
| 276 args.SetAt(0, message); |
| 277 |
| 278 Exceptions::ThrowByType(Exceptions::kFormat, args); |
274 } | 279 } |
275 return !parser.failed(); | 280 return !parser.failed(); |
276 } | 281 } |
277 | 282 |
278 | 283 |
279 void RegExpParser::ReportError(const char* message) { | 284 void RegExpParser::ReportError(const char* message) { |
280 failed_ = true; | 285 failed_ = true; |
281 *error_ = String::New(message); | 286 *error_ = String::New(message); |
282 // Zip to the end to make sure the no more input is read. | 287 // Zip to the end to make sure the no more input is read. |
283 current_ = kEndMarker; | 288 current_ = kEndMarker; |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 uint32_t c = ParseClassCharacterEscape(); | 1036 uint32_t c = ParseClassCharacterEscape(); |
1032 return CharacterRange::Singleton(c); | 1037 return CharacterRange::Singleton(c); |
1033 } | 1038 } |
1034 } else { | 1039 } else { |
1035 Advance(); | 1040 Advance(); |
1036 return CharacterRange::Singleton(first); | 1041 return CharacterRange::Singleton(first); |
1037 } | 1042 } |
1038 } | 1043 } |
1039 | 1044 |
1040 } // namespace dart | 1045 } // namespace dart |
OLD | NEW |