16 #ifndef LLVM_CLANG_LIB_FORMAT_FORMATTOKEN_H
17 #define LLVM_CLANG_LIB_FORMAT_FORMATTOKEN_H
28 #define LIST_TOKEN_TYPES \
29 TYPE(ArrayInitializerLSquare) \
30 TYPE(ArraySubscriptLSquare) \
31 TYPE(AttributeParen) \
32 TYPE(BinaryOperator) \
36 TYPE(ConditionalExpr) \
37 TYPE(ConflictAlternative) \
40 TYPE(CtorInitializerColon) \
41 TYPE(CtorInitializerComma) \
42 TYPE(DesignatedInitializerPeriod) \
45 TYPE(FunctionAnnotationRParen) \
46 TYPE(FunctionDeclarationName) \
47 TYPE(FunctionLBrace) \
48 TYPE(FunctionTypeLParen) \
49 TYPE(ImplicitStringLiteral) \
50 TYPE(InheritanceColon) \
51 TYPE(InlineASMBrace) \
52 TYPE(InlineASMColon) \
53 TYPE(JavaAnnotation) \
54 TYPE(JsComputedPropertyName) \
57 TYPE(JsTypeOperator) \
58 TYPE(JsTypeOptionalQuestion) \
61 TYPE(LeadingJavaAnnotation) \
63 TYPE(MacroBlockBegin) \
65 TYPE(ObjCBlockLBrace) \
66 TYPE(ObjCBlockLParen) \
69 TYPE(ObjCMethodExpr) \
70 TYPE(ObjCMethodSpecifier) \
72 TYPE(ObjCStringLiteral) \
73 TYPE(OverloadedOperator) \
74 TYPE(OverloadedOperatorLParen) \
75 TYPE(PointerOrReference) \
76 TYPE(PureVirtualSpecifier) \
77 TYPE(RangeBasedForLoopColon) \
81 TYPE(TemplateCloser) \
82 TYPE(TemplateOpener) \
83 TYPE(TemplateString) \
84 TYPE(TrailingAnnotation) \
85 TYPE(TrailingReturnArrow) \
86 TYPE(TrailingUnaryOperator) \
91 #define TYPE(X) TT_##X,
197 std::unique_ptr<TokenRole>
Role;
291 template <
typename A,
typename B>
bool isOneOf(A K1, B K2)
const {
292 return is(K1) ||
is(K2);
294 template <
typename A,
typename B,
typename... Ts>
298 template <
typename T>
bool isNot(T
Kind)
const {
return !
is(Kind); }
302 template <
typename A,
typename... Ts>
304 return startsSequenceInternal(K1,
Tokens...);
309 template <
typename A,
typename... Ts>
311 return endsSequenceInternal(K1,
Tokens...);
321 return isOneOf(tok::kw_public, tok::kw_protected, tok::kw_private) &&
322 (!ColonRequired || (
Next &&
Next->
is(tok::colon)));
337 return isOneOf(tok::l_paren, tok::l_brace, tok::l_square,
342 return isOneOf(tok::r_paren, tok::r_brace, tok::r_square,
348 return isOneOf(tok::arrow, tok::period, tok::arrowstar) &&
349 !
isOneOf(TT_DesignatedInitializerPeriod, TT_TrailingReturnArrow,
358 case tok::minusminus:
362 case tok::kw_alignof:
375 return is(tok::comment) &&
387 case tok::kw_alignof:
388 case tok::kw_alignas:
389 case tok::kw_decltype:
390 case tok::kw_noexcept:
391 case tok::kw_static_assert:
392 case tok::kw___attribute:
415 while (Tok && Tok->
is(tok::comment))
423 while (Tok && Tok->
is(tok::comment))
431 return is(TT_ArrayInitializerLSquare) ||
447 template <
typename A,
typename... Ts>
448 bool startsSequenceInternal(A K1, Ts...
Tokens)
const {
449 if (
is(tok::comment) &&
Next)
450 return Next->startsSequenceInternal(K1,
Tokens...);
454 template <
typename A>
455 bool startsSequenceInternal(A K1)
const {
456 if (
is(tok::comment) &&
Next)
457 return Next->startsSequenceInternal(K1);
461 template <
typename A,
typename... Ts>
462 bool endsSequenceInternal(A K1)
const {
464 return Previous->endsSequenceInternal(K1);
468 template <
typename A,
typename... Ts>
469 bool endsSequenceInternal(A K1, Ts...
Tokens)
const {
476 class ContinuationIndenter;
523 bool DryRun)
override;
526 bool DryRun)
override;
530 Commas.push_back(Token);
536 struct ColumnFormat {
552 const ColumnFormat *getColumnFormat(
unsigned RemainingCharacters)
const;
564 bool HasNestedBracedList;
SourceLocation getEnd() const
The base class of the type hierarchy.
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token...
One of these records is kept for each identifier that is lexed.
Token - This structure provides full information about a lexed token.
tok::TokenKind getKind() const
Implements an efficient mapping from strings to IdentifierInfo nodes.
PPKeywordKind
Provides a namespace for preprocessor keywords which start with a '#' at the beginning of the line...
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Defines and computes precedence levels for binary/ternary operators.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
ArrayRef< FormatToken * > Tokens
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, bool CPlusPlus11)
Return the precedence of the specified binary operator token.
A trivial tuple used to represent a source range.
IdentifierInfo * getIdentifierInfo() const
tok::PPKeywordKind getPPKeywordID() const
Return the preprocessor keyword ID for this identifier.