[cfe-commits] r90042 - in /cfe/trunk: include/clang/Basic/TokenKinds.def lib/Basic/TokenKinds.cpp
Kovarththanan Rajaratnam
kovarththanan.rajaratnam at gmail.com
Sat Nov 28 08:09:28 PST 2009
Author: krj
Date: Sat Nov 28 10:09:28 2009
New Revision: 90042
URL: http://llvm.org/viewvc/llvm-project?rev=90042&view=rev
Log:
This patch adds a PUNCTUATOR macro (specialization of TOK) in TokenKinds.def and makes use of it in tok::getTokenSimpleSpelling.
Modified:
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/Basic/TokenKinds.cpp
Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=90042&r1=90041&r2=90042&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Sat Nov 28 10:09:28 2009
@@ -17,6 +17,9 @@
#ifndef TOK
#define TOK(X)
#endif
+#ifndef PUNCTUATOR
+#define PUNCTUATOR(X,Y) TOK(X)
+#endif
#ifndef KEYWORD
#define KEYWORD(X,Y) TOK(kw_ ## X)
#endif
@@ -113,64 +116,63 @@
TOK(angle_string_literal)// <foo>
// C99 6.4.6: Punctuators.
-TOK(l_square) // [
-TOK(r_square) // ]
-TOK(l_paren) // (
-TOK(r_paren) // )
-TOK(l_brace) // {
-TOK(r_brace) // }
-TOK(period) // .
-TOK(ellipsis) // ...
-TOK(amp) // &
-TOK(ampamp) // &&
-TOK(ampequal) // &=
-TOK(star) // *
-TOK(starequal) // *=
-TOK(plus) // +
-TOK(plusplus) // ++
-TOK(plusequal) // +=
-TOK(minus) // -
-TOK(arrow) // ->
-TOK(minusminus) // --
-TOK(minusequal) // -=
-TOK(tilde) // ~
-TOK(exclaim) // !
-TOK(exclaimequal) // !=
-TOK(slash) // /
-TOK(slashequal) // /=
-TOK(percent) // %
-TOK(percentequal) // %=
-TOK(less) // <
-TOK(lessless) // <<
-TOK(lessequal) // <=
-TOK(lesslessequal) // <<=
-TOK(greater) // >
-TOK(greatergreater) // >>
-TOK(greaterequal) // >=
-TOK(greatergreaterequal) // >>=
-TOK(caret) // ^
-TOK(caretequal) // ^=
-TOK(pipe) // |
-TOK(pipepipe) // ||
-TOK(pipeequal) // |=
-TOK(question) // ?
-TOK(colon) // :
-TOK(semi) // ;
-TOK(equal) // =
-TOK(equalequal) // ==
-TOK(comma) // ,
-TOK(hash) // #
-TOK(hashhash) // ##
-TOK(hashat) // #@
+PUNCTUATOR(l_square, "[")
+PUNCTUATOR(r_square, "]")
+PUNCTUATOR(l_paren, "(")
+PUNCTUATOR(r_paren, ")")
+PUNCTUATOR(l_brace, "{")
+PUNCTUATOR(r_brace, "}")
+PUNCTUATOR(period, ".")
+PUNCTUATOR(ellipsis, "...")
+PUNCTUATOR(amp, "&")
+PUNCTUATOR(ampamp, "&&")
+PUNCTUATOR(ampequal, "&=")
+PUNCTUATOR(star, "*")
+PUNCTUATOR(starequal, "*=")
+PUNCTUATOR(plus, "+")
+PUNCTUATOR(plusplus, "++")
+PUNCTUATOR(plusequal, "+=")
+PUNCTUATOR(minus, "-")
+PUNCTUATOR(arrow, "->")
+PUNCTUATOR(minusminus, "--")
+PUNCTUATOR(minusequal, "-=")
+PUNCTUATOR(tilde, "~")
+PUNCTUATOR(exclaim, "!")
+PUNCTUATOR(exclaimequal, "!=")
+PUNCTUATOR(slash, "/")
+PUNCTUATOR(slashequal, "/=")
+PUNCTUATOR(percent, "%")
+PUNCTUATOR(percentequal, "%=")
+PUNCTUATOR(less, "<")
+PUNCTUATOR(lessless, "<<")
+PUNCTUATOR(lessequal, "<=")
+PUNCTUATOR(lesslessequal, "<<=")
+PUNCTUATOR(greater, ">")
+PUNCTUATOR(greatergreater, ">>")
+PUNCTUATOR(greaterequal, ">=")
+PUNCTUATOR(greatergreaterequal, ">>=")
+PUNCTUATOR(caret, "^")
+PUNCTUATOR(caretequal, "^=")
+PUNCTUATOR(pipe, "|")
+PUNCTUATOR(pipepipe, "||")
+PUNCTUATOR(pipeequal, "|=")
+PUNCTUATOR(question, "?")
+PUNCTUATOR(colon, ":")
+PUNCTUATOR(semi, ";")
+PUNCTUATOR(equal, "=")
+PUNCTUATOR(equalequal, "==")
+PUNCTUATOR(comma, ",")
+PUNCTUATOR(hash, "#")
+PUNCTUATOR(hashhash, "##")
+PUNCTUATOR(hashat, "#@")
// C++ Support
-TOK(periodstar) // .*
-TOK(arrowstar) // ->*
-TOK(coloncolon) // ::
+PUNCTUATOR(periodstar, ".*")
+PUNCTUATOR(arrowstar, "->*")
+PUNCTUATOR(coloncolon, "::")
// Objective C support.
-TOK(at) // @
-
+PUNCTUATOR(at, "@")
// C99 6.4.1: Keywords. These turn into kw_* tokens.
// Flags allowed:
@@ -415,4 +417,5 @@
#undef PPKEYWORD
#undef ALIAS
#undef KEYWORD
+#undef PUNCTUATOR
#undef TOK
Modified: cfe/trunk/lib/Basic/TokenKinds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TokenKinds.cpp?rev=90042&r1=90041&r2=90042&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TokenKinds.cpp (original)
+++ cfe/trunk/lib/Basic/TokenKinds.cpp Sat Nov 28 10:09:28 2009
@@ -30,59 +30,8 @@
const char *tok::getTokenSimpleSpelling(enum TokenKind Kind) {
switch (Kind) {
- case tok::l_square: return "[";
- case tok::r_square: return "]";
- case tok::l_paren: return "(";
- case tok::r_paren: return ")";
- case tok::l_brace: return "{";
- case tok::r_brace: return "}";
- case tok::period: return ".";
- case tok::ellipsis: return "...";
- case tok::amp: return "&";
- case tok::ampamp: return "&&";
- case tok::ampequal: return "&=";
- case tok::star: return "*";
- case tok::starequal: return "*=";
- case tok::plus: return "+";
- case tok::plusplus: return "++";
- case tok::plusequal: return "+=";
- case tok::minus: return "-";
- case tok::arrow: return "->";
- case tok::minusminus: return "--";
- case tok::minusequal: return "-=";
- case tok::tilde: return "~";
- case tok::exclaim: return "!";
- case tok::exclaimequal: return "!=";
- case tok::slash: return "/";
- case tok::slashequal: return "/=";
- case tok::percent: return "%";
- case tok::percentequal: return "%=";
- case tok::less: return "<";
- case tok::lessless: return "<<";
- case tok::lessequal: return "<=";
- case tok::lesslessequal: return "<<=";
- case tok::greater: return ">";
- case tok::greatergreater: return ">>";
- case tok::greaterequal: return ">=";
- case tok::greatergreaterequal: return ">>=";
- case tok::caret: return "^";
- case tok::caretequal: return "^=";
- case tok::pipe: return "|";
- case tok::pipepipe: return "||";
- case tok::pipeequal: return "|=";
- case tok::question: return "?";
- case tok::colon: return ":";
- case tok::semi: return ";";
- case tok::equal: return "=";
- case tok::equalequal: return "==";
- case tok::comma: return ",";
- case tok::hash: return "#";
- case tok::hashhash: return "##";
- case tok::hashat: return "#@";
- case tok::periodstar: return ".*";
- case tok::arrowstar: return "->*";
- case tok::coloncolon: return "::";
- case tok::at: return "@";
+#define PUNCTUATOR(X,Y) case X: return Y;
+#include "clang/Basic/TokenKinds.def"
default: break;
}
More information about the cfe-commits
mailing list