From 004bb36b09ef49f3c7e610c16c0da14f5cf7d195 Mon Sep 17 00:00:00 2001 From: lachrymaL Date: Sun, 12 Dec 2021 23:29:53 -0500 Subject: [PATCH] comment fix --- NouVeL/Environment.cpp | 6 +++++- NouVeL/Environment.h | 7 ++++--- NouVeL/NouVeL.cpp | 6 +++--- NouVeL/Parser.cpp | 9 ++------- NouVeL/test.nvl | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/NouVeL/Environment.cpp b/NouVeL/Environment.cpp index 156eb76..1739526 100644 --- a/NouVeL/Environment.cpp +++ b/NouVeL/Environment.cpp @@ -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& 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)>& v, int l) : type(Type::Procedure), value(v), length(l) {} Environment ENVIRONMENT; diff --git a/NouVeL/Environment.h b/NouVeL/Environment.h index 14983cd..f455d77 100644 --- a/NouVeL/Environment.h +++ b/NouVeL/Environment.h @@ -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, void*> value; + std::variant, std::function)>> 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& v); - Variable(void* v, int l); + Variable(const std::function < Variable(std::vector)>& v, int l); }; class Environment { diff --git a/NouVeL/NouVeL.cpp b/NouVeL/NouVeL.cpp index 6a6aeb7..2dba1e1 100644 --- a/NouVeL/NouVeL.cpp +++ b/NouVeL/NouVeL.cpp @@ -6,12 +6,12 @@ #include 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; } diff --git a/NouVeL/Parser.cpp b/NouVeL/Parser.cpp index f3db886..bc2d7e7 100644 --- a/NouVeL/Parser.cpp +++ b/NouVeL/Parser.cpp @@ -102,10 +102,6 @@ namespace { return true; } - /*struct Command { - Object procedure; - std::vector args{}; - };*/ class Object { public: ParseType type; @@ -122,9 +118,7 @@ namespace { std::string name; std::vector 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; } diff --git a/NouVeL/test.nvl b/NouVeL/test.nvl index 4fc0f9a..485b3b8 100644 --- a/NouVeL/test.nvl +++ b/NouVeL/test.nvl @@ -1,3 +1,3 @@ BEGIN Scene1 -hello "String \\ sdsd \" \\ \" sds" 873482384 .2342342 + END