OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class JSSyntaxRegExp implements RegExp { | 5 class JSSyntaxRegExp implements RegExp { |
6 const JSSyntaxRegExp( | 6 const JSSyntaxRegExp( |
7 String this.pattern, | 7 String this.pattern, |
8 [bool this.multiLine = false, | 8 [bool this.multiLine = false, |
9 bool this.ignoreCase = false]); | 9 bool this.ignoreCase = false]); |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 const JSSyntaxMatch(RegExp regexp, String str) | 35 const JSSyntaxMatch(RegExp regexp, String str) |
36 : this.pattern = regexp, this.str = str; | 36 : this.pattern = regexp, this.str = str; |
37 | 37 |
38 final String str; | 38 final String str; |
39 final Pattern pattern; | 39 final Pattern pattern; |
40 | 40 |
41 String operator[](int group) { | 41 String operator[](int group) { |
42 return this.group(group); | 42 return this.group(group); |
43 } | 43 } |
44 | 44 |
45 Array<String> groups(Array<int> groups) { | 45 List<String> groups(List<int> groups) { |
46 Array<String> strings = new Array<String>(); | 46 List<String> strings = new List<String>(); |
47 groups.forEach((int group) { | 47 groups.forEach((int group) { |
48 strings.add(this.group(group)); | 48 strings.add(this.group(group)); |
49 }); | 49 }); |
50 return strings; | 50 return strings; |
51 } | 51 } |
52 | 52 |
53 String group(int nb) native; | 53 String group(int nb) native; |
54 | 54 |
55 int start() native; | 55 int start() native; |
56 | 56 |
(...skipping 12 matching lines...) Expand all Loading... |
69 | 69 |
70 const _LazyAllMatches(this._regexp, this._str); | 70 const _LazyAllMatches(this._regexp, this._str); |
71 | 71 |
72 void forEach(void f(Match match)) { | 72 void forEach(void f(Match match)) { |
73 for (Match match in this) { | 73 for (Match match in this) { |
74 f(match); | 74 f(match); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 Collection<Match> filter(bool f(Match match)) { | 78 Collection<Match> filter(bool f(Match match)) { |
79 Array<Match> result = new Array<Match>(); | 79 List<Match> result = new List<Match>(); |
80 for (Match match in this) { | 80 for (Match match in this) { |
81 if (f(match)) result.add(match); | 81 if (f(match)) result.add(match); |
82 } | 82 } |
83 return result; | 83 return result; |
84 } | 84 } |
85 | 85 |
86 bool every(bool f(Match match)) { | 86 bool every(bool f(Match match)) { |
87 for (Match match in this) { | 87 for (Match match in this) { |
88 if (!f(match)) return false; | 88 if (!f(match)) return false; |
89 } | 89 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 bool hasNext() { | 133 bool hasNext() { |
134 if (_nextMatch != null) return true; | 134 if (_nextMatch != null) return true; |
135 _nextMatch = _computeNextMatch(_regexp, _str); | 135 _nextMatch = _computeNextMatch(_regexp, _str); |
136 return (_nextMatch != null); | 136 return (_nextMatch != null); |
137 } | 137 } |
138 | 138 |
139 void _jsInit(JSSyntaxRegExp regexp) native; | 139 void _jsInit(JSSyntaxRegExp regexp) native; |
140 Match _computeNextMatch(JSSyntaxRegExp regexp, String str) native; | 140 Match _computeNextMatch(JSSyntaxRegExp regexp, String str) native; |
141 } | 141 } |
OLD | NEW |