mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
+31
-32
@@ -20,35 +20,34 @@ fn F() {
|
||||
}
|
||||
|
||||
// CHECK:STDOUT: - filename: basic.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: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
|
||||
// CHECK:STDOUT: {kind: 'WhileConditionStart', text: '('},
|
||||
// CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'},
|
||||
// CHECK:STDOUT: {kind: 'WhileCondition', text: ')', subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
|
||||
// CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
|
||||
// CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'b'},
|
||||
// CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
|
||||
// CHECK:STDOUT: {kind: 'BreakStatementStart', text: 'break'},
|
||||
// CHECK:STDOUT: {kind: 'BreakStatement', text: ';', subtree_size: 2},
|
||||
// CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 4},
|
||||
// CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8},
|
||||
// CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
|
||||
// CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'c'},
|
||||
// CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
|
||||
// CHECK:STDOUT: {kind: 'ContinueStatementStart', text: 'continue'},
|
||||
// CHECK:STDOUT: {kind: 'ContinueStatement', text: ';', subtree_size: 2},
|
||||
// CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 4},
|
||||
// CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8},
|
||||
// CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 18},
|
||||
// CHECK:STDOUT: {kind: 'WhileStatement', text: 'while', subtree_size: 22},
|
||||
// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 28},
|
||||
// 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: │ ╭─FunctionDefinitionStart '{'
|
||||
// CHECK:STDOUT: │ │ ╭─WhileConditionStart '('
|
||||
// CHECK:STDOUT: │ │ ├─IdentifierNameExpr 'a'
|
||||
// CHECK:STDOUT: │ │ ╭─WhileCondition ')'
|
||||
// CHECK:STDOUT: │ │ │ ╭─CodeBlockStart '{'
|
||||
// CHECK:STDOUT: │ │ │ │ ╭─IfConditionStart '('
|
||||
// CHECK:STDOUT: │ │ │ │ ├─IdentifierNameExpr 'b'
|
||||
// CHECK:STDOUT: │ │ │ │ ╭─IfCondition ')'
|
||||
// CHECK:STDOUT: │ │ │ │ │ ╭─CodeBlockStart '{'
|
||||
// CHECK:STDOUT: │ │ │ │ │ │ ╭─BreakStatementStart 'break'
|
||||
// CHECK:STDOUT: │ │ │ │ │ ├─BreakStatement ';'
|
||||
// CHECK:STDOUT: │ │ │ │ ├─CodeBlock '}'
|
||||
// CHECK:STDOUT: │ │ │ ├─IfStatement 'if'
|
||||
// CHECK:STDOUT: │ │ │ │ ╭─IfConditionStart '('
|
||||
// CHECK:STDOUT: │ │ │ │ ├─IdentifierNameExpr 'c'
|
||||
// CHECK:STDOUT: │ │ │ │ ╭─IfCondition ')'
|
||||
// CHECK:STDOUT: │ │ │ │ │ ╭─CodeBlockStart '{'
|
||||
// CHECK:STDOUT: │ │ │ │ │ │ ╭─ContinueStatementStart 'continue'
|
||||
// CHECK:STDOUT: │ │ │ │ │ ├─ContinueStatement ';'
|
||||
// CHECK:STDOUT: │ │ │ │ ├─CodeBlock '}'
|
||||
// CHECK:STDOUT: │ │ │ ├─IfStatement 'if'
|
||||
// CHECK:STDOUT: │ │ ├─CodeBlock '}'
|
||||
// CHECK:STDOUT: │ ├─WhileStatement 'while'
|
||||
// CHECK:STDOUT: ├─FunctionDefinition '}'
|
||||
// CHECK:STDOUT: ├─FileEnd ''
|
||||
// CHECK:STDOUT: (root)
|
||||
|
||||
Reference in New Issue
Block a user