comment fix
This commit is contained in:
parent
084acbba1e
commit
004bb36b09
5 changed files with 15 additions and 15 deletions
|
@ -21,10 +21,14 @@ namespace NVL {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Variable::Variable() {}
|
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 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::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(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;
|
Environment ENVIRONMENT;
|
||||||
|
|
||||||
|
|
|
@ -6,18 +6,19 @@
|
||||||
|
|
||||||
namespace NVL {
|
namespace NVL {
|
||||||
using Number = float;
|
using Number = float;
|
||||||
enum class Type { Procedure, Number, String, Array };
|
enum class Type { Procedure, Number, String, Array, Nil };
|
||||||
|
|
||||||
struct Variable {
|
struct Variable {
|
||||||
Type type;
|
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;
|
int length;
|
||||||
bool operator==(const Variable& other) const;
|
bool operator==(const Variable& other) const;
|
||||||
Variable();
|
Variable();
|
||||||
|
Variable(Type t);
|
||||||
Variable(const Number& v);
|
Variable(const Number& v);
|
||||||
Variable(const std::string& v);
|
Variable(const std::string& v);
|
||||||
Variable(const std::vector<Variable>& 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 {
|
class Environment {
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
auto f = [](std::string& what) -> std::any { return true; };
|
auto f = [](NVL::Variable) { return NVL::Variable(NVL::Type::Nil); };
|
||||||
NVL::Variable v(&f, 3);
|
NVL::Variable v(f, 1);
|
||||||
|
|
||||||
NVL::ENVIRONMENT.enter("hello", v);
|
NVL::ENVIRONMENT.enter("hello", v);
|
||||||
|
|
||||||
const std::string PJ_DIR = "E:\\Archive\\Projects\\NouVeL\\NouVeL\\";
|
const std::string PJ_DIR = "E:\\Archive\\Projects\\NouVeL\\NouVeL\\";
|
||||||
NVL::ParseFile(PJ_DIR + "test.nvl");
|
NVL::ParseFile(PJ_DIR + "spec.nvl");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,10 +102,6 @@ namespace {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*struct Command {
|
|
||||||
Object procedure;
|
|
||||||
std::vector<Object> args{};
|
|
||||||
};*/
|
|
||||||
class Object {
|
class Object {
|
||||||
public:
|
public:
|
||||||
ParseType type;
|
ParseType type;
|
||||||
|
@ -122,9 +118,7 @@ namespace {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::vector<Command> commands{};
|
std::vector<Command> commands{};
|
||||||
public:
|
public:
|
||||||
Scene(const std::string& name) : name(name) {
|
Scene(const std::string& name) : name(name) {}
|
||||||
//NVL::ENVIRONMENT.enter(name, this);
|
|
||||||
}
|
|
||||||
void append(const Command& c) {
|
void append(const Command& c) {
|
||||||
commands.push_back(c);
|
commands.push_back(c);
|
||||||
}
|
}
|
||||||
|
@ -241,6 +235,7 @@ namespace {
|
||||||
c.push_back(ParseExpression(f, pos));
|
c.push_back(ParseExpression(f, pos));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SkipComments(f, pos);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
BEGIN Scene1
|
BEGIN Scene1
|
||||||
hello "String \\ sdsd \" \\ \" sds" 873482384 .2342342
|
|
||||||
END
|
END
|
||||||
|
|
Loading…
Add table
Reference in a new issue