@@ -44,18 +44,23 @@ extension _ASTPrintable {
44
44
guard let children = _children else {
45
45
return _dumpBase
46
46
}
47
- let sub = children. lazy . compactMap {
47
+ let childDump = children. compactMap { child -> String ? in
48
48
// Exclude trivia for now, as we don't want it to appear when performing
49
49
// comparisons of dumped output in tests.
50
50
// TODO: We should eventually have some way of filtering out trivia for
51
51
// tests, so that it can appear in regular dumps.
52
- if $0. isTrivia { return nil }
53
- return $0. _dump ( )
54
- } . joined ( separator: " , " )
55
- if sub. isEmpty {
56
- return " \( _dumpBase) "
52
+ if child. isTrivia { return nil }
53
+ let dump = child. _dump ( )
54
+ return !dump. isEmpty ? dump : nil
57
55
}
58
- return " \( _dumpBase) ( \( sub) ) "
56
+ let base = " \( _dumpBase) "
57
+ if childDump. isEmpty {
58
+ return base
59
+ }
60
+ if childDump. count == 1 , base. isEmpty {
61
+ return " \( childDump [ 0 ] ) "
62
+ }
63
+ return " \( base) ( \( childDump. joined ( separator: " , " ) ) ) "
59
64
}
60
65
}
61
66
@@ -77,7 +82,7 @@ extension AST.Node: _ASTPrintable {
77
82
}
78
83
79
84
extension AST . Alternation {
80
- public var _dumpBase : String { " alternation " }
85
+ public var _dumpBase : String { " alternation< \( children . count ) > " }
81
86
}
82
87
83
88
extension AST . Concatenation {
0 commit comments