blob: 6ce076e57a6cc18acf86e2327d3f656f8fe1b772 [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +00001//===--- TokenKinds.cpp - Token Kinds Support -----------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Reid Spencer5f016e22007-07-11 17:01:13 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the TokenKind enum and support functions.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/Basic/TokenKinds.h"
15#include <cassert>
16using namespace clang;
17
18static 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
25const char *tok::getTokenName(enum TokenKind Kind) {
26 assert(Kind < tok::NUM_TOKENS);
27 return TokNames[Kind];
28}
Douglas Gregor4b2d3f72009-02-26 21:00:50 +000029
Douglas Gregorb2fb6de2009-02-27 17:53:17 +000030const char *tok::getTokenSimpleSpelling(enum TokenKind Kind) {
Douglas Gregor4b2d3f72009-02-26 21:00:50 +000031 switch (Kind) {
Kovarththanan Rajaratnam59c55e72009-11-28 16:09:28 +000032#define PUNCTUATOR(X,Y) case X: return Y;
33#include "clang/Basic/TokenKinds.def"
Douglas Gregor4b2d3f72009-02-26 21:00:50 +000034 default: break;
35 }
36
37 return 0;
38}