@@ -11,38 +11,52 @@ _range_string(::LastLayerTypeRule) = "last layer"
11
11
_range_string (r:: FirstNTypeRule ) = " layers $(1 : r. n) "
12
12
_range_string (r:: LastNTypeRule ) = " last $(r. n) layers"
13
13
14
+ const COLOR_COMMENT = :light_black
15
+ const COLOR_RULE = :yellow
16
+ const COLOR_TYPE = :blue
17
+ const COLOR_RANGE = :green
18
+
19
+ typename (x) = string (nameof (typeof (x)))
20
+
14
21
function Base. show (io:: IO , m:: MIME"text/plain" , c:: Composite )
15
- println (io, " Composite(" )
22
+ println (io, " Composite" , " (" )
16
23
for p in c. primitives
17
24
_show_primitive (io, p, 2 )
18
25
end
19
- return println (io, " )" )
26
+ println (io, " )" )
27
+ return nothing
20
28
end
21
29
22
30
function _show_primitive (io:: IO , r:: AbstractRulePrimitive , indent:: Int = 0 )
23
- print (io, " " ^ indent, nameof ( typeof (r) ), " : " )
24
- printstyled (io, _range_string (r); color= :blue )
31
+ print (io, " " ^ indent, typename (r ), " : " )
32
+ printstyled (io, _range_string (r); color= COLOR_RANGE )
25
33
print (io, " => " )
26
- printstyled (io, r. rule; color= :yellow )
34
+ printstyled (io, r. rule; color= COLOR_RULE )
27
35
println (io, " ," )
28
36
return nothing
29
37
end
30
38
31
- function _show_primitive (io:: IO , r:: AbstractCompositePrimitive , indent:: Int = 0 )
32
- print (io, " " ^ indent, nameof ( typeof (r)), " (" )
33
- printstyled (io, " # on " , _range_string (r); color= :light_black )
39
+ function _show_primitive (io:: IO , r:: AbstractTypeRulePrimitive , indent:: Int = 0 )
40
+ print (io, " " ^ indent, rpad ( typename (r) * " (" , 20 ) )
41
+ printstyled (io, " # on " , _range_string (r); color= COLOR_COMMENT )
34
42
println (io)
35
43
_print_rules (io, r. map, indent)
44
+ println (io, " " ^ (indent), " )," )
36
45
return nothing
37
46
end
38
47
39
48
function _print_rules (io:: IO , rs, indent:: Int = 0 )
40
49
for r in rs
41
- printstyled (io, " " ^ (indent + 2 ), r. first; color= :blue )
42
- print (io, " => " )
43
- printstyled (io, r. second; color= :yellow )
50
+ print (io, " " ^ (indent + 2 ))
51
+ _print_type_rule (io, r)
44
52
println (io, " ," )
45
53
end
46
- println (io, " " ^ (indent), " )," )
54
+ return nothing
55
+ end
56
+
57
+ function _print_type_rule (io:: IO , r:: TypeRulePair )
58
+ printstyled (io, r. first; color= COLOR_TYPE)
59
+ print (io, " => " )
60
+ printstyled (io, r. second; color= COLOR_RULE)
47
61
return nothing
48
62
end
0 commit comments