Added until tag.
This commit is contained in:
parent
08218e3530
commit
bff2b4d2c5
4
Tag.cpp
4
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;
|
||||
|
57
__until.cpp
Normal file
57
__until.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include "__until.h"
|
||||
#include "Exception.h"
|
||||
#include "Operand.h"
|
||||
#include <iostream>
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user