diff --git a/Tag.cpp b/Tag.cpp index f46b95e..73a1f21 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -18,6 +18,7 @@ #include "__system.h" #include "__jet.h" #include "__while.h" +#include "__until.h" #include "__header.h" #include "__whiledir.h" #include "__tag.h" @@ -161,6 +162,9 @@ namespace jet { } else if(ifTagName(in, "while")) { __while _while(in, out, global, this); continue; + } else if(ifTagName(in, "until")) { + __until _until(in, out, global, this); + continue; } else if(ifTagName(in, "header")) { __header _header(in, out, global, this); continue; diff --git a/__until.cpp b/__until.cpp new file mode 100644 index 0000000..82d7a44 --- /dev/null +++ b/__until.cpp @@ -0,0 +1,57 @@ +#include "__until.h" +#include "Exception.h" +#include "Operand.h" +#include + +namespace jet { + + __until::__until(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent) : Tag(in, parentOut, global, parent) { + + coreutils::MString result; + bool booleanResult = false; + + if(variableDefined("value1")) { + + if(variableDefined("expr")) + throw coreutils::Exception("Either value1 or expr can be specified but not both."); + if(variableDefined("value2")) { + + if(variableDefined("type")) { + + + } + else + throw coreutils::Exception("type expected if value1 and value2 specified."); + } + else + throw coreutils::Exception("value2 required if value1 specified."); + if(!variableDefined("type")) + throw coreutils::Exception("type required for a value1 and value2 comparison."); + int rc = variables["value1"].compare(variables["value2"]); + if(((variables["type"] == "eq") && (rc == 0)) || + ((variables["type"] == "ne") && (rc != 0)) || + ((variables["type"] == "lt") && (rc == -1)) || + ((variables["type"] == "le") && (rc != 1)) || + ((variables["type"] == "gt") && (rc == 1)) || + ((variables["type"] == "ge") && (rc != -1))) + booleanResult = true; + else + throw coreutils::Exception("type value must be 'eq','ne','lt','le','gt','ge'."); + } + else if(variableDefined("expr")) { + + if(variableDefined("value2")) + throw coreutils::Exception("value2 should not be specified with expr."); + if(variableDefined("type")) + throw coreutils::Exception("type should not be specified with expr."); + booleanResult = Operand(variables["expr"]).boolean; + } + + do { + processContainer(container); + container.reset(); + } while(booleanResult); + + } + +} diff --git a/__until.h b/__until.h new file mode 100644 index 0000000..c396d55 --- /dev/null +++ b/__until.h @@ -0,0 +1,18 @@ +#ifndef ____until_h__ +#define ____until_h__ + +#include "Tag.h" +#include + +namespace jet { + + class __until : public Tag { + + public: + __until(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent); + + }; + +} + +#endif