Lines Matching +full:sync +full:- +full:token

1 //===--- Macros.h - Format C++ code -----------------------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 /// clang-format.
13 /// In order to not violate the requirement that clang-format can format files
14 /// in isolation, clang-format's macro support uses expansions users provide
15 /// as part of clang-format's style configuration.
21 /// As part of parsing, clang-format uses the MacroExpander to expand the
22 /// spelled token streams into expanded token streams when it encounters a
24 /// from the expanded token stream.
26 /// matches the spelled token stream into unwrapped lines that best resemble the
28 /// lines are aliasing the tokens in the expanded token stream, so that token
31 /// When formatting, clang-format annotates and formats the expanded unwrapped
32 /// lines first, determining the token types. Next, it formats the spelled
33 /// unwrapped lines, keeping the token types fixed, while allowing other
36 //===----------------------------------------------------------------------===//
68 /// - recursive expansion
69 /// - stringification
70 /// - concatenation
71 /// - variadic macros
85 /// Macro definitions must be encoded as UTF-8.
88 /// macro-definition language:
90 /// <params> ::= <id-list> | ""
91 /// <id-list> ::= <id> | <id> "," <params>
106 /// Returns whetherh there is an object-like overload, i.e. where the macro
115 /// If \p Args is not set, the object-like overload is used.
151 /// After this point, the state of the spelled/expanded stream is "in sync"
155 /// Given a mapping from the macro name identifier token in the macro call
157 /// CLASSA -> CLASSA({public: void x();})
160 /// (each '->' specifies a call to \c addLine ):
161 /// -> class A {
162 /// -> public:
163 /// -> void x();
164 /// -> };
169 /// -> CLASSA({
170 /// -> public:
171 /// -> void x();
172 /// -> })
176 /// \p Level, using the map from name identifier token to the corresponding
194 /// the spelled token stream, the calling code may also continue to call
199 /// macro calls, formatted according to the expanded token stream received
203 /// that for multiple top-level lines, each subsequent line will be the
204 /// child of the last token in its predecessor. This representation is chosen
208 /// If a token in a macro argument is a child of a token in the expansion,
209 /// the parent will be the corresponding token in the macro call.
219 /// and "int y;" will be a child of the "," token:
221 /// \- int x;
223 /// \- int y;
228 void add(FormatToken *Token, FormatToken *ExpandedParent, bool First,
232 void reconstruct(FormatToken *Token);
233 void startReconstruction(FormatToken *Token);
234 bool reconstructActiveCallUntil(FormatToken *Token);
235 void endReconstruction(FormatToken *Token);
241 void appendToken(FormatToken *Token, ReconstructedLine *L = nullptr);
277 // contains a single null token that has the reconstructed incoming
280 // is a child of the last token of the previous line. This is necessary
281 // in order to format the overall expression as a single logical line -
282 // if we created separate lines, we'd format them with their own top-level
287 // token is the parent token for that line.
290 // Maps from the expanded token to the token that takes its place in the
291 // reconstructed token stream in terms of parent-child relationships.
298 // |- f();
299 // \- g();
304 // \- f()
305 // \- g()
307 // of the comma token in the macro call.
309 // { -> (
311 // ( -> ,
319 // The identifier token of the macro call.
323 // The end of the reconstructed token sequence.
336 // The last token in the parent line or expansion, or nullptr if the macro
337 // expansion is on a top-level line.
361 // output and keep track of which parents in the expanded token stream map to
365 // |- MACRO
366 // |- (
367 // | \- <argument>
368 // |- ,
369 // | \- <argument>
370 // \- )