[cfe-commits] r38552 - in /cfe/cfe/trunk/include/clang/Lex: Lexer.h LexerToken.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:22:32 PDT 2007
Author: sabre
Date: Wed Jul 11 11:22:31 2007
New Revision: 38552
URL: http://llvm.org/viewvc/llvm-project?rev=38552&view=rev
Log:
Move the LexerToken definition out to LexerToken.h
Added:
cfe/cfe/trunk/include/clang/Lex/LexerToken.h (with props)
Modified:
cfe/cfe/trunk/include/clang/Lex/Lexer.h
Modified: cfe/cfe/trunk/include/clang/Lex/Lexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Lex/Lexer.h?rev=38552&r1=38551&r2=38552&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/cfe/trunk/include/clang/Lex/Lexer.h Wed Jul 11 11:22:31 2007
@@ -7,26 +7,22 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines the Lexer and LexerToken interfaces.
+// This file defines the Lexer interface.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_LEXER_H
#define LLVM_CLANG_LEXER_H
-#include "clang/Basic/TokenKinds.h"
-#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/LexerToken.h"
#include <string>
#include <vector>
namespace llvm {
namespace clang {
class Diagnostic;
-class Lexer;
class Preprocessor;
class SourceBuffer;
-class SourceLocation;
-class IdentifierTokenInfo;
struct LangOptions {
unsigned Trigraphs : 1; // Trigraphs in source files.
@@ -49,112 +45,6 @@
};
-/// LexerToken - This structure provides full information about a lexed token.
-/// it is not intended to be space efficient, it is intended to return as much
-/// information as possible about each returned token. This is expected to be
-/// compressed into a smaller form if memory footprint is important.
-class LexerToken {
- /// The location and length of the token text itself.
- SourceLocation Loc;
- unsigned Length;
-
- /// IdentifierInfo - If this was an identifier, this points to the uniqued
- /// information about this identifier.
- IdentifierTokenInfo *IdentifierInfo;
-
- /// Kind - The actual flavor of token this is.
- ///
- tok::TokenKind Kind : 8;
-
- /// Flags - Bits we track about this token, members of the TokenFlags enum.
- unsigned Flags : 8;
-public:
-
- // Various flags set per token:
- enum TokenFlags {
- StartOfLine = 0x01, // At start of line or only after whitespace.
- LeadingSpace = 0x02, // Whitespace exists before this token.
- NeedsCleaning = 0x04 // Contained an escaped newline or trigraph.
- //#define STRINGIFY_ARG (1 << 2) /* If macro argument to be stringified.
- //#define PASTE_LEFT (1 << 3) /* If on LHS of a ## operator.
- };
-
- tok::TokenKind getKind() const { return Kind; }
- void SetKind(tok::TokenKind K) { Kind = K; }
-
- /// getLocation - Return a source location identifier for the specified
- /// offset in the current file.
- SourceLocation getSourceLocation() const { return Loc; }
- unsigned getLength() const { return Length; }
-
- void SetLocation(SourceLocation L) { Loc = L; }
- void SetLength(unsigned Len) { Length = Len; }
-
- /// StartToken - Reset all flags to cleared.
- ///
- void StartToken() {
- Flags = 0;
- IdentifierInfo = 0;
- Loc = SourceLocation();
- }
-
- IdentifierTokenInfo *getIdentifierInfo() const { return IdentifierInfo; }
- void SetIdentifierInfo(IdentifierTokenInfo *II) {
- IdentifierInfo = II;
- }
-
- /// SetFlag - Set the specified flag.
- void SetFlag(TokenFlags Flag) {
- Flags |= Flag;
- }
-
- /// ClearFlag - Unset the specified flag.
- void ClearFlag(TokenFlags Flag) {
- Flags &= ~Flag;
- }
-
- /// SetFlagValue - Set a flag to either true or false.
- void SetFlagValue(TokenFlags Flag, bool Val) {
- if (Val)
- SetFlag(Flag);
- else
- ClearFlag(Flag);
- }
-
- /// isAtStartOfLine - Return true if this token is at the start of a line.
- ///
- bool isAtStartOfLine() const { return Flags & StartOfLine; }
-
- /// hasLeadingSpace - Return true if this token has whitespace before it.
- ///
- bool hasLeadingSpace() const { return Flags & LeadingSpace; }
-
- /// needsCleaning - Return true if this token has trigraphs or escaped
- /// newlines in it.
- ///
- bool needsCleaning() const { return Flags & NeedsCleaning; }
-};
-
-/// PPConditionalInfo - Information about the conditional stack (#if directives)
-/// currently active.
-struct PPConditionalInfo {
- /// IfLoc - Location where the conditional started.
- ///
- SourceLocation IfLoc;
-
- /// WasSkipping - True if this was contained in a skipping directive, e.g.
- /// in a "#if 0" block.
- bool WasSkipping;
-
- /// FoundNonSkip - True if we have emitted tokens already, and now we're in
- /// an #else block or something. Only useful in Skipping blocks.
- bool FoundNonSkip;
-
- /// FoundElse - True if we've seen a #else in this block. If so,
- /// #elif/#else directives are not allowed.
- bool FoundElse;
-};
-
/// Lexer - This provides a simple interface that turns a text buffer into a
/// stream of tokens. This provides no support for file reading or buffering,
Added: cfe/cfe/trunk/include/clang/Lex/LexerToken.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Lex/LexerToken.h?rev=38552&view=auto
==============================================================================
--- cfe/cfe/trunk/include/clang/Lex/LexerToken.h (added)
+++ cfe/cfe/trunk/include/clang/Lex/LexerToken.h Wed Jul 11 11:22:31 2007
@@ -0,0 +1,134 @@
+//===--- LexerToken.h - Token interface -------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Chris Lattner and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the LexerToken interface.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LEXERTOKEN_H
+#define LLVM_CLANG_LEXERTOKEN_H
+
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Basic/SourceLocation.h"
+
+namespace llvm {
+namespace clang {
+
+class IdentifierTokenInfo;
+
+/// LexerToken - This structure provides full information about a lexed token.
+/// it is not intended to be space efficient, it is intended to return as much
+/// information as possible about each returned token. This is expected to be
+/// compressed into a smaller form if memory footprint is important.
+class LexerToken {
+ /// The location and length of the token text itself.
+ SourceLocation Loc;
+ unsigned Length;
+
+ /// IdentifierInfo - If this was an identifier, this points to the uniqued
+ /// information about this identifier.
+ IdentifierTokenInfo *IdentifierInfo;
+
+ /// Kind - The actual flavor of token this is.
+ ///
+ tok::TokenKind Kind : 8;
+
+ /// Flags - Bits we track about this token, members of the TokenFlags enum.
+ unsigned Flags : 8;
+public:
+
+ // Various flags set per token:
+ enum TokenFlags {
+ StartOfLine = 0x01, // At start of line or only after whitespace.
+ LeadingSpace = 0x02, // Whitespace exists before this token.
+ NeedsCleaning = 0x04 // Contained an escaped newline or trigraph.
+ //#define STRINGIFY_ARG (1 << 2) /* If macro argument to be stringified.
+ //#define PASTE_LEFT (1 << 3) /* If on LHS of a ## operator.
+ };
+
+ tok::TokenKind getKind() const { return Kind; }
+ void SetKind(tok::TokenKind K) { Kind = K; }
+
+ /// getLocation - Return a source location identifier for the specified
+ /// offset in the current file.
+ SourceLocation getSourceLocation() const { return Loc; }
+ unsigned getLength() const { return Length; }
+
+ void SetLocation(SourceLocation L) { Loc = L; }
+ void SetLength(unsigned Len) { Length = Len; }
+
+ /// StartToken - Reset all flags to cleared.
+ ///
+ void StartToken() {
+ Flags = 0;
+ IdentifierInfo = 0;
+ Loc = SourceLocation();
+ }
+
+ IdentifierTokenInfo *getIdentifierInfo() const { return IdentifierInfo; }
+ void SetIdentifierInfo(IdentifierTokenInfo *II) {
+ IdentifierInfo = II;
+ }
+
+ /// SetFlag - Set the specified flag.
+ void SetFlag(TokenFlags Flag) {
+ Flags |= Flag;
+ }
+
+ /// ClearFlag - Unset the specified flag.
+ void ClearFlag(TokenFlags Flag) {
+ Flags &= ~Flag;
+ }
+
+ /// SetFlagValue - Set a flag to either true or false.
+ void SetFlagValue(TokenFlags Flag, bool Val) {
+ if (Val)
+ SetFlag(Flag);
+ else
+ ClearFlag(Flag);
+ }
+
+ /// isAtStartOfLine - Return true if this token is at the start of a line.
+ ///
+ bool isAtStartOfLine() const { return Flags & StartOfLine; }
+
+ /// hasLeadingSpace - Return true if this token has whitespace before it.
+ ///
+ bool hasLeadingSpace() const { return Flags & LeadingSpace; }
+
+ /// needsCleaning - Return true if this token has trigraphs or escaped
+ /// newlines in it.
+ ///
+ bool needsCleaning() const { return Flags & NeedsCleaning; }
+};
+
+/// PPConditionalInfo - Information about the conditional stack (#if directives)
+/// currently active.
+struct PPConditionalInfo {
+ /// IfLoc - Location where the conditional started.
+ ///
+ SourceLocation IfLoc;
+
+ /// WasSkipping - True if this was contained in a skipping directive, e.g.
+ /// in a "#if 0" block.
+ bool WasSkipping;
+
+ /// FoundNonSkip - True if we have emitted tokens already, and now we're in
+ /// an #else block or something. Only useful in Skipping blocks.
+ bool FoundNonSkip;
+
+ /// FoundElse - True if we've seen a #else in this block. If so,
+ /// #elif/#else directives are not allowed.
+ bool FoundElse;
+};
+
+} // end namespace clang
+} // end namespace llvm
+
+#endif
\ No newline at end of file
Propchange: cfe/cfe/trunk/include/clang/Lex/LexerToken.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/cfe/trunk/include/clang/Lex/LexerToken.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
More information about the cfe-commits
mailing list