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"
41 /// AsmLexer - Lexer class for assembly files.
46 const MemoryBuffer *CurBuf;
48 // Information about the current token.
50 asmtok::TokKind CurKind;
51 std::string CurStrVal; // This is valid for Identifier.
54 /// CurBuffer - This is the current buffer index we're lexing from as managed
55 /// by the SourceMgr object.
59 AsmLexer(SourceMgr &SrcMgr);
62 asmtok::TokKind Lex() {
63 return CurKind = LexToken();
66 asmtok::TokKind getKind() const { return CurKind; }
68 const std::string &getCurStrVal() const {
69 assert(CurKind == asmtok::Identifier &&
70 "This token doesn't have a string value");
73 int64_t getCurIntVal() const {
74 assert(CurKind == asmtok::IntVal && "This token isn't an integer");
80 void PrintError(const char *Loc, const std::string &Msg) const;
81 void PrintError(SMLoc Loc, const std::string &Msg) const;
86 /// LexToken - Read the next token and return its code.
87 asmtok::TokKind LexToken();
90 } // end namespace llvm