findPath method

ParserPath? findPath(
  1. Parser source,
  2. Predicate<ParserPath> predicate
)

Returns the shortest path from source that satisfies the given predicate, if any.

Implementation

ParserPath? findPath(Parser source, Predicate<ParserPath> predicate) {
  ParserPath? path;
  for (final current in findAllPaths(source, predicate)) {
    if (path == null || current.length < path.length) {
      path = current;
    }
  }
  return path;
}