blob: 5c33a872e5800b19f9c549ee4f8c4086f4f5d0b2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# encoding: utf-8
module ActionDispatch
module Journey # :nodoc:
module NFA # :nodoc:
module Dot # :nodoc:
def to_dot
edges = transitions.map { |from, sym, to|
" #{from} -> #{to} [label=\"#{sym || 'ε'}\"];"
}
#memo_nodes = memos.values.flatten.map { |n|
# label = n
# if Journey::Route === n
# label = "#{n.verb.source} #{n.path.spec}"
# end
# " #{n.object_id} [label=\"#{label}\", shape=box];"
#}
#memo_edges = memos.map { |k, memos|
# (memos || []).map { |v| " #{k} -> #{v.object_id};" }
#}.flatten.uniq
<<-eodot
digraph nfa {
rankdir=LR;
node [shape = doublecircle];
#{accepting_states.join ' '};
node [shape = circle];
#{edges.join "\n"}
}
eodot
end
end
end
end
end
|