NouVeL/NVL/Parser.h

46 lines
898 B
C++

#pragma once
#include <variant>
#include <string>
#include <utility>
#include "Common.h"
namespace NVL::Parse {
enum class Type { Symbol, Number, String, Array, Subexpression };
class Object {
public:
Object() = delete;
Object(const Number& v);
Object(Type t, const String& v);
Object(Type t, const Vector<Object>& v);
Object(Number&& v);
Object(Type t, String&& v);
Object(Type t, Vector<Object>&& v);
Type type;
std::variant<
Number,
String,
Vector<Object>
> value;
};
using Command = Vector<Object>;
class Scene {
Vector<Command> commands{};
public:
String name;
Scene(const String& name) : name(name) {}
void append(const Command& c) {
commands.push_back(c);
}
void append(Command&& c) {
commands.push_back(std::move(c));
}
const auto& get() const {
return commands;
}
};
Vector<Scene> ParseFile(const std::string& path);
}