| OLD | NEW |
| 1 part of reflection; | 1 part of petitparser.reflection; |
| 2 | 2 |
| 3 /** | 3 /// Returns a copy of [parser] with all settable parsers removed. |
| 4 * Returns a copy of [parser] with all settable parsers removed. | |
| 5 */ | |
| 6 Parser removeSettables(Parser parser) { | 4 Parser removeSettables(Parser parser) { |
| 7 return transformParser(parser, (each) { | 5 return transformParser(parser, (each) { |
| 8 while (each is SettableParser) { | 6 while (each is SettableParser) { |
| 9 each = each.children.first; | 7 each = each.children.first; |
| 10 } | 8 } |
| 11 return each; | 9 return each; |
| 12 }); | 10 }); |
| 13 } | 11 } |
| 14 | 12 |
| 15 /** | 13 /// Returns a copy of [parser] with all duplicates parsers collapsed. |
| 16 * Returns a copy of [parser] with all duplicates parsers collapsed. | |
| 17 */ | |
| 18 Parser removeDuplicates(Parser parser) { | 14 Parser removeDuplicates(Parser parser) { |
| 19 var uniques = new Set(); | 15 var uniques = new Set(); |
| 20 return transformParser(parser, (source) { | 16 return transformParser(parser, (source) { |
| 21 var target = uniques.firstWhere((each) { | 17 var target = uniques.firstWhere((each) { |
| 22 return source != each && source.isEqualTo(each); | 18 return source != each && source.isEqualTo(each); |
| 23 }, orElse: () => null); | 19 }, orElse: () => null); |
| 24 if (target == null) { | 20 if (target == null) { |
| 25 uniques.add(source); | 21 uniques.add(source); |
| 26 return source; | 22 return source; |
| 27 } else { | 23 } else { |
| 28 return target; | 24 return target; |
| 29 } | 25 } |
| 30 }); | 26 }); |
| 31 } | 27 } |
| OLD | NEW |