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"
47 Pipe, Caret, Amp, Exclaim,
48 Percent, LessLess, GreaterGreater
52 /// AsmLexer - Lexer class for assembly files.
57 const MemoryBuffer *CurBuf;
59 // Information about the current token.
61 asmtok::TokKind CurKind;
62 std::string CurStrVal; // This is valid for Identifier.
65 /// CurBuffer - This is the current buffer index we're lexing from as managed
66 /// by the SourceMgr object.
70 AsmLexer(SourceMgr &SrcMgr);
73 asmtok::TokKind Lex() {
74 return CurKind = LexToken();
77 asmtok::TokKind getKind() const { return CurKind; }
78 bool is(asmtok::TokKind K) const { return CurKind == K; }
79 bool isNot(asmtok::TokKind K) const { return CurKind != K; }
81 const std::string &getCurStrVal() const {
82 assert((CurKind == asmtok::Identifier || CurKind == asmtok::Register ||
83 CurKind == asmtok::String) &&
84 "This token doesn't have a string value");
87 int64_t getCurIntVal() const {
88 assert(CurKind == asmtok::IntVal && "This token isn't an integer");
94 void PrintMessage(SMLoc Loc, const std::string &Msg) const;
98 asmtok::TokKind ReturnError(const char *Loc, const std::string &Msg);
100 /// LexToken - Read the next token and return its code.
101 asmtok::TokKind LexToken();
102 asmtok::TokKind LexIdentifier();
103 asmtok::TokKind LexPercent();
104 asmtok::TokKind LexSlash();
105 asmtok::TokKind LexHash();
106 asmtok::TokKind LexDigit();
107 asmtok::TokKind LexQuote();
110 } // end namespace llvm