mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 14:01:06 +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:
@@ -56,10 +56,16 @@ auto Parse(Lex::TokenizedBuffer& tokens, ParseOptions options) -> Tree {
|
||||
CARBON_VLOG_TO(options.vlog_stream, "*** Parse::Tree ***\n{0}", tree);
|
||||
if (options.dump_stream) {
|
||||
Parse::TreeAndSubtrees tree_and_subtrees(tokens, tree);
|
||||
if (options.dump_preorder_parse_tree) {
|
||||
tree_and_subtrees.PrintPreorder(*options.dump_stream);
|
||||
} else {
|
||||
tree_and_subtrees.Print(*options.dump_stream);
|
||||
switch (options.dump_format) {
|
||||
case ParseOptions::DumpFormat::PrettyPostorder:
|
||||
tree_and_subtrees.PrettyPrint(*options.dump_stream);
|
||||
break;
|
||||
case ParseOptions::DumpFormat::YamlPostorder:
|
||||
tree_and_subtrees.PrintYamlPostorder(*options.dump_stream);
|
||||
break;
|
||||
case ParseOptions::DumpFormat::YamlPreorder:
|
||||
tree_and_subtrees.PrintYamlPreorder(*options.dump_stream);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user