blob: 8cdc1e31950cff3642056d45b58757a3ded9f98a [file] [log] [blame]
Shih-wei Liaof8fd82b2010-02-10 11:10:31 -08001//===--- 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>
17using namespace clang;
18
19static 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
26const char *tok::getTokenName(enum TokenKind Kind) {
27 assert(Kind < tok::NUM_TOKENS);
28 return TokNames[Kind];
29}
30
31const 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}