• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--- TokenKinds.cpp - Token Kinds Support -----------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  This file implements the TokenKind enum and support functions.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/Basic/TokenKinds.h"
15 
16 #include <cassert>
17 using namespace clang;
18 
19 static const char * const TokNames[] = {
20 #define TOK(X) #X,
21 #define KEYWORD(X,Y) #X,
22 #include "clang/Basic/TokenKinds.def"
23   0
24 };
25 
getTokenName(enum TokenKind Kind)26 const char *tok::getTokenName(enum TokenKind Kind) {
27   assert(Kind < tok::NUM_TOKENS);
28   return TokNames[Kind];
29 }
30 
getTokenSimpleSpelling(enum TokenKind Kind)31 const char *tok::getTokenSimpleSpelling(enum TokenKind Kind) {
32   switch (Kind) {
33 #define PUNCTUATOR(X,Y) case X: return Y;
34 #include "clang/Basic/TokenKinds.def"
35   default: break;
36   }
37 
38   return 0;
39 }
40