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; }
76 bool is(asmtok::TokKind K) const { return CurKind == K; }
77 bool isNot(asmtok::TokKind K) const { return CurKind != K; }
79 const std::string &getCurStrVal() const {
80 assert((CurKind == asmtok::Identifier || CurKind == asmtok::Register ||
81 CurKind == asmtok::String) &&
82 "This token doesn't have a string value");
85 int64_t getCurIntVal() const {
86 assert(CurKind == asmtok::IntVal && "This token isn't an integer");
92 void PrintMessage(SMLoc Loc, const std::string &Msg) const;
96 asmtok::TokKind ReturnError(const char *Loc, const std::string &Msg);
98 /// LexToken - Read the next token and return its code.
99 asmtok::TokKind LexToken();
100 asmtok::TokKind LexIdentifier();
101 asmtok::TokKind LexPercent();
102 asmtok::TokKind LexSlash();
103 asmtok::TokKind LexHash();
104 asmtok::TokKind LexDigit();
105 asmtok::TokKind LexQuote();
108 } // end namespace llvm