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 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MC_MCPARSER_ASMLEXER_H
15 #define LLVM_MC_MCPARSER_ASMLEXER_H
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/MC/MCParser/MCAsmLexer.h"
25 /// AsmLexer - Lexer class for assembly files.
26 class AsmLexer : public MCAsmLexer {
29 const char *CurPtr = nullptr;
31 bool IsAtStartOfLine = true;
32 bool IsAtStartOfStatement = true;
33 bool IsParsingMSInlineAsm = false;
34 bool IsPeeking = false;
37 /// LexToken - Read the next token and return its code.
38 AsmToken LexToken() override;
41 AsmLexer(const MCAsmInfo &MAI);
42 AsmLexer(const AsmLexer &) = delete;
43 AsmLexer &operator=(const AsmLexer &) = delete;
46 void setBuffer(StringRef Buf, const char *ptr = nullptr);
47 void setParsingMSInlineAsm(bool V) { IsParsingMSInlineAsm = V; }
49 StringRef LexUntilEndOfStatement() override;
51 size_t peekTokens(MutableArrayRef<AsmToken> Buf,
52 bool ShouldSkipSpace = true) override;
54 const MCAsmInfo &getMAI() const { return MAI; }
57 bool isAtStartOfComment(const char *Ptr);
58 bool isAtStatementSeparator(const char *Ptr);
60 AsmToken ReturnError(const char *Loc, const std::string &Msg);
62 AsmToken LexIdentifier();
64 AsmToken LexLineComment();
66 AsmToken LexSingleQuote();
68 AsmToken LexFloatLiteral();
69 AsmToken LexHexFloatLiteral(bool NoIntDigits);
71 StringRef LexUntilEndOfLine();
74 } // end namespace llvm
76 #endif // LLVM_MC_MCPARSER_ASMLEXER_H