Syntax highlight keywords. I assume someone else will pick less appaling colors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49780 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2008-04-16 06:35:07 +00:00
Родитель c54d50a418
Коммит c4586c234e
1 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -186,6 +186,7 @@ void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID) {
" .code { font-family: \"Andale Mono\", monospace; font-size:10pt }\n"
" .code { line-height: 1.2em }\n"
" .comment { color: #A0A0A0 }\n"
" .keyword { color: #FF00FF }\n"
" .macro { color: #FF0000; background-color:#FFC0C0 }\n"
" .num { width:2.5em; padding-right:2ex; background-color:#eeeeee }\n"
" .num { text-align:right; font-size: smaller }\n"
@ -250,9 +251,15 @@ void html::SyntaxHighlight(Rewriter &R, unsigned FileID, Preprocessor &PP) {
unsigned TokOffs = LLocInfo.second;
unsigned TokLen = Tok.getLength();
switch (Tok.getKind()) {
default: break;
// FIXME: Add keywords here.
default:
// If this is a pp-identifier, but not a real identifier it must be a
// keyword.
if (Tok.getIdentifierInfo() && Tok.isNot(tok::identifier)) {
RB.InsertTextAfter(TokOffs, "<span class='keyword'>",
strlen("<span class='keyword'>"));
RB.InsertTextBefore(TokOffs+TokLen, "</span>", strlen("</span>"));
}
break;
case tok::comment:
RB.InsertTextAfter(TokOffs, "<span class='comment'>",
strlen("<span class='comment'>"));