NouVeL/NVL/Parser.h

47 lines
898 B
C
Raw Normal View History

2021-05-14 11:47:54 -04:00
#pragma once
2021-12-17 01:05:38 -05:00
#include <variant>
2021-05-14 11:47:54 -04:00
#include <string>
2022-08-21 16:24:13 -04:00
#include <utility>
2021-12-17 01:05:38 -05:00
#include "Common.h"
2021-05-14 16:51:04 -04:00
2021-12-17 01:05:38 -05:00
namespace NVL::Parse {
enum class Type { Symbol, Number, String, Array, Subexpression };
2022-08-18 12:17:43 -04:00
class Object {
2021-12-17 01:05:38 -05:00
public:
2022-08-18 12:17:43 -04:00
Object() = delete;
Object(const Number& v);
Object(Type t, const String& v);
2023-04-07 16:04:30 -04:00
Object(Type t, const Vector<Object>& v);
2022-08-18 12:17:43 -04:00
Object(Number&& v);
Object(Type t, String&& v);
2023-04-07 16:04:30 -04:00
Object(Type t, Vector<Object>&& v);
2021-12-17 01:05:38 -05:00
Type type;
std::variant<
Number,
String,
2023-04-07 16:04:30 -04:00
Vector<Object>
2021-12-17 01:05:38 -05:00
> value;
};
2023-04-07 16:04:30 -04:00
using Command = Vector<Object>;
2021-12-17 01:05:38 -05:00
class Scene {
2023-04-07 16:04:30 -04:00
Vector<Command> commands{};
2021-12-17 01:05:38 -05:00
public:
2022-08-22 02:15:25 -04:00
String name;
Scene(const String& name) : name(name) {}
2021-12-17 01:05:38 -05:00
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;
}
};
2023-04-07 16:04:30 -04:00
Vector<Scene> ParseFile(const std::string& path);
2021-12-13 14:04:12 -05:00
}