Revert r80305, I forgot a dependent change.
[oota-llvm.git] / tools / llvm-mc / AsmLexer.h
index 08e6f9c6eeb39adba0cf9f1e6a30ad647f461bcc..905ff75ec9f86b148e24eaa297b703806c48909b 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef ASMLEXER_H
 #define ASMLEXER_H
 
+#include "llvm/ADT/StringRef.h"
+#include "llvm/MC/MCAsmLexer.h"
 #include "llvm/Support/DataTypes.h"
 #include <string>
 #include <cassert>
@@ -23,68 +25,50 @@ class MemoryBuffer;
 class SourceMgr;
 class SMLoc;
 
-namespace asmtok {
-  enum TokKind {
-    // Markers
-    Eof, Error,
-
-    Identifier,
-    IntVal,
-    
-    
-    Colon,
-    Plus,
-    Minus
-  };
-}
-
 /// AsmLexer - Lexer class for assembly files.
-class AsmLexer {
+class AsmLexer : public MCAsmLexer {
   SourceMgr &SrcMgr;
   
   const char *CurPtr;
   const MemoryBuffer *CurBuf;
   
-  // Information about the current token.
   const char *TokStart;
-  asmtok::TokKind CurKind;
-  std::string 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() {}
-  
-  asmtok::TokKind Lex() {
-    return CurKind = LexToken();
-  }
+  ~AsmLexer();
   
-  asmtok::TokKind getKind() const { return CurKind; }
+  SMLoc getLoc() const;
   
-  const std::string &getCurStrVal() const {
-    assert(CurKind == asmtok::Identifier &&
-           "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;
-  }
+  StringRef LexUntilEndOfStatement();
   
-  SMLoc getLoc() const;
+
+  /// EnterIncludeFile - Enter the specified file. This returns true on failure.
+  bool EnterIncludeFile(const std::string &Filename);
   
-  void PrintError(const char *Loc, const std::string &Msg) const;
-  void PrintError(SMLoc Loc, const std::string &Msg) const;
+  void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
   
 private:
   int getNextChar();
+  AsmToken ReturnError(const char *Loc, const std::string &Msg);
 
-  /// LexToken - Read the next token and return its code.
-  asmtok::TokKind LexToken();
+  AsmToken LexIdentifier();
+  AsmToken LexPercent();
+  AsmToken LexSlash();
+  AsmToken LexLineComment();
+  AsmToken LexDigit();
+  AsmToken LexQuote();
 };
   
 } // end namespace llvm