PTHLexer.h revision 17ff58a63197b398ae52697b088dc0fb8b255519
1//===--- PTHLexer.h - Lexer based on Pre-tokenized input --------*- 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 PTHLexer interface. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_PTHLexer_H 15#define LLVM_CLANG_PTHLexer_H 16 17#include "clang/Lex/PreprocessorLexer.h" 18 19namespace clang { 20 21class PTHLexer : public PreprocessorLexer { 22 /// FileLoc - Location for the start of the file. 23 /// 24 SourceLocation FileLoc; 25 26 /// Tokens - This is the pointer to an array of tokens that the macro is 27 /// defined to, with arguments expanded for function-like macros. If this is 28 /// a token stream, these are the tokens we are returning. 29 const Token *Tokens; 30 31 /// NumTokens - This is the length of the Tokens array. 32 /// 33 unsigned NumTokens; 34 35 /// CurToken - This is the next token that Lex will return. 36 /// 37 unsigned CurToken; 38 39 PTHLexer(const PTHLexer&); // DO NOT IMPLEMENT 40 void operator=(const PTHLexer&); // DO NOT IMPLEMENT 41 42public: 43 44 /// Create a PTHLexer for the specified token stream. 45 PTHLexer(Preprocessor& pp, SourceLocation fileloc, 46 const Token *TokArray, unsigned NumToks); 47 ~PTHLexer() {} 48 49 /// Lex - Return the next token. 50 void Lex(Token &Tok); 51 52 void setEOF(Token &Tok); 53 54 /// getFileLoc - Return the File Location for the file we are lexing out of. 55 /// The physical location encodes the location where the characters come from, 56 /// the virtual location encodes where we should *claim* the characters came 57 /// from. Currently this is only used by _Pragma handling. 58 SourceLocation getFileLoc() const { return FileLoc; } 59 60 /// ReadToEndOfLine - Read the rest of the current preprocessor line as an 61 /// uninterpreted string. This switches the lexer out of directive mode. 62 void DiscardToEndOfLine(); 63}; 64 65} // end namespace clang 66 67#endif 68