mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 16:01:04 +01:00
Bracket the tokenized buffer output. (#2446)
This makes TokenizedBuffer more consistent with ParseTree and SemanticsIR, which also wrap with [] to produce a sequence value. It also makes it possible in driver.cpp to just prefix the line with a name, so it ends up with: var_name: [ (content) ] Noticed this due to bracketing comments on #2443 and trying to think of better answers. With this, we can also say that the [] bracket a variable.
This commit is contained in:
@@ -133,29 +133,29 @@ TEST(DriverTest, DumpTokens) {
|
||||
auto tokenized_text = test_output_stream.TakeStr();
|
||||
|
||||
EXPECT_THAT(Yaml::Value::FromText(tokenized_text),
|
||||
ElementsAre(Yaml::MappingValue{
|
||||
{"token", Yaml::MappingValue{{"index", "0"},
|
||||
{"kind", "Identifier"},
|
||||
{"line", "1"},
|
||||
{"column", "1"},
|
||||
{"indent", "1"},
|
||||
{"spelling", "Hello"},
|
||||
{"identifier", "0"},
|
||||
{"has_trailing_space", "true"}}},
|
||||
{"token", Yaml::MappingValue{{"index", "1"},
|
||||
{"kind", "Identifier"},
|
||||
{"line", "1"},
|
||||
{"column", "7"},
|
||||
{"indent", "1"},
|
||||
{"spelling", "World"},
|
||||
{"identifier", "1"},
|
||||
{"has_trailing_space", "true"}}},
|
||||
{"token", Yaml::MappingValue{{"index", "2"},
|
||||
{"kind", "EndOfFile"},
|
||||
{"line", "1"},
|
||||
{"column", "12"},
|
||||
{"indent", "1"},
|
||||
{"spelling", ""}}}}));
|
||||
ElementsAre(Yaml::SequenceValue{
|
||||
Yaml::MappingValue{{"index", "0"},
|
||||
{"kind", "Identifier"},
|
||||
{"line", "1"},
|
||||
{"column", "1"},
|
||||
{"indent", "1"},
|
||||
{"spelling", "Hello"},
|
||||
{"identifier", "0"},
|
||||
{"has_trailing_space", "true"}},
|
||||
Yaml::MappingValue{{"index", "1"},
|
||||
{"kind", "Identifier"},
|
||||
{"line", "1"},
|
||||
{"column", "7"},
|
||||
{"indent", "1"},
|
||||
{"spelling", "World"},
|
||||
{"identifier", "1"},
|
||||
{"has_trailing_space", "true"}},
|
||||
Yaml::MappingValue{{"index", "2"},
|
||||
{"kind", "EndOfFile"},
|
||||
{"line", "1"},
|
||||
{"column", "12"},
|
||||
{"indent", "1"},
|
||||
{"spelling", ""}}}));
|
||||
|
||||
// Check that the subcommand dispatch works.
|
||||
EXPECT_TRUE(driver.RunFullCommand({"dump", "tokens", test_file_path}));
|
||||
|
||||
Reference in New Issue
Block a user