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"
45 /// AsmLexer - Lexer class for assembly files.
50 const MemoryBuffer *CurBuf;
52 // Information about the current token.
54 asmtok::TokKind CurKind;
55 std::string CurStrVal; // This is valid for Identifier.
58 /// CurBuffer - This is the current buffer index we're lexing from as managed
59 /// by the SourceMgr object.
63 AsmLexer(SourceMgr &SrcMgr);
66 asmtok::TokKind Lex() {
67 return CurKind = LexToken();
70 asmtok::TokKind getKind() const { return CurKind; }
72 const std::string &getCurStrVal() const {
73 assert((CurKind == asmtok::Identifier || CurKind == asmtok::Register) &&
74 "This token doesn't have a string value");
77 int64_t getCurIntVal() const {
78 assert(CurKind == asmtok::IntVal && "This token isn't an integer");
84 void PrintError(const char *Loc, const std::string &Msg) const;
85 void PrintError(SMLoc Loc, const std::string &Msg) const;
89 asmtok::TokKind ReturnError(const char *Loc, const std::string &Msg);
91 /// LexToken - Read the next token and return its code.
92 asmtok::TokKind LexToken();
93 asmtok::TokKind LexIdentifier();
94 asmtok::TokKind LexPercent();
95 asmtok::TokKind LexSlash();
96 asmtok::TokKind LexHash();
97 asmtok::TokKind LexDigit();
100 } // end namespace llvm