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