comment fix

This commit is contained in:
lachrymaL 2021-12-12 23:29:53 -05:00
parent 084acbba1e
commit 004bb36b09
No known key found for this signature in database
GPG key ID: F3640ACFA174B1C1
5 changed files with 15 additions and 15 deletions

View file

@ -21,10 +21,14 @@ namespace NVL {
}
}
Variable::Variable() {}
Variable::Variable(Type t) : type(t) {
if (t != Type::Nil)
throw std::runtime_error("Cannot create non-nil object with type alone");
}
Variable::Variable(const Number& v) : type(Type::Number), value(v), length(1) {}
Variable::Variable(const std::string& v) : type(Type::String), value(v), length(1) {}
Variable::Variable(const std::vector<Variable>& v) : type(Type::Array), value(v), length(v.size()) {}
Variable::Variable(void* v, int l) : type(Type::Procedure), value(v), length(l) {}
Variable::Variable(const std::function < Variable(std::vector<Variable>)>& v, int l) : type(Type::Procedure), value(v), length(l) {}
Environment ENVIRONMENT;

View file

@ -6,18 +6,19 @@
namespace NVL {
using Number = float;
enum class Type { Procedure, Number, String, Array };
enum class Type { Procedure, Number, String, Array, Nil };
struct Variable {
Type type;
std::variant<Number, std::string, std::vector<Variable>, void*> value;
std::variant<Number, std::string, std::vector<Variable>, std::function<Variable(std::vector<Variable>)>> value;
int length;
bool operator==(const Variable& other) const;
Variable();
Variable(Type t);
Variable(const Number& v);
Variable(const std::string& v);
Variable(const std::vector<Variable>& v);
Variable(void* v, int l);
Variable(const std::function < Variable(std::vector<Variable>)>& v, int l);
};
class Environment {

View file

@ -6,12 +6,12 @@
#include <iostream>
int main() {
auto f = [](std::string& what) -> std::any { return true; };
NVL::Variable v(&f, 3);
auto f = [](NVL::Variable) { return NVL::Variable(NVL::Type::Nil); };
NVL::Variable v(f, 1);
NVL::ENVIRONMENT.enter("hello", v);
const std::string PJ_DIR = "E:\\Archive\\Projects\\NouVeL\\NouVeL\\";
NVL::ParseFile(PJ_DIR + "test.nvl");
NVL::ParseFile(PJ_DIR + "spec.nvl");
return 0;
}

View file

@ -102,10 +102,6 @@ namespace {
return true;
}
/*struct Command {
Object procedure;
std::vector<Object> args{};
};*/
class Object {
public:
ParseType type;
@ -122,9 +118,7 @@ namespace {
std::string name;
std::vector<Command> commands{};
public:
Scene(const std::string& name) : name(name) {
//NVL::ENVIRONMENT.enter(name, this);
}
Scene(const std::string& name) : name(name) {}
void append(const Command& c) {
commands.push_back(c);
}
@ -241,6 +235,7 @@ namespace {
c.push_back(ParseExpression(f, pos));
};
SkipComments(f, pos);
return c;
}

View file

@ -1,3 +1,3 @@
BEGIN Scene1
hello "String \\ sdsd \" \\ \" sds" 873482384 .2342342
END