| OLD | NEW |
| 1 part of reflection; | 1 part of petitparser.reflection; |
| 2 | 2 |
| 3 /** | 3 /// Returns a lazy iterable over all parsers reachable from a [root]. |
| 4 * Returns a lazy iterable over all parsers reachable from a [root]. | 4 /// |
| 5 * | 5 /// For example, the following code prints the two parsers of the |
| 6 * For example, the following code prints the two parsers of the | 6 /// defined grammar: |
| 7 * defined grammar: | 7 /// |
| 8 * | 8 /// var parser = range('0', '9').star(); |
| 9 * var parser = range('0', '9').star(); | 9 /// allParser(parser).forEach((each) { |
| 10 * allParser(parser).forEach((each) { | 10 /// print(each); |
| 11 * print(each); | 11 /// }); |
| 12 * }); | 12 /// |
| 13 * | |
| 14 */ | |
| 15 Iterable<Parser> allParser(Parser root) => new _ParserIterable(root); | 13 Iterable<Parser> allParser(Parser root) => new _ParserIterable(root); |
| 16 | 14 |
| 17 class _ParserIterable extends IterableBase<Parser> { | 15 class _ParserIterable extends IterableBase<Parser> { |
| 18 final Parser root; | 16 final Parser root; |
| 19 | 17 |
| 20 _ParserIterable(this.root); | 18 _ParserIterable(this.root); |
| 21 | 19 |
| 22 @override | 20 @override |
| 23 Iterator<Parser> get iterator => new _ParserIterator([root]); | 21 Iterator<Parser> get iterator => new _ParserIterator([root]); |
| 24 } | 22 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 43 current = todo.removeLast(); | 41 current = todo.removeLast(); |
| 44 for (var parser in current.children) { | 42 for (var parser in current.children) { |
| 45 if (!seen.contains(parser)) { | 43 if (!seen.contains(parser)) { |
| 46 todo.add(parser); | 44 todo.add(parser); |
| 47 seen.add(parser); | 45 seen.add(parser); |
| 48 } | 46 } |
| 49 } | 47 } |
| 50 return true; | 48 return true; |
| 51 } | 49 } |
| 52 } | 50 } |
| OLD | NEW |