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

Side by Side Diff: petitparser/lib/src/reflection/optimize.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « petitparser/lib/src/reflection/iterable.dart ('k') | petitparser/lib/src/reflection/transform.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698