#ifndef ELOHIMSCRIPT_LEXTOKEN_HPP #define ELOHIMSCRIPT_LEXTOKEN_HPP #include #include #include "LexTokenKind.hpp" namespace ElohimScript::Parser { class LexToken { friend class Lexer; std::unique_ptr _next; TextSpan _span; public: LexToken(TextSpan span) : _span(span) {} virtual ~LexToken() = default; [[nodiscard]] virtual LexTokenKind GetKind() const noexcept = 0; [[nodiscard]] const std::unique_ptr& GetNext() const noexcept { return _next; } [[nodiscard]] const TextSpan& GetSpan() const noexcept { return _span; } }; template class LexTokenImpl : public LexToken { public: LexTokenImpl(TextSpan span) : LexToken(span){}; [[nodiscard]] LexTokenKind GetKind() const noexcept override { return kind; } }; class IntegerLiteral : public LexTokenImpl { uint64_t _value; public: IntegerLiteral(TextSpan span, uint64_t value) : LexTokenImpl(span), _value(value) {} [[nodiscard]] uint64_t GetValue() const noexcept { return _value; } }; class FloatLiteral : public LexTokenImpl { double _value; public: FloatLiteral(TextSpan span, double value) : LexTokenImpl(span), _value(value) {} [[nodiscard]] double GetValue() const noexcept { return _value; } }; class StringLiteral : public LexTokenImpl { std::u8string _value; public: StringLiteral(TextSpan span, std::u8string value) : LexTokenImpl(span), _value(std::move(value)) {} [[nodiscard]] const std::u8string& GetValue() const noexcept { return _value; } }; class IdentifierToken : public LexTokenImpl { std::u8string _value; public: IdentifierToken(TextSpan span, std::u8string value) : LexTokenImpl(span), _value(std::move(value)) {} [[nodiscard]] const std::u8string& GetValue() const noexcept { return _value; } }; } #endif // ELOHIMSCRIPT_LEXTOKEN_HPP