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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 // In order to know whether an escape is a backreference or not we have to scan | 666 // In order to know whether an escape is a backreference or not we have to scan |
667 // the entire regexp and find the number of capturing parentheses. However we | 667 // the entire regexp and find the number of capturing parentheses. However we |
668 // don't want to scan the regexp twice unless it is necessary. This mini-parser | 668 // don't want to scan the regexp twice unless it is necessary. This mini-parser |
669 // is called when needed. It can see the difference between capturing and | 669 // is called when needed. It can see the difference between capturing and |
670 // noncapturing parentheses and can skip character classes and backslash-escaped | 670 // noncapturing parentheses and can skip character classes and backslash-escaped |
671 // characters. | 671 // characters. |
672 void RegExpParser::ScanForCaptures() { | 672 void RegExpParser::ScanForCaptures() { |
673 // Start with captures started previous to current position | 673 // Start with captures started previous to current position |
674 intptr_t capture_count = captures_started(); | 674 intptr_t capture_count = captures_started(); |
675 // Add count of captures after this position. | 675 // Add count of captures after this position. |
676 intptr_t n; | 676 uintptr_t n; |
677 while ((n = current()) != kEndMarker) { | 677 while ((n = current()) != kEndMarker) { |
678 Advance(); | 678 Advance(); |
679 switch (n) { | 679 switch (n) { |
680 case '\\': | 680 case '\\': |
681 Advance(); | 681 Advance(); |
682 break; | 682 break; |
683 case '[': { | 683 case '[': { |
684 intptr_t c; | 684 uintptr_t c; |
685 while ((c = current()) != kEndMarker) { | 685 while ((c = current()) != kEndMarker) { |
686 Advance(); | 686 Advance(); |
687 if (c == '\\') { | 687 if (c == '\\') { |
688 Advance(); | 688 Advance(); |
689 } else { | 689 } else { |
690 if (c == ']') break; | 690 if (c == ']') break; |
691 } | 691 } |
692 } | 692 } |
693 break; | 693 break; |
694 } | 694 } |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 String::Concat(result->error, input)); | 1069 String::Concat(result->error, input)); |
1070 const Array& args = Array::Handle(Array::New(1)); | 1070 const Array& args = Array::Handle(Array::New(1)); |
1071 args.SetAt(0, message); | 1071 args.SetAt(0, message); |
1072 | 1072 |
1073 Exceptions::ThrowByType(Exceptions::kFormat, args); | 1073 Exceptions::ThrowByType(Exceptions::kFormat, args); |
1074 } | 1074 } |
1075 return !parser.failed(); | 1075 return !parser.failed(); |
1076 } | 1076 } |
1077 | 1077 |
1078 } // namespace dart | 1078 } // namespace dart |
OLD | NEW |