[go: up one dir, main page]

Menu

[390b88]: / dot / pprint.py  Maximize  Restore  History

Download this file

48 lines (32 with data), 705 Bytes

 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
37
38
39
40
41
42
43
44
45
46
47
'''Dot pretty-printing.'''
from transf import parse
import box
parse.Transfs('''
ppId = strings.tostr
ppAttr =
Attr(name, value)
-> H([ <ppId name>, "=", <ppId value> ])
ppAttrs =
!H([ "[", <Map(ppAttr); box.commas>, "]" ])
ppNode =
Node(nid, attrs, _)
-> H([ <ppId nid>, <ppAttrs attrs> ])
ppNodes = lists.Map(ppNode)
ppNodeEdge =
Edge(dst, attrs)
-> H([ <ppId src>, "->", <ppId dst>, <ppAttrs attrs> ])
ppNodeEdges =
Node(src, _, edges)
-> <Map(ppNodeEdge) edges>
ppEdges =
lists.MapConcat(ppNodeEdges)
ppGraph =
Graph(nodes)
-> V([
H([ "digraph", " ", "{" ]),
V( <ppNodes nodes> ),
V( <ppEdges nodes> ),
H([ "}" ])
])
pprint = ppGraph
''')