Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.3 KiB

  1. //===-- llvm/MC/MCTargetAsmLexer.h - Target Assembly Lexer ------*- 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. #ifndef LLVM_MC_MCTARGETASMLEXER_H
  10. #define LLVM_MC_MCTARGETASMLEXER_H
  11. #include "llvm/MC/MCParser/MCAsmLexer.h"
  12. namespace llvm {
  13. class Target;
  14. /// MCTargetAsmLexer - Generic interface to target specific assembly lexers.
  15. class MCTargetAsmLexer {
  16. /// The current token
  17. AsmToken CurTok;
  18. /// The location and description of the current error
  19. SMLoc ErrLoc;
  20. std::string Err;
  21. MCTargetAsmLexer(const MCTargetAsmLexer &) LLVM_DELETED_FUNCTION;
  22. void operator=(const MCTargetAsmLexer &) LLVM_DELETED_FUNCTION;
  23. protected: // Can only create subclasses.
  24. MCTargetAsmLexer(const Target &);
  25. virtual AsmToken LexToken() = 0;
  26. void SetError(const SMLoc &errLoc, const std::string &err) {
  27. ErrLoc = errLoc;
  28. Err = err;
  29. }
  30. /// TheTarget - The Target that this machine was created for.
  31. const Target &TheTarget;
  32. MCAsmLexer *Lexer;
  33. public:
  34. virtual ~MCTargetAsmLexer();
  35. const Target &getTarget() const { return TheTarget; }
  36. /// InstallLexer - Set the lexer to get tokens from lower-level lexer \p L.
  37. void InstallLexer(MCAsmLexer &L) {
  38. Lexer = &L;
  39. }
  40. MCAsmLexer *getLexer() {
  41. return Lexer;
  42. }
  43. /// Lex - Consume the next token from the input stream and return it.
  44. const AsmToken &Lex() {
  45. return CurTok = LexToken();
  46. }
  47. /// getTok - Get the current (last) lexed token.
  48. const AsmToken &getTok() {
  49. return CurTok;
  50. }
  51. /// getErrLoc - Get the current error location
  52. const SMLoc &getErrLoc() {
  53. return ErrLoc;
  54. }
  55. /// getErr - Get the current error string
  56. const std::string &getErr() {
  57. return Err;
  58. }
  59. /// getKind - Get the kind of current token.
  60. AsmToken::TokenKind getKind() const { return CurTok.getKind(); }
  61. /// is - Check if the current token has kind \p K.
  62. bool is(AsmToken::TokenKind K) const { return CurTok.is(K); }
  63. /// isNot - Check if the current token has kind \p K.
  64. bool isNot(AsmToken::TokenKind K) const { return CurTok.isNot(K); }
  65. };
  66. } // End llvm namespace
  67. #endif