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