]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/tools/clang/lib/Basic/TokenKinds.cpp
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / llvm / tools / clang / lib / Basic / TokenKinds.cpp
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 #include <cassert>
16 using namespace clang;
17
18 static const char * const TokNames[] = {
19 #define TOK(X) #X,
20 #define KEYWORD(X,Y) #X,
21 #include "clang/Basic/TokenKinds.def"
22   0
23 };
24
25 const char *tok::getTokenName(enum TokenKind Kind) {
26   assert(Kind < tok::NUM_TOKENS);
27   return TokNames[Kind];
28 }
29
30 const char *tok::getTokenSimpleSpelling(enum TokenKind Kind) {
31   switch (Kind) {
32 #define PUNCTUATOR(X,Y) case X: return Y;
33 #include "clang/Basic/TokenKinds.def"
34   default: break;
35   }
36
37   return 0;
38 }