AsmLexer.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //===- AsmLexer.h - Lexer for Assembly Files --------------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This class declares the lexer for assembly files.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_MC_MCPARSER_ASMLEXER_H
  14. #define LLVM_MC_MCPARSER_ASMLEXER_H
  15. #include "llvm/ADT/StringRef.h"
  16. #include "llvm/MC/MCParser/MCAsmLexer.h"
  17. #include "llvm/Support/DataTypes.h"
  18. #include <string>
  19. namespace llvm {
  20. class MemoryBuffer;
  21. class MCAsmInfo;
  22. /// AsmLexer - Lexer class for assembly files.
  23. class AsmLexer : public MCAsmLexer {
  24. const MCAsmInfo &MAI;
  25. const char *CurPtr;
  26. StringRef CurBuf;
  27. bool isAtStartOfLine;
  28. void operator=(const AsmLexer&) = delete;
  29. AsmLexer(const AsmLexer&) = delete;
  30. protected:
  31. /// LexToken - Read the next token and return its code.
  32. AsmToken LexToken() override;
  33. public:
  34. AsmLexer(const MCAsmInfo &MAI);
  35. ~AsmLexer() override;
  36. void setBuffer(StringRef Buf, const char *ptr = nullptr);
  37. StringRef LexUntilEndOfStatement() override;
  38. StringRef LexUntilEndOfLine();
  39. const AsmToken peekTok(bool ShouldSkipSpace = true) override;
  40. bool isAtStartOfComment(const char *Ptr);
  41. bool isAtStatementSeparator(const char *Ptr);
  42. const MCAsmInfo &getMAI() const { return MAI; }
  43. private:
  44. int getNextChar();
  45. AsmToken ReturnError(const char *Loc, const std::string &Msg);
  46. AsmToken LexIdentifier();
  47. AsmToken LexSlash();
  48. AsmToken LexLineComment();
  49. AsmToken LexDigit();
  50. AsmToken LexSingleQuote();
  51. AsmToken LexQuote();
  52. AsmToken LexFloatLiteral();
  53. AsmToken LexHexFloatLiteral(bool NoIntDigits);
  54. };
  55. } // end namespace llvm
  56. #endif