15 #ifndef LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
16 #define LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
21 #include "llvm/Support/Regex.h"
28 struct UnwrappedLineNode;
73 class FormatTokenSource;
87 void parseLevel(
bool HasOpeningBrace);
88 void parseBlock(
bool MustBeDeclaration,
unsigned AddLevels = 1u,
89 bool MunchSemi =
true,
90 bool UnindentWhitesmithsBraces =
false);
91 void parseChildBlock();
92 void parsePPDirective();
94 void parsePPIf(
bool IfDef);
98 void parsePPUnknown();
99 void readTokenWithJavaScriptASI();
100 void parseStructuralElement();
101 bool tryToParseBracedList();
102 bool parseBracedList(
bool ContinueOnSemicolons =
false,
bool IsEnum =
false,
106 void parseIfThenElse();
107 void parseTryCatch();
108 void parseForOrWhileLoop();
110 void parseLabel(
bool LeftAlignLabel =
false);
111 void parseCaseLabel();
113 void parseNamespace();
115 void parseAccessSpecifier();
118 void parseRequires();
119 void parseRequiresExpression(
unsigned int OriginalLevel);
120 void parseConstraintExpression(
unsigned int OriginalLevel);
121 void parseJavaEnumBody();
125 void parseRecord(
bool ParseAsExpr =
false);
126 void parseObjCLightweightGenerics();
127 void parseObjCMethod();
128 void parseObjCProtocolList();
129 void parseObjCUntilAtEnd();
130 void parseObjCInterfaceOrImplementation();
131 bool parseObjCProtocol();
132 void parseJavaScriptEs6ImportExport();
133 void parseStatementMacro();
134 void parseCSharpAttribute();
138 void parseCSharpGenericTypeConstraint();
139 bool tryToParseLambda();
140 bool tryToParseLambdaIntroducer();
141 bool tryToParsePropertyAccessor();
142 void tryToParseJSFunction();
143 bool tryToParseSimpleAttribute();
147 enum class LineLevel { Remove, Keep };
149 void addUnwrappedLine(LineLevel AdjustLevel = LineLevel::Remove);
155 void nextToken(
int LevelDifference = 0);
156 void readToken(
int LevelDifference = 0);
172 void flushComments(
bool NewlineBeforeNext);
174 void calculateBraceTypes(
bool ExpectClassBody =
false);
180 void conditionalCompilationCondition(
bool Unreachable);
181 void conditionalCompilationStart(
bool Unreachable);
182 void conditionalCompilationAlternative();
183 void conditionalCompilationEnd();
190 size_t computePPHash()
const;
195 std::unique_ptr<UnwrappedLine> Line;
203 bool MustBreakBeforeNextToken;
221 std::vector<bool> DeclarationScopeStack;
226 llvm::Regex CommentPragmasRegex;
244 PPBranch(PPBranchKind
Kind,
size_t Line) :
Kind(
Kind), Line(Line) {}
271 std::stack<int> PPChainBranchIndex;
275 enum IncludeGuardState {
284 IncludeGuardState IncludeGuard;
293 unsigned FirstStartColumn;
309 MatchingOpeningBlockLineIndex(kInvalidIndex) {}