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, EqualEqual,
47 Pipe, PipePipe, Caret,
48 Amp, AmpAmp, Exclaim, ExclaimEqual, Percent,
49 Less, LessEqual, LessLess, LessGreater,
50 Greater, GreaterEqual, GreaterGreater
54 /// AsmLexer - Lexer class for assembly files.
59 const MemoryBuffer *CurBuf;
60 // A llvm::StringSet<>, which provides uniqued and null-terminated strings.
63 // Information about the current token.
65 asmtok::TokKind CurKind;
66 const char *CurStrVal; // This is valid for Identifier.
69 /// CurBuffer - This is the current buffer index we're lexing from as managed
70 /// by the SourceMgr object.
73 void operator=(const AsmLexer&); // DO NOT IMPLEMENT
74 AsmLexer(const AsmLexer&); // DO NOT IMPLEMENT
76 AsmLexer(SourceMgr &SrcMgr);
79 asmtok::TokKind Lex() {
80 return CurKind = LexToken();
83 asmtok::TokKind getKind() const { return CurKind; }
84 bool is(asmtok::TokKind K) const { return CurKind == K; }
85 bool isNot(asmtok::TokKind K) const { return CurKind != K; }
87 const char *getCurStrVal() const {
88 assert((CurKind == asmtok::Identifier || CurKind == asmtok::Register ||
89 CurKind == asmtok::String) &&
90 "This token doesn't have a string value");
93 int64_t getCurIntVal() const {
94 assert(CurKind == asmtok::IntVal && "This token isn't an integer");
100 /// EnterIncludeFile - Enter the specified file. This returns true on failure.
101 bool EnterIncludeFile(const std::string &Filename);
103 void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
107 asmtok::TokKind ReturnError(const char *Loc, const std::string &Msg);
109 /// LexToken - Read the next token and return its code.
110 asmtok::TokKind LexToken();
111 asmtok::TokKind LexIdentifier();
112 asmtok::TokKind LexPercent();
113 asmtok::TokKind LexSlash();
114 asmtok::TokKind LexLineComment();
115 asmtok::TokKind LexDigit();
116 asmtok::TokKind LexQuote();
119 } // end namespace llvm