This patch adds a PUNCTUATOR macro (specialization of TOK) in TokenKinds.def and makes use of it in tok::getTokenSimpleSpelling.

llvm-svn: 90042
This commit is contained in:
Kovarththanan Rajaratnam 2009-11-28 16:09:28 +00:00
parent 32140312ca
commit 7632da4b8a
2 changed files with 59 additions and 107 deletions

View File

@ -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(wide_string_literal) // L"foo"
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 @@ ANNOTATION(template_id) // annotation for a C++ template-id that names a
#undef PPKEYWORD
#undef ALIAS
#undef KEYWORD
#undef PUNCTUATOR
#undef TOK

View File

@ -30,59 +30,8 @@ const char *tok::getTokenName(enum TokenKind Kind) {
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;
}