Make the tree structure more explicit in parse dumps (#7591)

It's hard to track 2-space indent levels across large vertical gaps, and
it can be hard to suppress the instinct to read the dump as if it were
preorder. This change introduces a new dump mode that addresses both
problems by using box-drawing characters to explicitly represent the
parent-child edges of the tree. This new mode is the default, but the
old behavior remains available with
`--parse-dump-format=yaml-postorder`.
This commit is contained in:
Geoff Romer
2026-07-31 16:44:18 +00:00
committed by GitHub
parent 2c91e5f5de
commit 6429c1655c
343 changed files with 11839 additions and 12185 deletions
+23 -24
View File
@@ -13,27 +13,26 @@ impl i32 as Interface {
}
// CHECK:STDOUT: - filename: basic.carbon
// CHECK:STDOUT: parse_tree: [
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'ImplIntroducer', text: 'impl'},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'ImplTypeAs', text: 'as', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'Interface'},
// CHECK:STDOUT: {kind: 'ImplDefinitionStart', text: '{', subtree_size: 5},
// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
// CHECK:STDOUT: {kind: 'IdentifierNameMaybeBeforeSignature', text: 'Add'},
// CHECK:STDOUT: {kind: 'ExplicitParamListStart', text: '('},
// CHECK:STDOUT: {kind: 'SelfValueName', text: 'self'},
// CHECK:STDOUT: {kind: 'SelfBindingPattern', text: 'self', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PatternListComma', text: ','},
// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeSignature', text: 'b'},
// CHECK:STDOUT: {kind: 'BindingPatternTypeStart', text: ':'},
// CHECK:STDOUT: {kind: 'SelfTypeNameExpr', text: 'Self'},
// CHECK:STDOUT: {kind: 'LetBindingPattern', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'ExplicitParamList', text: ')', subtree_size: 9},
// CHECK:STDOUT: {kind: 'SelfTypeNameExpr', text: 'Self'},
// CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2},
// CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 14},
// CHECK:STDOUT: {kind: 'ImplDefinition', text: '}', subtree_size: 20},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDOUT: ╭─FileStart ''
// CHECK:STDOUT: │ ╭─ImplIntroducer 'impl'
// CHECK:STDOUT: │ │ ╭─IntTypeLiteral 'i32'
// CHECK:STDOUT: │ ├─ImplTypeAs 'as'
// CHECK:STDOUT: │ ├─IdentifierNameExpr 'Interface'
// CHECK:STDOUT: │ ╭─ImplDefinitionStart '{'
// CHECK:STDOUT: │ │ ╭─FunctionIntroducer 'fn'
// CHECK:STDOUT: │ │ ├─IdentifierNameMaybeBeforeSignature 'Add'
// CHECK:STDOUT: │ │ │ ╭─ExplicitParamListStart '('
// CHECK:STDOUT: │ │ │ │ ╭─SelfValueName 'self'
// CHECK:STDOUT: │ │ │ ├─SelfBindingPattern 'self'
// CHECK:STDOUT: │ │ │ ├─PatternListComma ','
// CHECK:STDOUT: │ │ │ │ ╭─IdentifierNameNotBeforeSignature 'b'
// CHECK:STDOUT: │ │ │ │ ├─BindingPatternTypeStart ':'
// CHECK:STDOUT: │ │ │ │ ├─SelfTypeNameExpr 'Self'
// CHECK:STDOUT: │ │ │ ├─LetBindingPattern ':'
// CHECK:STDOUT: │ │ ├─ExplicitParamList ')'
// CHECK:STDOUT: │ │ │ ╭─SelfTypeNameExpr 'Self'
// CHECK:STDOUT: │ │ ├─ReturnType '->'
// CHECK:STDOUT: │ ├─FunctionDecl ';'
// CHECK:STDOUT: ├─ImplDefinition '}'
// CHECK:STDOUT: ├─FileEnd ''
// CHECK:STDOUT: (root)