Work on if, call and system tags.
This commit is contained in:
1 parent
8475ef01d1
commit
071151d8a1
6 files changed
+123
-20
No files matched your search
@@ -8,7 +8,8 @@ namespace jet {
|
||||
__if::__if(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global, "else") {
|
||||
|
||||
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.");
|
||||
@@ -19,15 +20,27 @@ namespace jet {
|
||||
throw coreutils::Exception("type expected if value1 and value2 specified.");
|
||||
} else
|
||||
throw coreutils::Exception("value2 required if value1 specified.");
|
||||
std::cout << variables["value1"].str() << "' and value2 '" << variables["value2"].str() << "' comparison" << std::endl;
|
||||
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.");
|
||||
result = Expression(variables["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.");
|
||||
result = Expression(variables["expr"]);
|
||||
booleanResult = true;
|
||||
}
|
||||
if(result.boolValue())
|
||||
if(booleanResult)
|
||||
processContainer(container);
|
||||
else
|
||||
if(hasContainer2)
|
||||
|
||||
Reference in new issue
Block a user