Small, generic graph primitives -- extracted from Grammar.Analysis's
own private reachable/2/do_reachable/3 (used to detect left
recursion: a rule is left-recursive exactly when it's reachable from
its own leading references). Nothing here is grammar-specific --
neighbors_fn is the caller's own adjacency, a plain function rather
than a hardcoded map, so this works over whatever graph an author's
own AST/IR/dependency structure represents, not just Ichor's own
rule-reference graphs.
Summary
Functions
Every node reachable from start_nodes (inclusive) by repeatedly
following neighbors_fn. To check "is node reachable from
itself" (a cycle, not trivial zero-hop self-membership) -- the
left-recursion-detection use case this was extracted from -- start
from neighbors_fn.(node) rather than [node] itself.
Functions
@spec reachable(Enumerable.t(node), (node -> Enumerable.t(node))) :: MapSet.t(node) when node: term()
Every node reachable from start_nodes (inclusive) by repeatedly
following neighbors_fn. To check "is node reachable from
itself" (a cycle, not trivial zero-hop self-membership) -- the
left-recursion-detection use case this was extracted from -- start
from neighbors_fn.(node) rather than [node] itself.