| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 final String _str; | 68 final String _str; |
| 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 map(f(Match match)) { |
| 79 List result = new List(); |
| 80 for (Match match in this) { |
| 81 result.add(f(match)); |
| 82 } |
| 83 return result; |
| 84 } |
| 85 |
| 78 Collection<Match> filter(bool f(Match match)) { | 86 Collection<Match> filter(bool f(Match match)) { |
| 79 List<Match> result = new List<Match>(); | 87 List<Match> result = new List<Match>(); |
| 80 for (Match match in this) { | 88 for (Match match in this) { |
| 81 if (f(match)) result.add(match); | 89 if (f(match)) result.add(match); |
| 82 } | 90 } |
| 83 return result; | 91 return result; |
| 84 } | 92 } |
| 85 | 93 |
| 86 bool every(bool f(Match match)) { | 94 bool every(bool f(Match match)) { |
| 87 for (Match match in this) { | 95 for (Match match in this) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 140 |
| 133 bool hasNext() { | 141 bool hasNext() { |
| 134 if (_nextMatch != null) return true; | 142 if (_nextMatch != null) return true; |
| 135 _nextMatch = _computeNextMatch(_regexp, _str); | 143 _nextMatch = _computeNextMatch(_regexp, _str); |
| 136 return (_nextMatch != null); | 144 return (_nextMatch != null); |
| 137 } | 145 } |
| 138 | 146 |
| 139 void _jsInit(JSSyntaxRegExp regexp) native; | 147 void _jsInit(JSSyntaxRegExp regexp) native; |
| 140 Match _computeNextMatch(JSSyntaxRegExp regexp, String str) native; | 148 Match _computeNextMatch(JSSyntaxRegExp regexp, String str) native; |
| 141 } | 149 } |
| OLD | NEW |