diff options
author | Chris Lattner <sabre@nondot.org> | 2008-10-12 04:05:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-10-12 04:05:48 +0000 |
commit | 4d96344c196f01a8a48db83c8f3c0f7700a7250f (patch) | |
tree | 4f96812b667849bef915501a85b51458762b2c42 /clang/Driver/RewriteTest.cpp | |
parent | 36b48de43c1e4e31e5d91cc76e822ac7bcab2d0b (diff) | |
download | bcm5719-llvm-4d96344c196f01a8a48db83c8f3c0f7700a7250f.tar.gz bcm5719-llvm-4d96344c196f01a8a48db83c8f3c0f7700a7250f.zip |
Add a new mode to the lexer which enables it to return all characters,
even whitespace, as tokens from the file. This is enabled with
L->SetKeepWhitespaceMode(true) on a raw lexer. In this mode, you too
can use clang as a really complex version of 'cat' with code like this:
Lexer RawLex(SourceLocation::getFileLoc(SM.getMainFileID(), 0),
PP.getLangOptions(), File.first, File.second);
RawLex.SetKeepWhitespaceMode(true);
Token RawTok;
RawLex.LexFromRawLexer(RawTok);
while (RawTok.isNot(tok::eof)) {
std::cout << PP.getSpelling(RawTok);
RawLex.LexFromRawLexer(RawTok);
}
This will emit exactly the input file, with no canonicalization or other
translation. Realistic clients actually do something with the tokens of
course :)
llvm-svn: 57401
Diffstat (limited to 'clang/Driver/RewriteTest.cpp')
0 files changed, 0 insertions, 0 deletions