Modify lex yaml output to elide FileStart/End in tests. (#4433)

Trying to make split file tests of lex functionality shorter and easier
to read. numeric_literals.carbon in particular has an example of why I'm
interested in this (at the bottom). This also switches from `[]` list
format to `-` list format so that the trailing `]` is removed.

Trimming comments in tokenized_buffer.h because (1) it feels like it's
giving too much detail about what's printed, which has drifted slightly
and (2) it also feels like it's trying to justify YAML output, when
that's just what we're doing in general.

---------

Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
Jon Ross-Perkins
2024-10-23 18:56:41 +00:00
committed by GitHub
co-authored by Geoff Romer
parent d1c6f0152e
commit 06f4eec91e
23 changed files with 233 additions and 311 deletions
+12 -1
View File
@@ -176,6 +176,16 @@ Dump the tokens to stdout when lexed.
)""",
},
[&](auto& arg_b) { arg_b.Set(&dump_tokens); });
b.AddFlag(
{
.name = "omit-file-boundary-tokens",
.help = R"""(
For `--dump-tokens`, omit file start and end boundary tokens.
)""",
},
[&](auto& arg_b) { arg_b.Set(&omit_file_boundary_tokens); });
b.AddFlag(
{
.name = "dump-parse-tree",
@@ -356,7 +366,8 @@ class CompilationUnit {
[&] { tokens_ = Lex::Lex(value_stores_, *source_, *consumer_); });
if (options_.dump_tokens && IncludeInDumps()) {
consumer_->Flush();
driver_env_->output_stream << tokens_;
tokens_->Print(driver_env_->output_stream,
options_.omit_file_boundary_tokens);
}
if (mem_usage_) {
mem_usage_->Collect("tokens_", *tokens_);