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 Star, Comma, Dollar, Equal,
47 Pipe, Caret, Amp, Exclaim,
48 Percent, LessLess, GreaterGreater
52 /// AsmLexer - Lexer class for assembly files.
57 const MemoryBuffer *CurBuf;
58 // A llvm::StringSet<>, which provides uniqued and null-terminated strings.
61 // Information about the current token.
63 asmtok::TokKind CurKind;
64 const char *CurStrVal; // This is valid for Identifier.
67 /// CurBuffer - This is the current buffer index we're lexing from as managed
68 /// by the SourceMgr object.
71 void operator=(const AsmLexer&); // DO NOT IMPLEMENT
72 AsmLexer(const AsmLexer&); // DO NOT IMPLEMENT
74 AsmLexer(SourceMgr &SrcMgr);
77 asmtok::TokKind Lex() {
78 return CurKind = LexToken();
81 asmtok::TokKind getKind() const { return CurKind; }
82 bool is(asmtok::TokKind K) const { return CurKind == K; }
83 bool isNot(asmtok::TokKind K) const { return CurKind != K; }
85 const char *getCurStrVal() const {
86 assert((CurKind == asmtok::Identifier || CurKind == asmtok::Register ||
87 CurKind == asmtok::String) &&
88 "This token doesn't have a string value");
91 int64_t getCurIntVal() const {
92 assert(CurKind == asmtok::IntVal && "This token isn't an integer");
98 void PrintMessage(SMLoc Loc, const std::string &Msg) const;
102 asmtok::TokKind ReturnError(const char *Loc, const std::string &Msg);
104 /// LexToken - Read the next token and return its code.
105 asmtok::TokKind LexToken();
106 asmtok::TokKind LexIdentifier();
107 asmtok::TokKind LexPercent();
108 asmtok::TokKind LexSlash();
109 asmtok::TokKind LexHash();
110 asmtok::TokKind LexDigit();
111 asmtok::TokKind LexQuote();
114 } // end namespace llvm