Finished up the keyword resolution issue and fixed for, while and until. Other tags still need work.
This commit is contained in:
parent
93a520f152
commit
6da620971e
@ -117,7 +117,6 @@ namespace jet {
|
||||
if(in.ifNext("<")) {
|
||||
Operand op(in);
|
||||
if(isNumber && op.isNumber) {
|
||||
std::cout << doubleValue << " < " << op.doubleValue << std::endl;
|
||||
if(doubleValue < op.doubleValue) {
|
||||
boolean = true;
|
||||
isNumber = false;
|
||||
@ -279,10 +278,8 @@ namespace jet {
|
||||
throw coreutils::Exception("operand is not a number.");
|
||||
} else
|
||||
throw coreutils::Exception("operand is not a number.");
|
||||
} else {
|
||||
// std::cout << ">" << string << std::endl;
|
||||
} else
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
2
Tag.cpp
2
Tag.cpp
@ -2,7 +2,6 @@
|
||||
#include "Exception.h"
|
||||
#include "KeywordValue.h"
|
||||
#include "Global.h"
|
||||
#include "Log.h"
|
||||
#include "__mysql.h"
|
||||
#include "__sql.h"
|
||||
#include "__whilerow.h"
|
||||
@ -63,7 +62,6 @@ namespace jet {
|
||||
trimLines = variables["trimlines"] == "true" ? true: false;
|
||||
}
|
||||
if(hasContainer) {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_2) << "has Container: " << hasContainer;
|
||||
bool hasSplitTag = splitTagName == "" ? false: true;
|
||||
char *start = in.getCursor();
|
||||
while(!in.eod()) {
|
||||
|
24
__for.cpp
24
__for.cpp
@ -6,19 +6,23 @@ namespace jet {
|
||||
|
||||
__for::__for(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent) : Tag(in, parentOut, global, parent) {
|
||||
double counter = 0.0f;
|
||||
double end = 0.0f;
|
||||
double step = 0.0f;
|
||||
bool nameDefined = variableDefined("name");
|
||||
if(variableDefined(coreutils::ZString("start"))) {
|
||||
if(variableDefined("start")) {
|
||||
resolveKeyword("start");
|
||||
counter = variables["start"].asDouble();
|
||||
variables["start"].reset();
|
||||
}
|
||||
if(variableDefined(coreutils::ZString("end"))) {
|
||||
end = variables["end"].asDouble();
|
||||
}
|
||||
if(variableDefined(coreutils::ZString("step"))) {
|
||||
step = variables["step"].asDouble();
|
||||
}
|
||||
for(double ix = counter; ix <= end; ix += step) {
|
||||
if(variableDefined("end"))
|
||||
resolveKeyword("end");
|
||||
else
|
||||
throw coreutils::Exception("for tag requires end keyword.");
|
||||
if(variableDefined("step"))
|
||||
resolveKeyword("step");
|
||||
else
|
||||
throw coreutils::Exception("for tag requires step keyword.");
|
||||
for(double ix = counter; ix <= variables["end"].asDouble(); ix += variables["step"].asDouble()) {
|
||||
variables["end"].reset();
|
||||
variables["step"].reset();
|
||||
if(nameDefined)
|
||||
variables[variables["name"]] = ix;
|
||||
processContainer(container);
|
||||
|
@ -24,7 +24,7 @@ namespace jet {
|
||||
resolveKeyword("name");
|
||||
|
||||
if(variableDefined("expr")) {
|
||||
resolveKeyword("eval");
|
||||
resolveKeyword("expr");
|
||||
if(!variableDefined("scope") || (variables["scope"] == "global"))
|
||||
global.variables[variables["name"]] = Operand(variables["expr"]).string;
|
||||
else if(variables["scope"] == "local")
|
||||
|
39
__until.cpp
39
__until.cpp
@ -9,24 +9,18 @@ namespace jet {
|
||||
|
||||
coreutils::MString result;
|
||||
bool booleanResult = false;
|
||||
bool exprMethod = false;
|
||||
coreutils::MString exprSaved;
|
||||
|
||||
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("either value1 or expr can be specified but not both.");
|
||||
if(!variableDefined("value2"))
|
||||
throw coreutils::Exception("value2 required if value1 specified.");
|
||||
if(!variableDefined("type"))
|
||||
throw coreutils::Exception("type required for a value1 and value2 comparison.");
|
||||
throw coreutils::Exception("type expected if value1 and value2 specified.");
|
||||
|
||||
int rc = variables["value1"].compare(variables["value2"]);
|
||||
if(((variables["type"] == "eq") && (rc == 0)) ||
|
||||
((variables["type"] == "ne") && (rc != 0)) ||
|
||||
@ -39,17 +33,32 @@ namespace jet {
|
||||
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;
|
||||
exprMethod = true;
|
||||
exprSaved = variables["expr"];
|
||||
}
|
||||
|
||||
do {
|
||||
processContainer(container);
|
||||
container.reset();
|
||||
if(exprMethod) {
|
||||
variables["expr"].reset();
|
||||
variables["expr"] = exprSaved;
|
||||
resolveKeyword("expr");
|
||||
booleanResult = Operand(variables["expr"]).boolean;
|
||||
} else {
|
||||
booleanResult = false;
|
||||
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;
|
||||
}
|
||||
} while(booleanResult);
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ namespace jet {
|
||||
coreutils::MString result;
|
||||
bool booleanResult = false;
|
||||
bool exprMethod = false;
|
||||
coreutils::MString exprSaved;
|
||||
|
||||
if(variableDefined("value1")) {
|
||||
|
||||
@ -37,14 +38,17 @@ namespace jet {
|
||||
if(variableDefined("type"))
|
||||
throw coreutils::Exception("type should not be specified with expr.");
|
||||
exprMethod = true;
|
||||
exprSaved = variables["expr"];
|
||||
resolveKeyword("expr");
|
||||
booleanResult = Operand(variables["expr"]).boolean;
|
||||
}
|
||||
|
||||
while(booleanResult) {
|
||||
processContainer(container);
|
||||
container.reset();
|
||||
if(exprMethod) {
|
||||
variables["expr"].reset();
|
||||
variables["expr"] = exprSaved;
|
||||
resolveKeyword("expr");
|
||||
booleanResult = Operand(variables["expr"]).boolean;
|
||||
} else {
|
||||
booleanResult = false;
|
||||
|
@ -12,3 +12,6 @@ $[var$[i$[letterx]]var]
|
||||
$[letterx;TOHEX]
|
||||
$[var$[i$[letterx]]$[ix]]
|
||||
$[var$[i$[letterx]]$[i$[letterx]]]
|
||||
$[ix]
|
||||
<set name="ix" expr="$[ix]+1" />
|
||||
$[ix]
|
||||
|
@ -2,8 +2,7 @@
|
||||
<jet cgi="false" name1="localname" filterblanklines="true" trimlines="true">
|
||||
<set name="ix" value="1" />
|
||||
<while expr="$[ix]<10">
|
||||
<set name="check" expr="$[ix]<10" />
|
||||
-->$[check]-$[ix]<--
|
||||
-->$[ix]<--
|
||||
<set name="ix" expr="$[ix]+1" />
|
||||
</while>
|
||||
</jet>
|
||||
|
Loading…
x
Reference in New Issue
Block a user