1 //===--- TokenKinds.h - Enum values for C Token Kinds -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Defines the clang::TokenKind enum and support functions.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_TOKENKINDS_H
16 #define LLVM_CLANG_TOKENKINDS_H
22 /// \brief Provides a simple uniform namespace for tokens from all C languages.
25 #include "clang/Basic/TokenKinds.def"
29 /// \brief Provides a namespace for preprocessor keywords which start with a
30 /// '#' at the beginning of the line.
32 #define PPKEYWORD(X) pp_##X,
33 #include "clang/Basic/TokenKinds.def"
37 /// \brief Provides a namespace for Objective-C keywords which start with
39 enum ObjCKeywordKind {
40 #define OBJC1_AT_KEYWORD(X) objc_##X,
41 #define OBJC2_AT_KEYWORD(X) objc_##X,
42 #include "clang/Basic/TokenKinds.def"
46 /// \brief Defines the possible values of an on-off-switch (C99 6.10.6p2).
48 OOS_ON, OOS_OFF, OOS_DEFAULT
51 /// \brief Determines the name of a token as used within the front end.
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.
55 const char *getTokenName(enum TokenKind Kind);
57 /// \brief Determines the spelling of simple punctuation tokens like
58 /// '!' or '%', and returns NULL for literal and annotation tokens.
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().
64 const char *getTokenSimpleSpelling(enum TokenKind Kind);
66 /// \brief Return true if this is a raw identifier or an identifier kind.
67 inline bool isAnyIdentifier(TokenKind K) {
68 return (K == tok::identifier) || (K == tok::raw_identifier);
71 /// \brief Return true if this is a C or C++ string-literal (or
72 /// C++11 user-defined-string-literal) token.
73 inline bool isStringLiteral(TokenKind K) {
74 return K == tok::string_literal || K == tok::wide_string_literal ||
75 K == tok::utf8_string_literal || K == tok::utf16_string_literal ||
76 K == tok::utf32_string_literal;
79 /// \brief Return true if this is a "literal" kind, like a numeric
80 /// constant, string, etc.
81 inline bool isLiteral(TokenKind K) {
82 return K == tok::numeric_constant || K == tok::char_constant ||
83 K == tok::wide_char_constant || K == tok::utf16_char_constant ||
84 K == tok::utf32_char_constant || isStringLiteral(K) ||
85 K == tok::angle_string_literal;
88 /// \brief Return true if this is any of tok::annot_* kinds.
89 inline bool isAnnotation(TokenKind K) {
90 #define ANNOTATION(NAME) \
91 if (K == tok::annot_##NAME) \
93 #include "clang/Basic/TokenKinds.def"
97 } // end namespace tok
98 } // end namespace clang