X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvm-mc%2FAsmLexer.h;h=ce292f66b127be5b2b051c2a10a743acb3499d60;hb=9e6d1d1f5034347d237941f1bf08fba5c1583cd3;hp=c668e8639cdc5b81a8e6fd8e8af69ae3e51e9040;hpb=b0789ed5a45a90ee7ff398fcdc1383b49ee88918;p=oota-llvm.git diff --git a/tools/llvm-mc/AsmLexer.h b/tools/llvm-mc/AsmLexer.h index c668e8639cd..ce292f66b12 100644 --- a/tools/llvm-mc/AsmLexer.h +++ b/tools/llvm-mc/AsmLexer.h @@ -14,7 +14,10 @@ #ifndef ASMLEXER_H #define ASMLEXER_H -#include "llvm/Support/DataTypes.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/MC/MCAsmLexer.h" +#include "llvm/MC/MCAsmInfo.h" +#include "llvm/System/DataTypes.h" #include #include @@ -22,88 +25,53 @@ 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, - Slash, // '/' - LParen, RParen, - Star, Comma, Dollar - }; -} +class MCAsmInfo; /// AsmLexer - Lexer class for assembly files. -class AsmLexer { +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; - 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(); - } - - asmtok::TokKind getKind() const { return CurKind; } - bool is(asmtok::TokKind K) const { return CurKind == K; } - bool isNot(asmtok::TokKind K) const { return CurKind != K; } - - const std::string &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; - } + AsmLexer(SourceMgr &SrcMgr, const MCAsmInfo &MAI); + ~AsmLexer(); SMLoc getLoc() const; - void PrintError(const char *Loc, const std::string &Msg) const; - void PrintError(SMLoc Loc, const std::string &Msg) const; + StringRef LexUntilEndOfStatement(); + + bool isAtStartOfComment(char Char); + + /// EnterIncludeFile - Enter the specified file. This returns true on failure. + bool EnterIncludeFile(const std::string &Filename); + + void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const; 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 LexHash(); - asmtok::TokKind LexDigit(); - asmtok::TokKind LexQuote(); + AsmToken LexIdentifier(); + AsmToken LexSlash(); + AsmToken LexLineComment(); + AsmToken LexDigit(); + AsmToken LexQuote(); }; } // end namespace llvm