Index: petitparser/lib/src/reflection/iterable.dart |
diff --git a/petitparser/lib/src/reflection/iterable.dart b/petitparser/lib/src/reflection/iterable.dart |
deleted file mode 100644 |
index b6579ffffcf1f645a1d95b4b077afacf20eb1534..0000000000000000000000000000000000000000 |
--- a/petitparser/lib/src/reflection/iterable.dart |
+++ /dev/null |
@@ -1,52 +0,0 @@ |
-part of reflection; |
- |
-/** |
- * Returns a lazy iterable over all parsers reachable from a [root]. |
- * |
- * For example, the following code prints the two parsers of the |
- * defined grammar: |
- * |
- * var parser = range('0', '9').star(); |
- * allParser(parser).forEach((each) { |
- * print(each); |
- * }); |
- * |
- */ |
-Iterable<Parser> allParser(Parser root) => new _ParserIterable(root); |
- |
-class _ParserIterable extends IterableBase<Parser> { |
- final Parser root; |
- |
- _ParserIterable(this.root); |
- |
- @override |
- Iterator<Parser> get iterator => new _ParserIterator([root]); |
-} |
- |
-class _ParserIterator implements Iterator<Parser> { |
- final List<Parser> todo; |
- final Set<Parser> seen; |
- |
- _ParserIterator(Iterable<Parser> roots) |
- : todo = new List.from(roots), |
- seen = new Set.from(roots); |
- |
- @override |
- Parser current; |
- |
- @override |
- bool moveNext() { |
- if (todo.isEmpty) { |
- current = null; |
- return false; |
- } |
- current = todo.removeLast(); |
- for (var parser in current.children) { |
- if (!seen.contains(parser)) { |
- todo.add(parser); |
- seen.add(parser); |
- } |
- } |
- return true; |
- } |
-} |