mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:30:14 +01:00
Here I'm trying to add some simple formatting based on the token kind, aiming mainly to keep the implementation short for now. This approach won't generalize to arbitrary structures (e.g., it doesn't discern between braces for a function body and a struct literal). I think we'll probably want to build a parse tree and associate parse kinds with tokens in order to format, additionally doing something less linear. But my essential goal at present is to just get a proof-of-concept that the basics can yield something that looks okay.
17 lines
461 B
C++
17 lines
461 B
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/format/format.h"
|
|
|
|
#include "toolchain/format/formatter.h"
|
|
|
|
namespace Carbon::Format {
|
|
|
|
auto Format(const Lex::TokenizedBuffer& tokens, llvm::raw_ostream& out)
|
|
-> bool {
|
|
return Formatter(&tokens, &out).Run();
|
|
}
|
|
|
|
} // namespace Carbon::Format
|