| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/regexp/regexp-parser.h" | 5 #include "src/regexp/regexp-parser.h" |
| 6 | 6 |
| 7 #include "src/char-predicates-inl.h" | 7 #include "src/char-predicates-inl.h" |
| 8 #include "src/factory.h" | 8 #include "src/factory.h" |
| 9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
| 10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 case '/': | 123 case '/': |
| 124 return true; | 124 return true; |
| 125 default: | 125 default: |
| 126 break; | 126 break; |
| 127 } | 127 } |
| 128 return false; | 128 return false; |
| 129 } | 129 } |
| 130 | 130 |
| 131 | 131 |
| 132 RegExpTree* RegExpParser::ReportError(Vector<const char> message) { | 132 RegExpTree* RegExpParser::ReportError(Vector<const char> message) { |
| 133 if (failed_) return NULL; // Do not overwrite any existing error. |
| 133 failed_ = true; | 134 failed_ = true; |
| 134 *error_ = isolate()->factory()->NewStringFromAscii(message).ToHandleChecked(); | 135 *error_ = isolate()->factory()->NewStringFromAscii(message).ToHandleChecked(); |
| 135 // Zip to the end to make sure the no more input is read. | 136 // Zip to the end to make sure the no more input is read. |
| 136 current_ = kEndMarker; | 137 current_ = kEndMarker; |
| 137 next_pos_ = in()->length(); | 138 next_pos_ = in()->length(); |
| 138 return NULL; | 139 return NULL; |
| 139 } | 140 } |
| 140 | 141 |
| 141 | 142 |
| 142 #define CHECK_FAILED /**/); \ | 143 #define CHECK_FAILED /**/); \ |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 builder->AddCharacter(current()); | 505 builder->AddCharacter(current()); |
| 505 Advance(); | 506 Advance(); |
| 506 } else { | 507 } else { |
| 507 return ReportError(CStrVector("Invalid escape")); | 508 return ReportError(CStrVector("Invalid escape")); |
| 508 } | 509 } |
| 509 break; | 510 break; |
| 510 } | 511 } |
| 511 break; | 512 break; |
| 512 case '{': { | 513 case '{': { |
| 513 int dummy; | 514 int dummy; |
| 514 if (ParseIntervalQuantifier(&dummy, &dummy)) { | 515 bool parsed = ParseIntervalQuantifier(&dummy, &dummy CHECK_FAILED); |
| 515 return ReportError(CStrVector("Nothing to repeat")); | 516 if (parsed) return ReportError(CStrVector("Nothing to repeat")); |
| 516 } | |
| 517 // fallthrough | 517 // fallthrough |
| 518 } | 518 } |
| 519 case '}': | 519 case '}': |
| 520 case ']': | 520 case ']': |
| 521 if (unicode()) { | 521 if (unicode()) { |
| 522 return ReportError(CStrVector("Lone quantifier brackets")); | 522 return ReportError(CStrVector("Lone quantifier brackets")); |
| 523 } | 523 } |
| 524 // fallthrough | 524 // fallthrough |
| 525 default: | 525 default: |
| 526 builder->AddUnicodeCharacter(current()); | 526 builder->AddUnicodeCharacter(current()); |
| (...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 return false; | 1565 return false; |
| 1566 } | 1566 } |
| 1567 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), | 1567 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), |
| 1568 zone()); | 1568 zone()); |
| 1569 LAST(ADD_TERM); | 1569 LAST(ADD_TERM); |
| 1570 return true; | 1570 return true; |
| 1571 } | 1571 } |
| 1572 | 1572 |
| 1573 } // namespace internal | 1573 } // namespace internal |
| 1574 } // namespace v8 | 1574 } // namespace v8 |
| OLD | NEW |