Newer
Older
libj / modules / x-tokenizer / include / token.hpp
Nomura Kei on 31 Dec 883 bytes 一時保存
#ifndef X_TOKENIZER_TOKEN_HPP
#define X_TOKENIZER_TOKEN_HPP

#include <string>
#include <cinttypes>

#include <string_util.hpp>
#include <token_type.hpp>
#include <keyword.hpp>

namespace xtokenizer
{

    /**
     * トークン。
     */
    class Token
    {
    public:
        Token(int line, int column, TokenType type, const std::string &str, Keyword keyword = Keyword::K_UNKNOWN) noexcept;
        virtual ~Token() noexcept = default;
        bool operator==(const Token &token) const noexcept;
        int line;        //!< 行番号
        int column;      //!< カラム
        TokenType type;  //!< トークン種別
        std::string str; //!< トークン文字列
        Keyword keyword; //!< キーワード
        union
        {
            uint64_t i;
            double f;
        } value;
    };

} // namespace xtokenizer
#endif // XTOKENIZER_TOKEN_HPP