32 lines
568 B
C++
32 lines
568 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <iostream>
|
|
#include <string_view>
|
|
|
|
enum class StringObjectType : uint8_t {
|
|
IDENTIFIER,
|
|
LITERAL,
|
|
};
|
|
|
|
enum class ObjectType : uint8_t {
|
|
NIL,
|
|
IDENTIFIER,
|
|
STRING_LIT,
|
|
NUMBER,
|
|
};
|
|
|
|
struct Object {
|
|
Object() : type{ObjectType::NIL} {};
|
|
Object(double number) : type{ObjectType::NUMBER}, number{number} {};
|
|
Object(StringObjectType string_type, const std::string &value);
|
|
|
|
ObjectType type;
|
|
union {
|
|
std::string_view str;
|
|
double number;
|
|
};
|
|
};
|
|
|
|
std::ostream &operator<<(std::ostream &os, const Object &obj);
|