mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +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:
@@ -788,10 +788,12 @@ auto TokenizedBuffer::Print(llvm::raw_ostream& output_stream) const -> void {
|
||||
widths.Widen(GetTokenPrintWidths(token));
|
||||
}
|
||||
|
||||
output_stream << "[\n";
|
||||
for (Token token : tokens()) {
|
||||
PrintToken(output_stream, token, widths);
|
||||
output_stream << "\n";
|
||||
}
|
||||
output_stream << "]\n";
|
||||
}
|
||||
|
||||
auto TokenizedBuffer::PrintToken(llvm::raw_ostream& output_stream,
|
||||
@@ -810,7 +812,7 @@ auto TokenizedBuffer::PrintToken(llvm::raw_ostream& output_stream, Token token,
|
||||
// justification manually in order to use the dynamically computed widths
|
||||
// and get the quotes included.
|
||||
output_stream << llvm::formatv(
|
||||
"token: { index: {0}, kind: {1}, line: {2}, column: {3}, indent: {4}, "
|
||||
"{ index: {0}, kind: {1}, line: {2}, column: {3}, indent: {4}, "
|
||||
"spelling: '{5}'",
|
||||
llvm::format_decimal(token_index, widths.index),
|
||||
llvm::right_justify(
|
||||
@@ -855,7 +857,7 @@ auto TokenizedBuffer::PrintToken(llvm::raw_ostream& output_stream, Token token,
|
||||
output_stream << ", recovery: true";
|
||||
}
|
||||
|
||||
output_stream << " }";
|
||||
output_stream << " },";
|
||||
}
|
||||
|
||||
auto TokenizedBuffer::GetLineInfo(Line line) -> LineInfo& {
|
||||
|
||||
Reference in New Issue
Block a user