1 //===- AsmLexer.h - Lexer for Assembly Files --------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class declares the lexer for assembly files.
12 //===----------------------------------------------------------------------===//
17 #include "llvm/Support/DataTypes.h"
50 /// AsmLexer - Lexer class for assembly files.
55 const MemoryBuffer *CurBuf;
57 // Information about the current token.
59 asmtok::TokKind CurKind;
60 std::string CurStrVal; // This is valid for Identifier.
63 /// CurBuffer - This is the current buffer index we're lexing from as managed
64 /// by the SourceMgr object.
68 AsmLexer(SourceMgr &SrcMgr);
71 asmtok::TokKind Lex() {
72 return CurKind = LexToken();
75 asmtok::TokKind getKind() const { return CurKind; }
77 const std::string &getCurStrVal() const {
78 assert((CurKind == asmtok::Identifier || CurKind == asmtok::Register ||
79 CurKind == asmtok::String) &&
80 "This token doesn't have a string value");
83 int64_t getCurIntVal() const {
84 assert(CurKind == asmtok::IntVal && "This token isn't an integer");
90 void PrintError(const char *Loc, const std::string &Msg) const;
91 void PrintError(SMLoc Loc, const std::string &Msg) const;
95 asmtok::TokKind ReturnError(const char *Loc, const std::string &Msg);
97 /// LexToken - Read the next token and return its code.
98 asmtok::TokKind LexToken();
99 asmtok::TokKind LexIdentifier();
100 asmtok::TokKind LexPercent();
101 asmtok::TokKind LexSlash();
102 asmtok::TokKind LexHash();
103 asmtok::TokKind LexDigit();
104 asmtok::TokKind LexQuote();
107 } // end namespace llvm