PTHLexer.h revision ac2dda65d2d39c0a83d95bdf6237edbf4685bc58
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 /// Tokens - This is the pointer to an array of tokens that the macro is 23 /// defined to, with arguments expanded for function-like macros. If this is 24 /// a token stream, these are the tokens we are returning. 25 const Token *Tokens; 26 27 /// LastTokenIdx - The index of the last token in Tokens. This token 28 /// will be an eof token. 29 unsigned LastToken; 30 31 /// CurToken - This is the index of the next token that Lex will return. 32 unsigned CurToken; 33 34 PTHLexer(const PTHLexer&); // DO NOT IMPLEMENT 35 void operator=(const PTHLexer&); // DO NOT IMPLEMENT 36 37public: 38 39 /// Create a PTHLexer for the specified token stream. 40 PTHLexer(Preprocessor& pp, SourceLocation fileloc, 41 const Token *TokArray, unsigned NumToks); 42 ~PTHLexer() {} 43 44 /// Lex - Return the next token. 45 void Lex(Token &Tok); 46 47 void setEOF(Token &Tok); 48 49 /// DiscardToEndOfLine - Read the rest of the current preprocessor line as an 50 /// uninterpreted string. This switches the lexer out of directive mode. 51 void DiscardToEndOfLine(); 52 53 /// isNextPPTokenLParen - Return 1 if the next unexpanded token will return a 54 /// tok::l_paren token, 0 if it is something else and 2 if there are no more 55 /// tokens controlled by this lexer. 56 unsigned isNextPPTokenLParen(); 57 58 /// IndirectLex - An indirect call to 'Lex' that can be invoked via 59 /// the PreprocessorLexer interface. 60 void IndirectLex(Token &Result) { Lex(Result); } 61}; 62 63} // end namespace clang 64 65#endif 66