PTHLexer.h revision 452e37837a48b2f0ced144784277fd4d28cbede9
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
14452e37837a48b2f0ced144784277fd4d28cbede9Ted Kremenek#ifndef LLVM_CLANG_PTHLEXER_H
15452e37837a48b2f0ced144784277fd4d28cbede9Ted 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  /// Tokens - This is the pointer to an array of tokens that the macro is
23274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  /// defined to, with arguments expanded for function-like macros.  If this is
24274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  /// a token stream, these are the tokens we are returning.
25274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  const Token *Tokens;
26274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek
27452e37837a48b2f0ced144784277fd4d28cbede9Ted Kremenek  /// LastTokenIdx - The index of the last token in Tokens.  This token
28452e37837a48b2f0ced144784277fd4d28cbede9Ted Kremenek  ///  will be an eof token.
29452e37837a48b2f0ced144784277fd4d28cbede9Ted Kremenek  unsigned LastToken;
30274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek
31452e37837a48b2f0ced144784277fd4d28cbede9Ted Kremenek  /// CurToken - This is the index of the next token that Lex will return.
32274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  unsigned CurToken;
33274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek
34274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  PTHLexer(const PTHLexer&);  // DO NOT IMPLEMENT
35274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  void operator=(const PTHLexer&); // DO NOT IMPLEMENT
36274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek
37274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenekpublic:
38274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek
39274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  /// Create a PTHLexer for the specified token stream.
40274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  PTHLexer(Preprocessor& pp, SourceLocation fileloc,
41274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek           const Token *TokArray, unsigned NumToks);
42274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  ~PTHLexer() {}
43274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek
44274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  /// Lex - Return the next token.
45274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  void Lex(Token &Tok);
46274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek
47274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek  void setEOF(Token &Tok);
48274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek
499f1384f7db76e24068f6c9d7d881714addb6c029Ted Kremenek  /// DiscardToEndOfLine - Read the rest of the current preprocessor line as an
5017ff58a63197b398ae52697b088dc0fb8b255519Ted Kremenek  /// uninterpreted string.  This switches the lexer out of directive mode.
5117ff58a63197b398ae52697b088dc0fb8b255519Ted Kremenek  void DiscardToEndOfLine();
522f1c0243f7fc5d12446efcb006c071854c345923Ted Kremenek
532f1c0243f7fc5d12446efcb006c071854c345923Ted Kremenek  /// isNextPPTokenLParen - Return 1 if the next unexpanded token will return a
542f1c0243f7fc5d12446efcb006c071854c345923Ted Kremenek  /// tok::l_paren token, 0 if it is something else and 2 if there are no more
552f1c0243f7fc5d12446efcb006c071854c345923Ted Kremenek  /// tokens controlled by this lexer.
562f1c0243f7fc5d12446efcb006c071854c345923Ted Kremenek  unsigned isNextPPTokenLParen();
57274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek};
58274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek
59274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek}  // end namespace clang
60274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek
61274b20863a728cc6a31ee75c670e3733600c1531Ted Kremenek#endif
62