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
@@ -20,29 +20,28 @@ fn f() -> i32 {
}
// CHECK:STDOUT: - filename: fail_missing_case_pattern.carbon
// CHECK:STDOUT: parse_tree: [
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
// CHECK:STDOUT: {kind: 'IdentifierNameMaybeBeforeSignature', text: 'f'},
// CHECK:STDOUT: {kind: 'ExplicitParamListStart', text: '('},
// CHECK:STDOUT: {kind: 'ExplicitParamList', text: ')', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2},
// CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 7},
// CHECK:STDOUT: {kind: 'MatchIntroducer', text: 'match'},
// CHECK:STDOUT: {kind: 'MatchConditionStart', text: '('},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '3'},
// CHECK:STDOUT: {kind: 'MatchCondition', text: ')', subtree_size: 3},
// CHECK:STDOUT: {kind: 'MatchStatementStart', text: '{', subtree_size: 5},
// CHECK:STDOUT: {kind: 'MatchCaseIntroducer', text: 'case'},
// CHECK:STDOUT: {kind: 'InvalidParse', text: '=>', has_error: yes},
// CHECK:STDOUT: {kind: 'MatchCase', text: '=>', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'MatchHandlerStart', text: '=>', has_error: yes, subtree_size: 4},
// CHECK:STDOUT: {kind: 'MatchHandler', text: '=>', has_error: yes, subtree_size: 5},
// CHECK:STDOUT: {kind: 'MatchStatement', text: '}', subtree_size: 11},
// CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 3},
// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 22},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDOUT: ╭─FileStart ''
// CHECK:STDOUT: │ ╭─FunctionIntroducer 'fn'
// CHECK:STDOUT: │ ├─IdentifierNameMaybeBeforeSignature 'f'
// CHECK:STDOUT: │ │ ╭─ExplicitParamListStart '('
// CHECK:STDOUT: │ ├─ExplicitParamList ')'
// CHECK:STDOUT: │ │ ╭─IntTypeLiteral 'i32'
// CHECK:STDOUT: │ ├─ReturnType '->'
// CHECK:STDOUT: │ ╭─FunctionDefinitionStart '{'
// CHECK:STDOUT: │ │ ╭─MatchIntroducer 'match'
// CHECK:STDOUT: │ │ │ ╭─MatchConditionStart '('
// CHECK:STDOUT: │ │ │ ├─IntLiteral '3'
// CHECK:STDOUT: │ │ ├─MatchCondition ')'
// CHECK:STDOUT: │ │ ╭─MatchStatementStart '{'
// CHECK:STDOUT: │ │ │ ╭─MatchCaseIntroducer 'case'
// CHECK:STDOUT: │ │ │ ├─InvalidParse '=>' has_error
// CHECK:STDOUT: │ │ │ ╭─MatchCase '=>' has_error
// CHECK:STDOUT: │ │ │ ╭─MatchHandlerStart '=>' has_error
// CHECK:STDOUT: │ │ ├─MatchHandler '=>' has_error
// CHECK:STDOUT: │ ├─MatchStatement '}'
// CHECK:STDOUT: │ │ ╭─ReturnStatementStart 'return'
// CHECK:STDOUT: │ │ ├─IntLiteral '0'
// CHECK:STDOUT: │ ├─ReturnStatement ';'
// CHECK:STDOUT: ├─FunctionDefinition '}'
// CHECK:STDOUT: ├─FileEnd ''
// CHECK:STDOUT: (root)