Permalink
Browse files

Avoid looping during graph construction

But still create links for each use of an atom.
  • Loading branch information...
1 parent 31e86b4 commit 8158f5e09c44cf048ca1a7ab822f748437dc64d9 @kschiess committed Jul 31, 2013
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/parslet/graphviz.rb
View
@@ -16,6 +16,7 @@ class GraphvizVisitor
def initialize g
@graph = g
@known_links = Set.new
+ @visited = Set.new
end
attr_reader :parent
@@ -27,6 +28,10 @@ def visit_entity(name, block)
s = node(name)
downwards s
+
+ return if @visited.include?(name)
+ @visited << name
+
recurse block.call, s
end
def visit_named(name, atom)

0 comments on commit 8158f5e

Please sign in to comment.