Add missing newlines at EOF (for clang++).
[oota-llvm.git] / tools / llvm-mc / AsmLexer.h
index 25311c8f9f3f51819fbe692791204d7c74ffbdec..ce292f66b127be5b2b051c2a10a743acb3499d60 100644 (file)
@@ -16,7 +16,8 @@
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/MC/MCAsmLexer.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/System/DataTypes.h"
 #include <string>
 #include <cassert>
 
@@ -24,84 +25,39 @@ namespace llvm {
 class MemoryBuffer;
 class SourceMgr;
 class SMLoc;
-
-namespace asmtok {
-  enum TokKind {
-    // Markers
-    Eof, Error,
-
-    // String values.
-    Identifier,
-    Register,
-    String,
-    
-    // Integer values.
-    IntVal,
-    
-    // No-value.
-    EndOfStatement,
-    Colon,
-    Plus, Minus, Tilde,
-    Slash,    // '/'
-    LParen, RParen,
-    Star, Comma, Dollar, Equal, EqualEqual,
-    
-    Pipe, PipePipe, Caret, 
-    Amp, AmpAmp, Exclaim, ExclaimEqual, Percent, 
-    Less, LessEqual, LessLess, LessGreater,
-    Greater, GreaterEqual, GreaterGreater
-  };
-}
+class MCAsmInfo;
 
 /// AsmLexer - Lexer class for assembly files.
 class AsmLexer : public MCAsmLexer {
   SourceMgr &SrcMgr;
+  const MCAsmInfo &MAI;
   
   const char *CurPtr;
   const MemoryBuffer *CurBuf;
   
-  // Information about the current token.
   const char *TokStart;
-  asmtok::TokKind CurKind;
-  StringRef CurStrVal;  // This is valid for Identifier.
-  int64_t CurIntVal;
-  
-  /// CurBuffer - This is the current buffer index we're lexing from as managed
-  /// by the SourceMgr object.
+
+  /// This is the current buffer index we're lexing from as managed by the
+  /// SourceMgr object.
   int CurBuffer;
   
   void operator=(const AsmLexer&); // DO NOT IMPLEMENT
   AsmLexer(const AsmLexer&);       // DO NOT IMPLEMENT
+
+protected:
+  /// LexToken - Read the next token and return its code.
+  virtual AsmToken LexToken();
+
 public:
-  AsmLexer(SourceMgr &SrcMgr);
+  AsmLexer(SourceMgr &SrcMgr, const MCAsmInfo &MAI);
   ~AsmLexer();
   
-  asmtok::TokKind Lex() {
-    return CurKind = LexToken();
-  }
-  
-  asmtok::TokKind getKind() const { return CurKind; }
-  bool is(asmtok::TokKind K) const { return CurKind == K; }
-  bool isNot(asmtok::TokKind K) const { return CurKind != K; }
-
-  /// getCurStrVal - Get the string for the current token, this includes all
-  /// characters (for example, the quotes on strings) in the token.
-  ///
-  /// The returned StringRef points into the source manager's memory buffer, and
-  /// is safe to store across calls to Lex().
-  StringRef getCurStrVal() const {
-    assert((CurKind == asmtok::Identifier || CurKind == asmtok::Register ||
-            CurKind == asmtok::String) &&
-           "This token doesn't have a string value");
-    return CurStrVal;
-  }
-  int64_t getCurIntVal() const {
-    assert(CurKind == asmtok::IntVal && "This token isn't an integer");
-    return CurIntVal;
-  }
-  
   SMLoc getLoc() const;
   
+  StringRef LexUntilEndOfStatement();
+
+  bool isAtStartOfComment(char Char);
+
   /// EnterIncludeFile - Enter the specified file. This returns true on failure.
   bool EnterIncludeFile(const std::string &Filename);
   
@@ -109,16 +65,13 @@ public:
   
 private:
   int getNextChar();
-  asmtok::TokKind ReturnError(const char *Loc, const std::string &Msg);
+  AsmToken ReturnError(const char *Loc, const std::string &Msg);
 
-  /// LexToken - Read the next token and return its code.
-  asmtok::TokKind LexToken();
-  asmtok::TokKind LexIdentifier();
-  asmtok::TokKind LexPercent();
-  asmtok::TokKind LexSlash();
-  asmtok::TokKind LexLineComment();
-  asmtok::TokKind LexDigit();
-  asmtok::TokKind LexQuote();
+  AsmToken LexIdentifier();
+  AsmToken LexSlash();
+  AsmToken LexLineComment();
+  AsmToken LexDigit();
+  AsmToken LexQuote();
 };
   
 } // end namespace llvm