//===--- UnwrappedLineParser.h - Format C++ code ----------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// /// \file /// This file contains the declaration of the UnwrappedLineParser, /// which turns a stream of tokens into UnwrappedLines. /// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H #define LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H #include "Macros.h" #include <stack> namespace clang { namespace format { struct UnwrappedLineNode; /// An unwrapped line is a sequence of \c Token, that we would like to /// put on a single line if there was no column limit. /// /// This is used as a main interface between the \c UnwrappedLineParser and the /// \c UnwrappedLineFormatter. The key property is that changing the formatting /// within an unwrapped line does not affect any other unwrapped lines. struct UnwrappedLine { … }; /// Interface for users of the UnwrappedLineParser to receive the parsed lines. /// Parsing a single snippet of code can lead to multiple runs, where each /// run is a coherent view of the file. /// /// For example, different runs are generated: /// - for different combinations of #if blocks /// - when macros are involved, for the expanded code and the as-written code /// /// Some tokens will only be visible in a subset of the runs. /// For each run, \c UnwrappedLineParser will call \c consumeUnwrappedLine /// for each parsed unwrapped line, and then \c finishRun to indicate /// that the set of unwrapped lines before is one coherent view of the /// code snippet to be formatted. class UnwrappedLineConsumer { … }; class FormatTokenSource; class UnwrappedLineParser { … }; struct UnwrappedLineNode { … }; std::ostream &operator<<(std::ostream &Stream, const UnwrappedLine &Line); } // end namespace format } // end namespace clang #endif