TokenKinds.h revision af50aab0c317462129d73ae8000c6394c718598d
1//===--- TokenKinds.h - Enum values for C Token Kinds -----------*- C++ -*-===//
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/// \file
11/// \brief Defines the clang::TokenKind enum and support functions.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_TOKENKINDS_H
16#define LLVM_CLANG_TOKENKINDS_H
17
18namespace clang {
19
20namespace tok {
21
22/// \brief Provides a simple uniform namespace for tokens from all C languages.
23enum TokenKind {
24#define TOK(X) X,
25#include "clang/Basic/TokenKinds.def"
26  NUM_TOKENS
27};
28
29/// \brief Provides a namespace for preprocessor keywords which start with a
30/// '#' at the beginning of the line.
31enum PPKeywordKind {
32#define PPKEYWORD(X) pp_##X,
33#include "clang/Basic/TokenKinds.def"
34  NUM_PP_KEYWORDS
35};
36
37/// \brief Provides a namespace for Objective-C keywords which start with
38/// an '@'.
39enum ObjCKeywordKind {
40#define OBJC1_AT_KEYWORD(X) objc_##X,
41#define OBJC2_AT_KEYWORD(X) objc_##X,
42#include "clang/Basic/TokenKinds.def"
43  NUM_OBJC_KEYWORDS
44};
45
46/// \brief Defines the possible values of an on-off-switch (C99 6.10.6p2).
47enum OnOffSwitch {
48  OOS_ON, OOS_OFF, OOS_DEFAULT
49};
50
51/// \brief Determines the name of a token as used within the front end.
52///
53/// The name of a token will be an internal name (such as "l_square")
54/// and should not be used as part of diagnostic messages.
55const char *getTokenName(enum TokenKind Kind);
56
57/// \brief Determines the spelling of simple punctuation tokens like
58/// '!' or '%', and returns NULL for literal and annotation tokens.
59///
60/// This routine only retrieves the "simple" spelling of the token,
61/// and will not produce any alternative spellings (e.g., a
62/// digraph). For the actual spelling of a given Token, use
63/// Preprocessor::getSpelling().
64const char *getTokenSimpleSpelling(enum TokenKind Kind);
65
66}  // end namespace tok
67}  // end namespace clang
68
69#endif
70