Newer
Older
libj / modules / x-tokenizer / include / token.hpp
Nomura Kei on 31 Dec 883 bytes 一時保存
  1. #ifndef X_TOKENIZER_TOKEN_HPP
  2. #define X_TOKENIZER_TOKEN_HPP
  3.  
  4. #include <string>
  5. #include <cinttypes>
  6.  
  7. #include <string_util.hpp>
  8. #include <token_type.hpp>
  9. #include <keyword.hpp>
  10.  
  11. namespace xtokenizer
  12. {
  13.  
  14. /**
  15. * トークン。
  16. */
  17. class Token
  18. {
  19. public:
  20. Token(int line, int column, TokenType type, const std::string &str, Keyword keyword = Keyword::K_UNKNOWN) noexcept;
  21. virtual ~Token() noexcept = default;
  22. bool operator==(const Token &token) const noexcept;
  23. int line; //!< 行番号
  24. int column; //!< カラム
  25. TokenType type; //!< トークン種別
  26. std::string str; //!< トークン文字列
  27. Keyword keyword; //!< キーワード
  28. union
  29. {
  30. uint64_t i;
  31. double f;
  32. } value;
  33. };
  34.  
  35. } // namespace xtokenizer
  36. #endif // XTOKENIZER_TOKEN_HPP