1 //===--- TokenKinds.cpp - Token Kinds Support -----------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the TokenKind enum and support functions.
11 //===----------------------------------------------------------------------===//
13 #include "clang/Basic/TokenKinds.h"
14 #include "llvm/Support/ErrorHandling.h"
15 using namespace clang
;
17 static const char * const TokNames
[] = {
19 #define KEYWORD(X,Y) #X,
20 #include "clang/Basic/TokenKinds.def"
24 const char *tok::getTokenName(TokenKind Kind
) {
25 if (Kind
< tok::NUM_TOKENS
)
26 return TokNames
[Kind
];
27 llvm_unreachable("unknown TokenKind");
31 const char *tok::getPunctuatorSpelling(TokenKind Kind
) {
33 #define PUNCTUATOR(X,Y) case X: return Y;
34 #include "clang/Basic/TokenKinds.def"
40 const char *tok::getKeywordSpelling(TokenKind Kind
) {
42 #define KEYWORD(X,Y) case kw_ ## X: return #X;
43 #include "clang/Basic/TokenKinds.def"
49 const char *tok::getPPKeywordSpelling(tok::PPKeywordKind Kind
) {
51 #define PPKEYWORD(x) case tok::pp_##x: return #x;
52 #include "clang/Basic/TokenKinds.def"
58 bool tok::isAnnotation(TokenKind Kind
) {
60 #define ANNOTATION(X) case annot_ ## X: return true;
61 #include "clang/Basic/TokenKinds.def"
68 bool tok::isPragmaAnnotation(TokenKind Kind
) {
70 #define PRAGMA_ANNOTATION(X) case annot_ ## X: return true;
71 #include "clang/Basic/TokenKinds.def"