LLVM API Documentation
00001 //===- AsmLexer.h - Lexer for Assembly Files --------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This class declares the lexer for assembly files. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_MC_MCPARSER_ASMLEXER_H 00015 #define LLVM_MC_MCPARSER_ASMLEXER_H 00016 00017 #include "llvm/ADT/StringRef.h" 00018 #include "llvm/MC/MCParser/MCAsmLexer.h" 00019 #include "llvm/Support/DataTypes.h" 00020 #include <string> 00021 00022 namespace llvm { 00023 class MemoryBuffer; 00024 class MCAsmInfo; 00025 00026 /// AsmLexer - Lexer class for assembly files. 00027 class AsmLexer : public MCAsmLexer { 00028 const MCAsmInfo &MAI; 00029 00030 const char *CurPtr; 00031 StringRef CurBuf; 00032 bool isAtStartOfLine; 00033 00034 void operator=(const AsmLexer&) LLVM_DELETED_FUNCTION; 00035 AsmLexer(const AsmLexer&) LLVM_DELETED_FUNCTION; 00036 00037 protected: 00038 /// LexToken - Read the next token and return its code. 00039 AsmToken LexToken() override; 00040 00041 public: 00042 AsmLexer(const MCAsmInfo &MAI); 00043 ~AsmLexer(); 00044 00045 void setBuffer(StringRef Buf, const char *ptr = nullptr); 00046 00047 StringRef LexUntilEndOfStatement() override; 00048 StringRef LexUntilEndOfLine(); 00049 00050 const AsmToken peekTok(bool ShouldSkipSpace = true) override; 00051 00052 bool isAtStartOfComment(const char *Ptr); 00053 bool isAtStatementSeparator(const char *Ptr); 00054 00055 const MCAsmInfo &getMAI() const { return MAI; } 00056 00057 private: 00058 int getNextChar(); 00059 AsmToken ReturnError(const char *Loc, const std::string &Msg); 00060 00061 AsmToken LexIdentifier(); 00062 AsmToken LexSlash(); 00063 AsmToken LexLineComment(); 00064 AsmToken LexDigit(); 00065 AsmToken LexSingleQuote(); 00066 AsmToken LexQuote(); 00067 AsmToken LexFloatLiteral(); 00068 AsmToken LexHexFloatLiteral(bool NoIntDigits); 00069 }; 00070 00071 } // end namespace llvm 00072 00073 #endif