Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: runtime/lib/regexp_patch.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/regexp.cc ('k') | runtime/lib/string_base.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 patch class RegExp { 5 patch class RegExp {
6 /* patch */ factory RegExp(String pattern, 6 /* patch */ factory RegExp(String pattern,
7 {bool multiLine: false, 7 {bool multiLine: false,
8 bool ignoreCase: false}) { 8 bool caseSensitive: true}) {
9 return new _JSSyntaxRegExp(pattern, 9 return new _JSSyntaxRegExp(pattern,
10 multiLine: multiLine, 10 multiLine: multiLine,
11 ignoreCase: ignoreCase); 11 caseSensitive: caseSensitive);
12 } 12 }
13 } 13 }
14 14
15 class _JSRegExpMatch implements Match { 15 class _JSRegExpMatch implements Match {
16 _JSRegExpMatch(this.regexp, this.str, this._match); 16 _JSRegExpMatch(this.regexp, this.str, this._match);
17 17
18 int get start => _start(0); 18 int get start => _start(0);
19 int get end => _end(0); 19 int get end => _end(0);
20 20
21 int _start(int groupIdx) { 21 int _start(int groupIdx) {
(...skipping 15 matching lines...) Expand all
37 return null; 37 return null;
38 } 38 }
39 return str._substringUnchecked(startIndex, endIndex); 39 return str._substringUnchecked(startIndex, endIndex);
40 } 40 }
41 41
42 String operator [](int groupIdx) { 42 String operator [](int groupIdx) {
43 return this.group(groupIdx); 43 return this.group(groupIdx);
44 } 44 }
45 45
46 List<String> groups(List<int> groupsSpec) { 46 List<String> groups(List<int> groupsSpec) {
47 var groupsList = new List<String>(groupsSpec.length); 47 var groupsList = new List<String>.fixedLength(groupsSpec.length);
48 for (int i = 0; i < groupsSpec.length; i++) { 48 for (int i = 0; i < groupsSpec.length; i++) {
49 groupsList[i] = group(groupsSpec[i]); 49 groupsList[i] = group(groupsSpec[i]);
50 } 50 }
51 return groupsList; 51 return groupsList;
52 } 52 }
53 53
54 int get groupCount => regexp._groupCount; 54 int get groupCount => regexp._groupCount;
55 55
56 String get pattern => regexp.pattern; 56 String get pattern => regexp.pattern;
57 57
58 final RegExp regexp; 58 final RegExp regexp;
59 final String str; 59 final String str;
60 final List<int> _match; 60 final List<int> _match;
61 static const int MATCH_PAIR = 2; 61 static const int MATCH_PAIR = 2;
62 } 62 }
63 63
64 64
65 class _JSSyntaxRegExp implements RegExp { 65 class _JSSyntaxRegExp implements RegExp {
66 factory _JSSyntaxRegExp( 66 factory _JSSyntaxRegExp(
67 String pattern, 67 String pattern,
68 {bool multiLine: false, 68 {bool multiLine: false,
69 bool ignoreCase: false}) native "JSSyntaxRegExp_factory"; 69 bool caseSensitive: true}) native "JSSyntaxRegExp_factory";
70 70
71 Match firstMatch(String str) { 71 Match firstMatch(String str) {
72 List match = _ExecuteMatch(str, 0); 72 List match = _ExecuteMatch(str, 0);
73 if (match == null) { 73 if (match == null) {
74 return null; 74 return null;
75 } 75 }
76 return new _JSRegExpMatch(this, str, match); 76 return new _JSRegExpMatch(this, str, match);
77 } 77 }
78 78
79 Iterable<Match> allMatches(String str) { 79 Iterable<Match> allMatches(String str) {
(...skipping 27 matching lines...) Expand all
107 String stringMatch(String str) { 107 String stringMatch(String str) {
108 List match = _ExecuteMatch(str, 0); 108 List match = _ExecuteMatch(str, 0);
109 if (match == null) { 109 if (match == null) {
110 return null; 110 return null;
111 } 111 }
112 return str._substringUnchecked(match[0], match[1]); 112 return str._substringUnchecked(match[0], match[1]);
113 } 113 }
114 114
115 String get pattern native "JSSyntaxRegExp_getPattern"; 115 String get pattern native "JSSyntaxRegExp_getPattern";
116 116
117 bool get multiLine native "JSSyntaxRegExp_multiLine"; 117 bool get isMultiLine native "JSSyntaxRegExp_getIsMultiLine";
118 118
119 bool get ignoreCase native "JSSyntaxRegExp_ignoreCase"; 119 bool get isCaseSensitive native "JSSyntaxRegExp_getIsCaseSensitive";
120 120
121 int get _groupCount native "JSSyntaxRegExp_getGroupCount"; 121 int get _groupCount native "JSSyntaxRegExp_getGroupCount";
122 122
123 List _ExecuteMatch(String str, int start_index) 123 List _ExecuteMatch(String str, int start_index)
124 native "JSSyntaxRegExp_ExecuteMatch"; 124 native "JSSyntaxRegExp_ExecuteMatch";
125 } 125 }
OLDNEW
« no previous file with comments | « runtime/lib/regexp.cc ('k') | runtime/lib/string_base.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698