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

Unified Diff: petitparser/lib/src/reflection/transform.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « petitparser/lib/src/reflection/optimize.dart ('k') | petitparser/lib/src/smalltalk/grammar.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: petitparser/lib/src/reflection/transform.dart
diff --git a/petitparser/lib/src/reflection/transform.dart b/petitparser/lib/src/reflection/transform.dart
deleted file mode 100644
index 7206ea444d1652b66e44b1914eaab41c655a71ce..0000000000000000000000000000000000000000
--- a/petitparser/lib/src/reflection/transform.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-part of reflection;
-
-/**
- * A function transforming one parser to another one.
- */
-typedef Parser TransformationHandler(Parser parser);
-
-/**
- * Transforms all parsers reachable from [parser] with the given [handler].
- * The identity function returns a copy of the the incoming parser.
- *
- * The implementation first creates a copy of each parser reachable in the
- * input grammar; then the resulting grammar is traversed until all references
- * to old parsers are replaced with the transformed ones.
- */
-Parser transformParser(Parser parser, TransformationHandler handler) {
- var mapping = new Map.identity();
- for (var each in allParser(parser)) {
- mapping[each] = handler(each.copy());
- }
- var seen = new Set.from(mapping.values);
- var todo = new List.from(mapping.values);
- while (todo.isNotEmpty) {
- var parent = todo.removeLast();
- for (var child in parent.children) {
- if (mapping.containsKey(child)) {
- parent.replace(child, mapping[child]);
- } else if (!seen.contains(child)) {
- seen.add(child);
- todo.add(child);
- }
- }
- }
- return mapping[parser];
-}
« no previous file with comments | « petitparser/lib/src/reflection/optimize.dart ('k') | petitparser/lib/src/smalltalk/grammar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698