blob: afacdeeeed63d6e4e4d7f9dddfc43a042b62f83b [file] [log] [blame]
Ted Kremenek6a340832008-03-18 21:19:49 +00001//== HTMLRewrite.cpp - Translate source code into prettified HTML --*- 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// This file defines the HTMLRewriter clas, which is used to translate the
11// text of a source file into prettified HTML.
12//
13//===----------------------------------------------------------------------===//
14
15#include "clang/Rewrite/Rewriter.h"
16#include "clang/Rewrite/HTMLRewrite.h"
Chris Lattner3245a0a2008-04-16 06:11:58 +000017#include "clang/Lex/Preprocessor.h"
Ted Kremenek6a340832008-03-18 21:19:49 +000018#include "clang/Basic/SourceManager.h"
Chris Lattner57df3b92008-04-16 04:11:35 +000019#include "llvm/ADT/SmallString.h"
Ted Kremenek6a340832008-03-18 21:19:49 +000020#include "llvm/Support/MemoryBuffer.h"
21#include <sstream>
Ted Kremenek6a340832008-03-18 21:19:49 +000022using namespace clang;
23
Chris Lattner9402b572008-04-16 23:06:45 +000024
Chris Lattner5ef3e2c2008-04-16 22:45:51 +000025/// HighlightRange - Highlight a range in the source code with the specified
26/// start/end tags. B/E must be in the same file. This ensures that
27/// start/end tags are placed at the start/end of each line if the range is
28/// multiline.
29void html::HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E,
30 const char *StartTag, const char *EndTag) {
31 SourceManager &SM = R.getSourceMgr();
32 B = SM.getLogicalLoc(B);
33 E = SM.getLogicalLoc(E);
34 unsigned FileID = SM.getCanonicalFileID(B);
35 assert(SM.getCanonicalFileID(E) == FileID && "B/E not in the same file!");
36
37 unsigned BOffset = SM.getFullFilePos(B);
38 unsigned EOffset = SM.getFullFilePos(E);
39
40 // Include the whole end token in the range.
41 EOffset += Lexer::MeasureTokenLength(E, R.getSourceMgr());
42
43 HighlightRange(R.getEditBuffer(FileID), BOffset, EOffset,
44 SM.getBufferData(FileID).first, StartTag, EndTag);
45}
46
47/// HighlightRange - This is the same as the above method, but takes
48/// decomposed file locations.
49void html::HighlightRange(RewriteBuffer &RB, unsigned B, unsigned E,
50 const char *BufferStart,
51 const char *StartTag, const char *EndTag) {
Chris Lattner9402b572008-04-16 23:06:45 +000052 // Insert the tag at the absolute start/end of the range.
Chris Lattner5ef3e2c2008-04-16 22:45:51 +000053 RB.InsertTextAfter(B, StartTag, strlen(StartTag));
54 RB.InsertTextBefore(E, EndTag, strlen(EndTag));
55
Chris Lattner9402b572008-04-16 23:06:45 +000056 // Scan the range to see if there is a \r or \n. If so, and if the line is
57 // not blank, insert tags on that line as well.
58 bool HadOpenTag = true;
59
60 unsigned LastNonWhiteSpace = B;
61 for (unsigned i = B; i != E; ++i) {
62 switch (BufferStart[i]) {
63 case '\r':
64 case '\n':
65 // Okay, we found a newline in the range. If we have an open tag, we need
66 // to insert a close tag at the first non-whitespace before the newline.
67 if (HadOpenTag)
68 RB.InsertTextBefore(LastNonWhiteSpace+1, EndTag, strlen(EndTag));
69
70 // Instead of inserting an open tag immediately after the newline, we
71 // wait until we see a non-whitespace character. This prevents us from
72 // inserting tags around blank lines, and also allows the open tag to
73 // be put *after* whitespace on a non-blank line.
74 HadOpenTag = false;
75 break;
76 case '\0':
77 case ' ':
78 case '\t':
79 case '\f':
80 case '\v':
81 // Ignore whitespace.
82 break;
83
84 default:
85 // If there is no tag open, do it now.
86 if (!HadOpenTag) {
87 RB.InsertTextAfter(i, StartTag, strlen(StartTag));
88 HadOpenTag = true;
89 }
90
91 // Remember this character.
92 LastNonWhiteSpace = i;
93 break;
94 }
95 }
Chris Lattner5ef3e2c2008-04-16 22:45:51 +000096}
97
Ted Kremenekfa5be362008-04-08 22:37:58 +000098void html::EscapeText(Rewriter& R, unsigned FileID,
99 bool EscapeSpaces, bool ReplaceTabs) {
Ted Kremenek6a340832008-03-18 21:19:49 +0000100
101 const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID);
102 const char* C = Buf->getBufferStart();
103 const char* FileEnd = Buf->getBufferEnd();
104
105 assert (C <= FileEnd);
106
Chris Lattner73527142008-04-16 04:33:23 +0000107 RewriteBuffer &RB = R.getEditBuffer(FileID);
108
Ted Kremenek6a340832008-03-18 21:19:49 +0000109 for (unsigned FilePos = 0; C != FileEnd ; ++C, ++FilePos) {
Ted Kremenek49cd6352008-04-03 07:12:29 +0000110
Ted Kremenek6a340832008-03-18 21:19:49 +0000111 switch (*C) {
Chris Lattner73527142008-04-16 04:33:23 +0000112 default: break;
113
114 case ' ':
115 if (EscapeSpaces)
116 RB.ReplaceText(FilePos, 1, "&nbsp;", 6);
117 break;
Ted Kremenek6a340832008-03-18 21:19:49 +0000118
Chris Lattner73527142008-04-16 04:33:23 +0000119 case '\t':
120 if (!ReplaceTabs)
Ted Kremenek49cd6352008-04-03 07:12:29 +0000121 break;
Chris Lattner73527142008-04-16 04:33:23 +0000122 if (EscapeSpaces)
Chris Lattner8aa06ac2008-04-17 21:28:41 +0000123 RB.ReplaceText(FilePos, 1, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
124 "&nbsp;&nbsp;&nbsp;", 6*8);
Chris Lattner73527142008-04-16 04:33:23 +0000125 else
Chris Lattner6f46be22008-04-17 00:40:45 +0000126 RB.ReplaceText(FilePos, 1, " ", 8);
Chris Lattner73527142008-04-16 04:33:23 +0000127 break;
128
129 case '<':
130 RB.ReplaceText(FilePos, 1, "&lt;", 4);
131 break;
132
133 case '>':
134 RB.ReplaceText(FilePos, 1, "&gt;", 4);
135 break;
136
137 case '&':
138 RB.ReplaceText(FilePos, 1, "&amp;", 5);
139 break;
Ted Kremenek6a340832008-03-18 21:19:49 +0000140 }
141 }
142}
143
Ted Kremenekfa5be362008-04-08 22:37:58 +0000144std::string html::EscapeText(const std::string& s, bool EscapeSpaces,
145 bool ReplaceTabs) {
Ted Kremenek053ef592008-03-27 17:15:29 +0000146
147 unsigned len = s.size();
148 std::ostringstream os;
149
150 for (unsigned i = 0 ; i < len; ++i) {
151
152 char c = s[i];
Ted Kremenek053ef592008-03-27 17:15:29 +0000153 switch (c) {
Chris Lattner8570f0b2008-04-16 04:37:29 +0000154 default:
155 os << c; break;
156
157 case ' ':
158 if (EscapeSpaces) os << "&nbsp;";
159 else os << ' ';
160 break;
161
162 case '\t':
163 if (ReplaceTabs)
164 for (unsigned i = 0; i < 4; ++i)
165 os << "&nbsp;";
166 else
167 os << c;
168
Ted Kremenek053ef592008-03-27 17:15:29 +0000169 break;
Chris Lattner8570f0b2008-04-16 04:37:29 +0000170
171 case '<': os << "&lt;"; break;
172 case '>': os << "&gt;"; break;
173 case '&': os << "&amp;"; break;
Ted Kremenek053ef592008-03-27 17:15:29 +0000174 }
175 }
176
177 return os.str();
178}
179
Chris Lattner8570f0b2008-04-16 04:37:29 +0000180static void AddLineNumber(RewriteBuffer &RB, unsigned LineNo,
181 unsigned B, unsigned E) {
Chris Lattner57df3b92008-04-16 04:11:35 +0000182 llvm::SmallString<100> Str;
183 Str += "<tr><td class=\"num\" id=\"LN";
184 Str.append_uint(LineNo);
185 Str += "\">";
186 Str.append_uint(LineNo);
187 Str += "</td><td class=\"line\">";
188
Ted Kremenek49cd6352008-04-03 07:12:29 +0000189 if (B == E) { // Handle empty lines.
Chris Lattner57df3b92008-04-16 04:11:35 +0000190 Str += " </td></tr>";
Chris Lattner8570f0b2008-04-16 04:37:29 +0000191 RB.InsertTextBefore(B, &Str[0], Str.size());
Chris Lattner57df3b92008-04-16 04:11:35 +0000192 } else {
Chris Lattner8570f0b2008-04-16 04:37:29 +0000193 RB.InsertTextBefore(B, &Str[0], Str.size());
194 RB.InsertTextBefore(E, "</td></tr>", strlen("</td></tr>"));
Ted Kremenek49cd6352008-04-03 07:12:29 +0000195 }
Ted Kremenekb485cd12008-03-18 23:08:51 +0000196}
197
198void html::AddLineNumbers(Rewriter& R, unsigned FileID) {
199
200 const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID);
201 const char* FileBeg = Buf->getBufferStart();
202 const char* FileEnd = Buf->getBufferEnd();
203 const char* C = FileBeg;
Chris Lattner8570f0b2008-04-16 04:37:29 +0000204 RewriteBuffer &RB = R.getEditBuffer(FileID);
Ted Kremenekb485cd12008-03-18 23:08:51 +0000205
206 assert (C <= FileEnd);
207
208 unsigned LineNo = 0;
209 unsigned FilePos = 0;
210
211 while (C != FileEnd) {
212
213 ++LineNo;
214 unsigned LineStartPos = FilePos;
215 unsigned LineEndPos = FileEnd - FileBeg;
216
217 assert (FilePos <= LineEndPos);
218 assert (C < FileEnd);
219
220 // Scan until the newline (or end-of-file).
221
Ted Kremenek49cd6352008-04-03 07:12:29 +0000222 while (C != FileEnd) {
223 char c = *C;
224 ++C;
225
226 if (c == '\n') {
227 LineEndPos = FilePos++;
Ted Kremenekb485cd12008-03-18 23:08:51 +0000228 break;
229 }
Ted Kremenek49cd6352008-04-03 07:12:29 +0000230
231 ++FilePos;
232 }
Ted Kremenekb485cd12008-03-18 23:08:51 +0000233
Chris Lattner8570f0b2008-04-16 04:37:29 +0000234 AddLineNumber(RB, LineNo, LineStartPos, LineEndPos);
Ted Kremenekd6c13602008-03-19 05:07:26 +0000235 }
236
Chris Lattner8570f0b2008-04-16 04:37:29 +0000237 // Add one big table tag that surrounds all of the code.
238 RB.InsertTextBefore(0, "<table class=\"code\">\n",
239 strlen("<table class=\"code\">\n"));
Ted Kremenekd6c13602008-03-19 05:07:26 +0000240
Chris Lattner8570f0b2008-04-16 04:37:29 +0000241 RB.InsertTextAfter(FileEnd - FileBeg, "</table>", strlen("</table>"));
Ted Kremenekb485cd12008-03-18 23:08:51 +0000242}
Ted Kremenekad0a2032008-03-19 06:14:37 +0000243
244void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID) {
245
246 const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID);
247 const char* FileStart = Buf->getBufferStart();
248 const char* FileEnd = Buf->getBufferEnd();
249
250 SourceLocation StartLoc = SourceLocation::getFileLoc(FileID, 0);
251 SourceLocation EndLoc = SourceLocation::getFileLoc(FileID, FileEnd-FileStart);
252
253 // Generate header
Ted Kremenek70bcba62008-04-09 15:40:40 +0000254 R.InsertCStrBefore(StartLoc,
Ted Kremenek07339a62008-04-17 19:57:27 +0000255 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
256 "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
257 "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n"
Ted Kremenek70bcba62008-04-09 15:40:40 +0000258 "<style type=\"text/css\">\n"
259 " body { color:#000000; background-color:#ffffff }\n"
260 " body { font-family:Helvetica, sans-serif; font-size:10pt }\n"
Ted Kremenek4b0f8132008-04-15 21:25:08 +0000261 " h1 { font-size:14pt }\n"
Ted Kremenek70bcba62008-04-09 15:40:40 +0000262 " .code { border-spacing:0px; width:100%; }\n"
263 " .code { font-family: \"Andale Mono\", monospace; font-size:10pt }\n"
264 " .code { line-height: 1.2em }\n"
Chris Lattner5ef3e2c2008-04-16 22:45:51 +0000265 " .comment { color: #A0A0A0; font-style: oblique }\n"
Chris Lattnerc4586c22008-04-16 06:35:07 +0000266 " .keyword { color: #FF00FF }\n"
Chris Lattner5deb96d2008-04-16 23:21:17 +0000267 " .directive { color: #00A000 }\n"
Chris Lattner6f46be22008-04-17 00:40:45 +0000268 // Macro expansions.
Ted Kremenek07339a62008-04-17 19:57:27 +0000269 " .expansion { display: none; }\n"
270 " .macro:hover .expansion { display: block; border: 2px solid #FF0000; "
271 "padding: 2px; background-color:#FFF0F0;"
Chris Lattner6f46be22008-04-17 00:40:45 +0000272 " -webkit-border-radius:5px; -webkit-box-shadow:1px 1px 7px #000; "
Chris Lattner8aa06ac2008-04-17 21:28:41 +0000273 "position: absolute; top: -1em; left:10em; z-index: 1 } \n"
Chris Lattner6f46be22008-04-17 00:40:45 +0000274 " .macro { color: #FF0000; background-color:#FFC0C0;"
275 // Macros are position: relative to provide base for expansions.
276 " position: relative }\n"
Ted Kremenek70bcba62008-04-09 15:40:40 +0000277 " .num { width:2.5em; padding-right:2ex; background-color:#eeeeee }\n"
278 " .num { text-align:right; font-size: smaller }\n"
279 " .num { color:#444444 }\n"
280 " .line { padding-left: 1ex; border-left: 3px solid #ccc }\n"
281 " .line { white-space: pre }\n"
282 " .msg { background-color:#fff8b4; color:#000000 }\n"
283 " .msg { -webkit-box-shadow:1px 1px 7px #000 }\n"
284 " .msg { -webkit-border-radius:5px }\n"
285 " .msg { font-family:Helvetica, sans-serif; font-size: smaller }\n"
286 " .msg { font-weight: bold }\n"
287 " .msg { float:left }\n"
288 " .msg { padding:0.5em 1ex 0.5em 1ex }\n"
289 " .msg { margin-top:10px; margin-bottom:10px }\n"
290 " .mrange { background-color:#dfddf3 }\n"
291 " .mrange { border-bottom:1px solid #6F9DBE }\n"
292 " .PathIndex { font-weight: bold }\n"
Ted Kremenek4b0f8132008-04-15 21:25:08 +0000293 " table.simpletable {\n"
294 " padding: 5px;\n"
295 " font-size:12pt;\n"
296 " margin:20px;\n"
297 " border-collapse: collapse; border-spacing: 0px;\n"
298 " }\n"
299 " td.rowname {\n"
300 " text-align:right; font-weight:bold; color:#444444;\n"
301 " padding-right:2ex; }\n"
Ted Kremenek70bcba62008-04-09 15:40:40 +0000302 "</style>\n</head>\n<body>");
303
Ted Kremenekad0a2032008-03-19 06:14:37 +0000304 // Generate footer
305
Ted Kremenek70bcba62008-04-09 15:40:40 +0000306 R.InsertCStrAfter(EndLoc, "</body></html>\n");
Ted Kremenekad0a2032008-03-19 06:14:37 +0000307}
Chris Lattner3245a0a2008-04-16 06:11:58 +0000308
309/// SyntaxHighlight - Relex the specified FileID and annotate the HTML with
310/// information about keywords, macro expansions etc. This uses the macro
311/// table state from the end of the file, so it won't be perfectly perfect,
312/// but it will be reasonably close.
313void html::SyntaxHighlight(Rewriter &R, unsigned FileID, Preprocessor &PP) {
314 RewriteBuffer &RB = R.getEditBuffer(FileID);
315
Chris Lattnera745e8c2008-04-16 20:51:51 +0000316 const SourceManager &SourceMgr = PP.getSourceManager();
317 std::pair<const char*, const char*> File = SourceMgr.getBufferData(FileID);
318 const char *BufferStart = File.first;
319
320 Lexer L(SourceLocation::getFileLoc(FileID, 0), PP.getLangOptions(),
321 File.first, File.second);
322
Chris Lattner3245a0a2008-04-16 06:11:58 +0000323 // Inform the preprocessor that we want to retain comments as tokens, so we
324 // can highlight them.
Chris Lattner678c6352008-04-16 20:54:51 +0000325 L.SetCommentRetentionState(true);
Chris Lattner3245a0a2008-04-16 06:11:58 +0000326
Chris Lattnerc54d50a2008-04-16 06:32:08 +0000327 // Lex all the tokens in raw mode, to avoid entering #includes or expanding
328 // macros.
Chris Lattner3245a0a2008-04-16 06:11:58 +0000329 Token Tok;
Chris Lattnera745e8c2008-04-16 20:51:51 +0000330 L.LexRawToken(Tok);
Chris Lattner74ea3e52008-04-16 06:53:09 +0000331
Chris Lattner74ea3e52008-04-16 06:53:09 +0000332 while (Tok.isNot(tok::eof)) {
333 // Since we are lexing unexpanded tokens, all tokens are from the main
334 // FileID.
335 unsigned TokOffs = SourceMgr.getFullFilePos(Tok.getLocation());
Chris Lattner3245a0a2008-04-16 06:11:58 +0000336 unsigned TokLen = Tok.getLength();
337 switch (Tok.getKind()) {
Chris Lattnera745e8c2008-04-16 20:51:51 +0000338 default: break;
339 case tok::identifier: {
340 // Fill in Result.IdentifierInfo, looking up the identifier in the
341 // identifier table.
342 IdentifierInfo *II = PP.LookUpIdentifierInfo(Tok, BufferStart+TokOffs);
343
344 // If this is a pp-identifier, for a keyword, highlight it as such.
Chris Lattner5ef3e2c2008-04-16 22:45:51 +0000345 if (II->getTokenID() != tok::identifier)
346 HighlightRange(RB, TokOffs, TokOffs+TokLen, BufferStart,
347 "<span class='keyword'>", "</span>");
Chris Lattnerc4586c22008-04-16 06:35:07 +0000348 break;
Chris Lattnera745e8c2008-04-16 20:51:51 +0000349 }
Chris Lattner3245a0a2008-04-16 06:11:58 +0000350 case tok::comment:
Chris Lattner5ef3e2c2008-04-16 22:45:51 +0000351 HighlightRange(RB, TokOffs, TokOffs+TokLen, BufferStart,
352 "<span class='comment'>", "</span>");
Chris Lattner3245a0a2008-04-16 06:11:58 +0000353 break;
Chris Lattner5deb96d2008-04-16 23:21:17 +0000354 case tok::hash: {
Chris Lattner74ea3e52008-04-16 06:53:09 +0000355 // If this is a preprocessor directive, all tokens to end of line are too.
Chris Lattner5deb96d2008-04-16 23:21:17 +0000356 if (!Tok.isAtStartOfLine())
357 break;
358
359 // Eat all of the tokens until we get to the next one at the start of
360 // line.
361 unsigned TokEnd = TokOffs+TokLen;
362 L.LexRawToken(Tok);
363 while (!Tok.isAtStartOfLine() && Tok.isNot(tok::eof)) {
364 TokEnd = SourceMgr.getFullFilePos(Tok.getLocation())+Tok.getLength();
365 L.LexRawToken(Tok);
Chris Lattner74ea3e52008-04-16 06:53:09 +0000366 }
Chris Lattner5deb96d2008-04-16 23:21:17 +0000367
368 // Find end of line. This is a hack.
369 HighlightRange(RB, TokOffs, TokEnd, BufferStart,
370 "<span class='directive'>", "</span>");
371
372 // Don't skip the next token.
373 continue;
374 }
Chris Lattner3245a0a2008-04-16 06:11:58 +0000375 }
376
Chris Lattnera745e8c2008-04-16 20:51:51 +0000377 L.LexRawToken(Tok);
Chris Lattner74ea3e52008-04-16 06:53:09 +0000378 }
Chris Lattner3245a0a2008-04-16 06:11:58 +0000379}
Chris Lattnerc54d50a2008-04-16 06:32:08 +0000380
381/// HighlightMacros - This uses the macro table state from the end of the
382/// file, to reexpand macros and insert (into the HTML) information about the
383/// macro expansions. This won't be perfectly perfect, but it will be
384/// reasonably close.
385void html::HighlightMacros(Rewriter &R, unsigned FileID, Preprocessor &PP) {
386 RewriteBuffer &RB = R.getEditBuffer(FileID);
387
388 // Inform the preprocessor that we don't want comments.
389 PP.SetCommentRetentionState(false, false);
390
391 // Start parsing the specified input file.
392 PP.EnterMainSourceFile();
393
394 // Lex all the tokens.
395 const SourceManager &SourceMgr = PP.getSourceManager();
396 Token Tok;
397 PP.Lex(Tok);
398 while (Tok.isNot(tok::eof)) {
399 // Ignore non-macro tokens.
400 if (!Tok.getLocation().isMacroID()) {
401 PP.Lex(Tok);
402 continue;
403 }
404
405 // Ignore tokens whose logical location was not the main file.
406 SourceLocation LLoc = SourceMgr.getLogicalLoc(Tok.getLocation());
407 std::pair<unsigned, unsigned> LLocInfo =
408 SourceMgr.getDecomposedFileLoc(LLoc);
409
410 if (LLocInfo.first != FileID) {
411 PP.Lex(Tok);
412 continue;
413 }
414
415 // Okay, we have the first token of a macro expansion: highlight the
416 // instantiation.
417
418 // Get the size of current macro call itself.
419 // FIXME: This should highlight the args of a function-like
420 // macro, using a heuristic.
421 unsigned TokLen = Lexer::MeasureTokenLength(LLoc, SourceMgr);
422
423 unsigned TokOffs = LLocInfo.second;
Chris Lattner6f46be22008-04-17 00:40:45 +0000424 // Highlight the macro invocation itself.
Chris Lattnerc54d50a2008-04-16 06:32:08 +0000425 RB.InsertTextAfter(TokOffs, "<span class='macro'>",
426 strlen("<span class='macro'>"));
427 RB.InsertTextBefore(TokOffs+TokLen, "</span>", strlen("</span>"));
428
Chris Lattner6f46be22008-04-17 00:40:45 +0000429 std::string Expansion = PP.getSpelling(Tok);
430 unsigned LineLen = Expansion.size();
431
Chris Lattnerc54d50a2008-04-16 06:32:08 +0000432 // Okay, eat this token, getting the next one.
433 PP.Lex(Tok);
434
435 // Skip all the rest of the tokens that are part of this macro
436 // instantiation. It would be really nice to pop up a window with all the
437 // spelling of the tokens or something.
438 while (!Tok.is(tok::eof) &&
Chris Lattner6f46be22008-04-17 00:40:45 +0000439 SourceMgr.getLogicalLoc(Tok.getLocation()) == LLoc) {
440 // Insert a newline if the macro expansion is getting large.
441 if (LineLen > 60) {
442 Expansion += "<br>";
443 LineLen = 0;
444 }
445
446 LineLen -= Expansion.size();
447 Expansion += ' ' + PP.getSpelling(Tok);
448 LineLen += Expansion.size();
Chris Lattnerc54d50a2008-04-16 06:32:08 +0000449 PP.Lex(Tok);
Chris Lattner6f46be22008-04-17 00:40:45 +0000450 }
451
452 // Insert the information about the expansion inside the macro span.
453 Expansion = "<span class='expansion'>" + Expansion + "</span>";
454 RB.InsertTextBefore(TokOffs+TokLen, Expansion.c_str(), Expansion.size());
Chris Lattnerc54d50a2008-04-16 06:32:08 +0000455 }
456}
457
458