clang API Documentation

TokenKinds.cpp
Go to the documentation of this file.
00001 //===--- TokenKinds.cpp - Token Kinds Support -----------------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 //  This file implements the TokenKind enum and support functions.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "clang/Basic/TokenKinds.h"
00015 
00016 #include <cassert>
00017 using namespace clang;
00018 
00019 static const char * const TokNames[] = {
00020 #define TOK(X) #X,
00021 #define KEYWORD(X,Y) #X,
00022 #include "clang/Basic/TokenKinds.def"
00023   0
00024 };
00025 
00026 const char *tok::getTokenName(enum TokenKind Kind) {
00027   assert(Kind < tok::NUM_TOKENS);
00028   return TokNames[Kind];
00029 }
00030 
00031 const char *tok::getTokenSimpleSpelling(enum TokenKind Kind) {
00032   switch (Kind) {
00033 #define PUNCTUATOR(X,Y) case X: return Y;
00034 #include "clang/Basic/TokenKinds.def"
00035   default: break;
00036   }
00037 
00038   return 0;
00039 }