diff --git a/Expression.h b/Expression.h index daa783b..3a6e508 100644 --- a/Expression.h +++ b/Expression.h @@ -1,5 +1,5 @@ #ifndef __Expression_h__ -#define __expression_h__ +#define __Expression_h__ #include "MString.h" diff --git a/Tag.cpp b/Tag.cpp index a21cb6f..550e41b 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -66,7 +66,8 @@ namespace jet { copyContainer(out, parent); else if(output) - copyContainer(container, parent); + copyContainer(container, parent); + std::cout << "Destructing " << name << std::endl; } void Tag::parseContainer(coreutils::ZString &in) { diff --git a/__set.cpp b/__set.cpp index e6a4d98..6dd8a74 100644 --- a/__set.cpp +++ b/__set.cpp @@ -5,14 +5,20 @@ namespace jet { __set::__set(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) { - output = false; - if(variables["scope"] == "local") - variables[variables["name"]] = variables["value"]; - if(variables["scope"] == "global") - global.variables[variables["name"]] = container; - - global.dump(); - - } - + output = false; + if(!variableDefined("name")) + throw coreutils::Exception("set tag must have name defined."); + if(variableDefined("value") && hasContainer) + throw coreutils::Exception("set tag cannot have both value and a container."); + if(!variableDefined("value") && !hasContainer) + throw coreutils::Exception("set tag must have a value or a container."); + if(!variableDefined("scope") || (variables["scope"] == "global")) { + if(hasContainer) { + global.variables[variables["name"]] = container.parsed(); + } else + global.variables[variables["name"]] = variables["value"]; + } else { + + } + } } diff --git a/testjet b/testjet index 91b0a14..238ca8b 100755 Binary files a/testjet and b/testjet differ diff --git a/testjet.cpp b/testjet.cpp index 5e11d94..4528dae 100644 --- a/testjet.cpp +++ b/testjet.cpp @@ -6,8 +6,9 @@ int main(int argc, char **argv) { coreutils::ZString data("\n" - " \n" - " this is the value\n" + " \n" + " this is the value\n" + " another container value\n" " \n" " \n" " 789\n" @@ -26,6 +27,6 @@ int main(int argc, char **argv) { coreutils::MString out; jet::__jet *jet = new jet::__jet(data, out, global); delete jet; - std::cout << ">>-------" << std::endl << out << std::endl << "<<------"; - std::cout << ">>" << global.variables["thename"] << "<<" << std::endl; + std::cout << ">>-------" << std::endl << out << std::endl << "<<------" << std::endl; + global.dump(); }