blob: 8cdc1e31950cff3642056d45b58757a3ded9f98a [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"
Ted Kremeneka2bfb912007-10-24 19:06:02 +000015
Reid Spencer5f016e22007-07-11 17:01:13 +000016#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}
Douglas Gregor4b2d3f72009-02-26 21:00:50 +000030
Douglas Gregorb2fb6de2009-02-27 17:53:17 +000031const char *tok::getTokenSimpleSpelling(enum TokenKind Kind) {
Douglas Gregor4b2d3f72009-02-26 21:00:50 +000032 switch (Kind) {
Kovarththanan Rajaratnam59c55e72009-11-28 16:09:28 +000033#define PUNCTUATOR(X,Y) case X: return Y;
34#include "clang/Basic/TokenKinds.def"
Douglas Gregor4b2d3f72009-02-26 21:00:50 +000035 default: break;
36 }
37
38 return 0;
39}