PTHLexer.h revision 274b20863a728cc6a31ee75c670e3733600c1531
1274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek//===--- PTHLexer.h - Lexer based on Pre-tokenized input --------*- C++ -*-===// 2274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek// 3274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek// The LLVM Compiler Infrastructure 4274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek// 5274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek// This file is distributed under the University of Illinois Open Source 6274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek// License. See LICENSE.TXT for details. 7274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek// 8274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek//===----------------------------------------------------------------------===// 9274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek// 10274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek// This file defines the PTHLexer interface. 11274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek// 12274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek//===----------------------------------------------------------------------===// 13274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 14274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek#ifndef LLVM_CLANG_PTHLexer_H 15274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek#define LLVM_CLANG_PTHLexer_H 16274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 17274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek#include "clang/Lex/PreprocessorLexer.h" 18274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 19274b20863a728cc6a31ee75c670e3733600c1531Ted Kremeneknamespace clang { 20274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 21274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenekclass PTHLexer : public PreprocessorLexer { 22274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 23274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// PP - Preprocessor. 24274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek Preprocessor& PP; 25274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 26274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// FileLoc - Location for the start of the file. 27274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// 28274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek SourceLocation FileLoc; 29274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 30274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// Tokens - This is the pointer to an array of tokens that the macro is 31274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// defined to, with arguments expanded for function-like macros. If this is 32274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// a token stream, these are the tokens we are returning. 33274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek const Token *Tokens; 34274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 35274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// NumTokens - This is the length of the Tokens array. 36274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// 37274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek unsigned NumTokens; 38274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 39274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// CurToken - This is the next token that Lex will return. 40274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// 41274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek unsigned CurToken; 42274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 43274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek PTHLexer(const PTHLexer&); // DO NOT IMPLEMENT 44274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek void operator=(const PTHLexer&); // DO NOT IMPLEMENT 45274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 46274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenekpublic: 47274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 48274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// Create a PTHLexer for the specified token stream. 49274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek PTHLexer(Preprocessor& pp, SourceLocation fileloc, 50274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek const Token *TokArray, unsigned NumToks); 51274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek ~PTHLexer() {} 52274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 53274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// Lex - Return the next token. 54274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek void Lex(Token &Tok); 55274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 56274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek void setEOF(Token &Tok); 57274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 58274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// getFileLoc - Return the File Location for the file we are lexing out of. 59274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// The physical location encodes the location where the characters come from, 60274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// the virtual location encodes where we should *claim* the characters came 61274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek /// from. Currently this is only used by _Pragma handling. 62274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek SourceLocation getFileLoc() const { return FileLoc; } 63274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek}; 64274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 65274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek} // end namespace clang 66274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek 67274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek#endif 68