Made $[%name] to retrieve keyword values in a tag. Has bugs.
This commit is contained in:
parent
9622b5cf8c
commit
f6dda8496c
28
Global.cpp
28
Global.cpp
@ -59,15 +59,20 @@ namespace jet {
|
|||||||
throw coreutils::Exception("modifier not valid.");
|
throw coreutils::Exception("modifier not valid.");
|
||||||
}
|
}
|
||||||
|
|
||||||
coreutils::MString Global::getVariable(coreutils::ZString &variable, std::map<coreutils::MString, coreutils::MString> &lvariables) {
|
coreutils::MString Global::getVariable(coreutils::ZString &variable,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &lvariables,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &keywords) {
|
||||||
if(variable.ifNext("$[")) {
|
if(variable.ifNext("$[")) {
|
||||||
coreutils::MString name;
|
coreutils::MString name;
|
||||||
coreutils::MString modifier;
|
coreutils::MString modifier;
|
||||||
if(variable.ifNext("!")) {
|
if(variable.ifNext("!")) {
|
||||||
renderVariableName(variable, name, modifier, lvariables);
|
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||||
return variables[name];
|
return variables[name];
|
||||||
} if(variable.ifNext(":")) {
|
} else if(variable.ifNext("%")) {
|
||||||
renderVariableName(variable, name, modifier, lvariables);
|
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||||
|
return keywords[name];
|
||||||
|
} else if(variable.ifNext(":")) {
|
||||||
|
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||||
if(name.find(":") == -1) {
|
if(name.find(":") == -1) {
|
||||||
name << ":0";
|
name << ":0";
|
||||||
}
|
}
|
||||||
@ -75,10 +80,10 @@ namespace jet {
|
|||||||
} if(variable.ifNext("@")) {
|
} if(variable.ifNext("@")) {
|
||||||
// TODO: should only allow session variables. Allow substitution.
|
// TODO: should only allow session variables. Allow substitution.
|
||||||
} if(variable.ifNext("%")) {
|
} if(variable.ifNext("%")) {
|
||||||
renderVariableName(variable, name, modifier, lvariables);
|
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||||
return getenv(name.c_str());
|
return getenv(name.c_str());
|
||||||
} else {
|
} else {
|
||||||
renderVariableName(variable, name, modifier, lvariables);
|
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||||
name.split(".");
|
name.split(".");
|
||||||
if(name.getList().size() == 1) {
|
if(name.getList().size() == 1) {
|
||||||
if(variables.find(name[0]) == variables.end())
|
if(variables.find(name[0]) == variables.end())
|
||||||
@ -91,7 +96,7 @@ namespace jet {
|
|||||||
} if(variable.ifNext("#[")) {
|
} if(variable.ifNext("#[")) {
|
||||||
coreutils::MString name;
|
coreutils::MString name;
|
||||||
coreutils::MString modifier;
|
coreutils::MString modifier;
|
||||||
renderVariableName(variable, name, modifier, lvariables);
|
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||||
if(lvariables.find(name) == lvariables.end())
|
if(lvariables.find(name) == lvariables.end())
|
||||||
throw coreutils::Exception("local variable is not initialized.");
|
throw coreutils::Exception("local variable is not initialized.");
|
||||||
return lvariables[name];
|
return lvariables[name];
|
||||||
@ -99,16 +104,19 @@ namespace jet {
|
|||||||
throw coreutils::Exception("Expecting a variable initializer ('$[' or '#[').");
|
throw coreutils::Exception("Expecting a variable initializer ('$[' or '#[').");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Global::renderVariableName(coreutils::ZString &variable, coreutils::MString &name, coreutils::MString &modifier, std::map<coreutils::MString, coreutils::MString> &lvariables) {
|
void Global::renderVariableName(coreutils::ZString &variable,
|
||||||
|
coreutils::MString &name, coreutils::MString &modifier,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &lvariables,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &keywords) {
|
||||||
while(!variable.ifNext("]")) {
|
while(!variable.ifNext("]")) {
|
||||||
name << variable.getTokenInclude("?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
|
name << variable.getTokenInclude("?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
|
||||||
if(variable.ifNext(";")) {
|
if(variable.ifNext(";")) {
|
||||||
renderVariableName(variable, modifier, modifier, lvariables);
|
renderVariableName(variable, modifier, modifier, lvariables, keywords);
|
||||||
return;
|
return;
|
||||||
} else if(variable.ifNext(":")) {
|
} else if(variable.ifNext(":")) {
|
||||||
name << ":";
|
name << ":";
|
||||||
} else if(variable.startsWith("$[") || variable.startsWith("#[")) {
|
} else if(variable.startsWith("$[") || variable.startsWith("#[")) {
|
||||||
name << getVariable(variable, lvariables);
|
name << getVariable(variable, lvariables, keywords);
|
||||||
} else if(variable.ifNext("]"))
|
} else if(variable.ifNext("]"))
|
||||||
return;
|
return;
|
||||||
else if(!variable.ifNextInclude("?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"))
|
else if(!variable.ifNextInclude("?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"))
|
||||||
|
10
Global.h
10
Global.h
@ -19,8 +19,14 @@ namespace jet {
|
|||||||
void addSession(coreutils::MString sessionId, __mysql *mysql);
|
void addSession(coreutils::MString sessionId, __mysql *mysql);
|
||||||
void removeSession(coreutils::MString sessionId);
|
void removeSession(coreutils::MString sessionId);
|
||||||
coreutils::MString processModifier(coreutils::MString &value, coreutils::MString &modifier);
|
coreutils::MString processModifier(coreutils::MString &value, coreutils::MString &modifier);
|
||||||
coreutils::MString getVariable(coreutils::ZString &variable, std::map<coreutils::MString, coreutils::MString> &lvariables);
|
coreutils::MString getVariable(coreutils::ZString &variable,
|
||||||
void renderVariableName(coreutils::ZString &variable, coreutils::MString &name, coreutils::MString &modifier, std::map<coreutils::MString, coreutils::MString> &lvariables);
|
std::map<coreutils::MString, coreutils::MString> &lvariables,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &keywords);
|
||||||
|
void renderVariableName(coreutils::ZString &variable,
|
||||||
|
coreutils::MString &name,
|
||||||
|
coreutils::MString &modifier,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &lvariables,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &keywords);
|
||||||
__mysql * getSession(coreutils::MString sessionId);
|
__mysql * getSession(coreutils::MString sessionId);
|
||||||
coreutils::ZString getSessionVariable(coreutils::MString &splitName);
|
coreutils::ZString getSessionVariable(coreutils::MString &splitName);
|
||||||
void outputHeaders();
|
void outputHeaders();
|
||||||
|
@ -3,10 +3,13 @@
|
|||||||
|
|
||||||
namespace jet {
|
namespace jet {
|
||||||
|
|
||||||
KeywordValue::KeywordValue(coreutils::ZString data, Global &global, std::map<coreutils::MString, coreutils::MString> &variables) : MString() {
|
KeywordValue::KeywordValue(coreutils::ZString data,
|
||||||
|
Global &global,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &variables,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &keywords) : MString() {
|
||||||
while(!data.eod()) {
|
while(!data.eod()) {
|
||||||
if(data.startsWith("$[") || data.startsWith("#[")) {
|
if(data.startsWith("$[") || data.startsWith("#[")) {
|
||||||
write(global.getVariable(data, variables));
|
write(global.getVariable(data, variables, keywords));
|
||||||
} else {
|
} else {
|
||||||
write(data.charAt(0));
|
write(data.charAt(0));
|
||||||
data.nextChar();
|
data.nextChar();
|
||||||
|
@ -13,7 +13,9 @@ namespace jet {
|
|||||||
class KeywordValue : public coreutils::MString {
|
class KeywordValue : public coreutils::MString {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KeywordValue(coreutils::ZString data, Global &global, std::map<coreutils::MString, coreutils::MString> &variables);
|
KeywordValue(coreutils::ZString data, Global &global,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &variables,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &keywords);
|
||||||
virtual ~KeywordValue();
|
virtual ~KeywordValue();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
43
Operand.cpp
43
Operand.cpp
@ -6,21 +6,24 @@
|
|||||||
|
|
||||||
namespace jet {
|
namespace jet {
|
||||||
|
|
||||||
Operand::Operand(coreutils::ZString &in, Global &global, std::map<coreutils::MString, coreutils::MString> &lvariables) {
|
Operand::Operand(coreutils::ZString &in,
|
||||||
|
Global &global,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &lvariables,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &keywords) {
|
||||||
|
|
||||||
doubleValue = 0;
|
doubleValue = 0;
|
||||||
|
|
||||||
in.skipWhitespace();
|
in.skipWhitespace();
|
||||||
|
|
||||||
if(in.startsWith("$[") || in.startsWith("#[")) {
|
if(in.startsWith("$[") || in.startsWith("#[")) {
|
||||||
string = global.getVariable(in, lvariables);
|
string = global.getVariable(in, lvariables, keywords);
|
||||||
doubleValue = string.asDouble();
|
doubleValue = string.asDouble();
|
||||||
isNumber = string.eod();
|
isNumber = string.eod();
|
||||||
string.reset();
|
string.reset();
|
||||||
if((string == "false") || (string == "true"))
|
if((string == "false") || (string == "true"))
|
||||||
boolean = true;
|
boolean = true;
|
||||||
} else if(in.ifNext("(")) {
|
} else if(in.ifNext("(")) {
|
||||||
Operand op(in, global, lvariables);
|
Operand op(in, global, lvariables, keywords);
|
||||||
string = op.string;
|
string = op.string;
|
||||||
doubleValue = op.doubleValue;
|
doubleValue = op.doubleValue;
|
||||||
if(!in.ifNext(")"))
|
if(!in.ifNext(")"))
|
||||||
@ -28,15 +31,15 @@ namespace jet {
|
|||||||
} else if(in.ifNextIgnoreCase("SUBSTRING")) {
|
} else if(in.ifNextIgnoreCase("SUBSTRING")) {
|
||||||
if(!in.ifNext("("))
|
if(!in.ifNext("("))
|
||||||
throw coreutils::Exception("Expecting ( for SUBSTRING parameters.");
|
throw coreutils::Exception("Expecting ( for SUBSTRING parameters.");
|
||||||
Operand parm1(in, global, lvariables);
|
Operand parm1(in, global, lvariables, keywords);
|
||||||
if(!in.ifNext(","))
|
if(!in.ifNext(","))
|
||||||
throw coreutils::Exception("Expecting , in SUBSTRING expression.");
|
throw coreutils::Exception("Expecting , in SUBSTRING expression.");
|
||||||
Operand parm2(in, global, lvariables);
|
Operand parm2(in, global, lvariables, keywords);
|
||||||
if(in.ifNext(")")) {
|
if(in.ifNext(")")) {
|
||||||
string = parm1.string.substring(parm2.string.asInteger());
|
string = parm1.string.substring(parm2.string.asInteger());
|
||||||
} else if(!in.ifNext(","))
|
} else if(!in.ifNext(","))
|
||||||
throw coreutils::Exception("Expecting , in SUBSTRING expression.");
|
throw coreutils::Exception("Expecting , in SUBSTRING expression.");
|
||||||
Operand parm3(in, global, lvariables);
|
Operand parm3(in, global, lvariables, keywords);
|
||||||
if(in.ifNext(")")) {
|
if(in.ifNext(")")) {
|
||||||
string = parm1.string.substring(parm2.string.asInteger(), parm3.string.asInteger());
|
string = parm1.string.substring(parm2.string.asInteger(), parm3.string.asInteger());
|
||||||
} else
|
} else
|
||||||
@ -44,10 +47,10 @@ namespace jet {
|
|||||||
} else if(in.ifNextIgnoreCase("LEFT")) {
|
} else if(in.ifNextIgnoreCase("LEFT")) {
|
||||||
if(!in.ifNext("("))
|
if(!in.ifNext("("))
|
||||||
throw coreutils::Exception("Expecting ( for LEFT parameters.");
|
throw coreutils::Exception("Expecting ( for LEFT parameters.");
|
||||||
Operand parm1(in, global, lvariables);
|
Operand parm1(in, global, lvariables, keywords);
|
||||||
if(!in.ifNext(","))
|
if(!in.ifNext(","))
|
||||||
throw coreutils::Exception("Expecting , in LEFT expression.");
|
throw coreutils::Exception("Expecting , in LEFT expression.");
|
||||||
Operand parm2(in, global, lvariables);
|
Operand parm2(in, global, lvariables, keywords);
|
||||||
if(in.ifNext(")")) {
|
if(in.ifNext(")")) {
|
||||||
string = parm1.string.substring(0, parm2.string.asInteger());
|
string = parm1.string.substring(0, parm2.string.asInteger());
|
||||||
} else
|
} else
|
||||||
@ -55,9 +58,9 @@ namespace jet {
|
|||||||
} else if(in.ifNextIgnoreCase("EXPR")) {
|
} else if(in.ifNextIgnoreCase("EXPR")) {
|
||||||
if(!in.ifNext("("))
|
if(!in.ifNext("("))
|
||||||
throw coreutils::Exception("Expecting ( for EXPR parameters.");
|
throw coreutils::Exception("Expecting ( for EXPR parameters.");
|
||||||
Operand parm1(in, global, lvariables);
|
Operand parm1(in, global, lvariables, keywords);
|
||||||
if(in.ifNext(")")) {
|
if(in.ifNext(")")) {
|
||||||
Operand op(parm1.string, global, lvariables);
|
Operand op(parm1.string, global, lvariables, keywords);
|
||||||
string = op.string;
|
string = op.string;
|
||||||
isNumber = op.isNumber;
|
isNumber = op.isNumber;
|
||||||
boolean = op.boolean;
|
boolean = op.boolean;
|
||||||
@ -105,7 +108,7 @@ namespace jet {
|
|||||||
in.skipWhitespace();
|
in.skipWhitespace();
|
||||||
|
|
||||||
if(in.ifNext("!=") || in.ifNext("<>")) {
|
if(in.ifNext("!=") || in.ifNext("<>")) {
|
||||||
Operand op(in, global, lvariables);
|
Operand op(in, global, lvariables, keywords);
|
||||||
if(isNumber && op.isNumber) {
|
if(isNumber && op.isNumber) {
|
||||||
if(doubleValue != op.doubleValue) {
|
if(doubleValue != op.doubleValue) {
|
||||||
boolean = true;
|
boolean = true;
|
||||||
@ -129,7 +132,7 @@ namespace jet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(in.ifNext("<=")) {
|
if(in.ifNext("<=")) {
|
||||||
Operand op(in, global, lvariables);
|
Operand op(in, global, lvariables, keywords);
|
||||||
if(isNumber && op.isNumber) {
|
if(isNumber && op.isNumber) {
|
||||||
if(doubleValue <= op.doubleValue) {
|
if(doubleValue <= op.doubleValue) {
|
||||||
boolean = true;
|
boolean = true;
|
||||||
@ -153,7 +156,7 @@ namespace jet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(in.ifNext(">=")) {
|
if(in.ifNext(">=")) {
|
||||||
Operand op(in, global, lvariables);
|
Operand op(in, global, lvariables, keywords);
|
||||||
if(isNumber && op.isNumber) {
|
if(isNumber && op.isNumber) {
|
||||||
if(doubleValue >= op.doubleValue) {
|
if(doubleValue >= op.doubleValue) {
|
||||||
boolean = true;
|
boolean = true;
|
||||||
@ -177,7 +180,7 @@ namespace jet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(in.ifNext("=")) {
|
if(in.ifNext("=")) {
|
||||||
Operand op(in, global, lvariables);
|
Operand op(in, global, lvariables, keywords);
|
||||||
if(isNumber && op.isNumber) {
|
if(isNumber && op.isNumber) {
|
||||||
if(doubleValue == op.doubleValue) {
|
if(doubleValue == op.doubleValue) {
|
||||||
boolean = true;
|
boolean = true;
|
||||||
@ -201,7 +204,7 @@ namespace jet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(in.ifNext("<")) {
|
if(in.ifNext("<")) {
|
||||||
Operand op(in, global, lvariables);
|
Operand op(in, global, lvariables, keywords);
|
||||||
if(isNumber && op.isNumber) {
|
if(isNumber && op.isNumber) {
|
||||||
if(doubleValue < op.doubleValue) {
|
if(doubleValue < op.doubleValue) {
|
||||||
boolean = true;
|
boolean = true;
|
||||||
@ -225,7 +228,7 @@ namespace jet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(in.ifNext(">")) {
|
if(in.ifNext(">")) {
|
||||||
Operand op(in, global, lvariables);
|
Operand op(in, global, lvariables, keywords);
|
||||||
if(isNumber && op.isNumber) {
|
if(isNumber && op.isNumber) {
|
||||||
if(doubleValue > op.doubleValue) {
|
if(doubleValue > op.doubleValue) {
|
||||||
boolean = true;
|
boolean = true;
|
||||||
@ -250,7 +253,7 @@ namespace jet {
|
|||||||
}
|
}
|
||||||
if(in.ifNext("+")) {
|
if(in.ifNext("+")) {
|
||||||
if(isNumber) {
|
if(isNumber) {
|
||||||
Operand op(in, global, lvariables);
|
Operand op(in, global, lvariables, keywords);
|
||||||
if(op.isNumber) {
|
if(op.isNumber) {
|
||||||
doubleValue += op.doubleValue;
|
doubleValue += op.doubleValue;
|
||||||
string = std::format("{:.12f}", doubleValue);
|
string = std::format("{:.12f}", doubleValue);
|
||||||
@ -261,7 +264,7 @@ namespace jet {
|
|||||||
throw coreutils::Exception("operand is not a number.");
|
throw coreutils::Exception("operand is not a number.");
|
||||||
} else if(in.ifNext("-")) {
|
} else if(in.ifNext("-")) {
|
||||||
if(isNumber) {
|
if(isNumber) {
|
||||||
Operand op(in, global, lvariables);
|
Operand op(in, global, lvariables, keywords);
|
||||||
if(op.isNumber) {
|
if(op.isNumber) {
|
||||||
doubleValue -= op.doubleValue;
|
doubleValue -= op.doubleValue;
|
||||||
string = std::format("{:.12f}", doubleValue);
|
string = std::format("{:.12f}", doubleValue);
|
||||||
@ -272,7 +275,7 @@ namespace jet {
|
|||||||
throw coreutils::Exception("operand is not a number.");
|
throw coreutils::Exception("operand is not a number.");
|
||||||
} else if(in.ifNext("*")) {
|
} else if(in.ifNext("*")) {
|
||||||
if(isNumber) {
|
if(isNumber) {
|
||||||
Operand op(in, global, lvariables);
|
Operand op(in, global, lvariables, keywords);
|
||||||
if(op.isNumber) {
|
if(op.isNumber) {
|
||||||
doubleValue *= op.doubleValue;
|
doubleValue *= op.doubleValue;
|
||||||
string = std::format("{:.12f}", doubleValue);
|
string = std::format("{:.12f}", doubleValue);
|
||||||
@ -283,7 +286,7 @@ namespace jet {
|
|||||||
throw coreutils::Exception("operand is not a number.");
|
throw coreutils::Exception("operand is not a number.");
|
||||||
} else if(in.ifNext("/")) {
|
} else if(in.ifNext("/")) {
|
||||||
if(isNumber) {
|
if(isNumber) {
|
||||||
Operand op(in, global, lvariables);
|
Operand op(in, global, lvariables, keywords);
|
||||||
if(op.isNumber) {
|
if(op.isNumber) {
|
||||||
doubleValue /= op.doubleValue;
|
doubleValue /= op.doubleValue;
|
||||||
string = std::format("{:.12f}", doubleValue);
|
string = std::format("{:.12f}", doubleValue);
|
||||||
|
@ -9,7 +9,10 @@ namespace jet {
|
|||||||
class Operand {
|
class Operand {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Operand(coreutils::ZString &in, Global &global, std::map<coreutils::MString, coreutils::MString> &lvariables);
|
Operand(coreutils::ZString &in,
|
||||||
|
Global &global,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &lvariables,
|
||||||
|
std::map<coreutils::MString, coreutils::MString> &keywords);
|
||||||
|
|
||||||
bool isNumber;
|
bool isNumber;
|
||||||
|
|
||||||
|
4
Tag.cpp
4
Tag.cpp
@ -111,7 +111,7 @@ namespace jet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Tag::resolveKeyword(coreutils::ZString keyword) {
|
void Tag::resolveKeyword(coreutils::ZString keyword) {
|
||||||
keywords[keyword] = KeywordValue(keywords[keyword], global, parent->local->variables);
|
keywords[keyword] = KeywordValue(keywords[keyword], global, parent->local->variables, keywords);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tag::processContainer(coreutils::ZString &container) {
|
void Tag::processContainer(coreutils::ZString &container) {
|
||||||
@ -206,7 +206,7 @@ namespace jet {
|
|||||||
}
|
}
|
||||||
} else if(in.startsWith("$[") || in.startsWith("#[")) {
|
} else if(in.startsWith("$[") || in.startsWith("#[")) {
|
||||||
global.errorCursor = in.getCursor();
|
global.errorCursor = in.getCursor();
|
||||||
out.write(global.getVariable(in, local->variables));
|
out.write(global.getVariable(in, local->variables, keywords));
|
||||||
} else {
|
} else {
|
||||||
out.write(in.nextChar());
|
out.write(in.nextChar());
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace jet {
|
|||||||
if(keywordDefined("expr")) {
|
if(keywordDefined("expr")) {
|
||||||
if(keywordDefined("eval"))
|
if(keywordDefined("eval"))
|
||||||
throw coreutils::Exception("Cannot use eval with expr.");
|
throw coreutils::Exception("Cannot use eval with expr.");
|
||||||
global.headers[keywords["name"]] = Operand(keywords["expr"], global, parent->variables).string;
|
global.headers[keywords["name"]] = Operand(keywords["expr"], global, parent->variables, keywords).string;
|
||||||
} else if(hasContainer) {
|
} else if(hasContainer) {
|
||||||
processContainer(container);
|
processContainer(container);
|
||||||
if(evaluate) {
|
if(evaluate) {
|
||||||
|
@ -21,7 +21,7 @@ namespace jet {
|
|||||||
if(keywordDefined("expr")) {
|
if(keywordDefined("expr")) {
|
||||||
if(keywordDefined("eval"))
|
if(keywordDefined("eval"))
|
||||||
throw coreutils::Exception("Cannot use eval with expr.");
|
throw coreutils::Exception("Cannot use eval with expr.");
|
||||||
global.headers[keywords["name"]] = Operand(keywords["expr"], global, parent->variables).string;
|
global.headers[keywords["name"]] = Operand(keywords["expr"], global, parent->variables, keywords).string;
|
||||||
} else if(hasContainer) {
|
} else if(hasContainer) {
|
||||||
processContainer(container);
|
processContainer(container);
|
||||||
if(evaluate) {
|
if(evaluate) {
|
||||||
|
2
__if.cpp
2
__if.cpp
@ -34,7 +34,7 @@ namespace jet {
|
|||||||
throw coreutils::Exception("value2 should not be specified with expr.");
|
throw coreutils::Exception("value2 should not be specified with expr.");
|
||||||
if(keywordDefined("type"))
|
if(keywordDefined("type"))
|
||||||
throw coreutils::Exception("type should not be specified with expr.");
|
throw coreutils::Exception("type should not be specified with expr.");
|
||||||
booleanResult = Operand(keywords["expr"], global, parent->variables).boolean;
|
booleanResult = Operand(keywords["expr"], global, parent->variables, keywords).boolean;
|
||||||
}
|
}
|
||||||
if(booleanResult)
|
if(booleanResult)
|
||||||
processContainer(container);
|
processContainer(container);
|
||||||
|
@ -25,11 +25,11 @@ namespace jet {
|
|||||||
|
|
||||||
if(keywordDefined("expr")) {
|
if(keywordDefined("expr")) {
|
||||||
if(!keywordDefined("scope") || (keywords["scope"] == "global"))
|
if(!keywordDefined("scope") || (keywords["scope"] == "global"))
|
||||||
global.variables[keywords["name"]] = Operand(keywords["expr"], global, parent->variables).string;
|
global.variables[keywords["name"]] = Operand(keywords["expr"], global, parent->variables, keywords).string;
|
||||||
else if(keywords["scope"] == "local")
|
else if(keywords["scope"] == "local")
|
||||||
local->variables[keywords["name"]] = Operand(keywords["expr"], global, parent->variables).string;
|
local->variables[keywords["name"]] = Operand(keywords["expr"], global, parent->variables, keywords).string;
|
||||||
else if(keywords["scope"] == "parent")
|
else if(keywords["scope"] == "parent")
|
||||||
local->parent->variables[keywords["name"]] = Operand(keywords["expr"], global, parent->variables).string;
|
local->parent->variables[keywords["name"]] = Operand(keywords["expr"], global, parent->variables, keywords).string;
|
||||||
} else if(hasContainer) {
|
} else if(hasContainer) {
|
||||||
processContainer(container);
|
processContainer(container);
|
||||||
if(evaluate) {
|
if(evaluate) {
|
||||||
|
@ -47,7 +47,7 @@ namespace jet {
|
|||||||
keywords["expr"].reset();
|
keywords["expr"].reset();
|
||||||
keywords["expr"] = exprSaved;
|
keywords["expr"] = exprSaved;
|
||||||
resolveKeyword("expr");
|
resolveKeyword("expr");
|
||||||
booleanResult = Operand(keywords["expr"], global, parent->variables).boolean;
|
booleanResult = Operand(keywords["expr"], global, parent->variables, keywords).boolean;
|
||||||
} else {
|
} else {
|
||||||
booleanResult = false;
|
booleanResult = false;
|
||||||
int rc = keywords["value1"].compare(keywords["value2"]);
|
int rc = keywords["value1"].compare(keywords["value2"]);
|
||||||
|
@ -39,7 +39,7 @@ namespace jet {
|
|||||||
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 = keywords["expr"];
|
exprSaved = keywords["expr"];
|
||||||
booleanResult = Operand(keywords["expr"], global, parent->variables).boolean;
|
booleanResult = Operand(keywords["expr"], global, parent->variables, keywords).boolean;
|
||||||
}
|
}
|
||||||
while(booleanResult) {
|
while(booleanResult) {
|
||||||
processContainer(container);
|
processContainer(container);
|
||||||
@ -47,7 +47,7 @@ namespace jet {
|
|||||||
if(exprMethod) {
|
if(exprMethod) {
|
||||||
keywords["expr"].reset();
|
keywords["expr"].reset();
|
||||||
keywords["expr"] = exprSaved;
|
keywords["expr"] = exprSaved;
|
||||||
booleanResult = Operand(keywords["expr"], global, parent->variables).boolean;
|
booleanResult = Operand(keywords["expr"], global, parent->variables, keywords).boolean;
|
||||||
} else {
|
} else {
|
||||||
booleanResult = false;
|
booleanResult = false;
|
||||||
int rc = keywords["value1"].compare(keywords["value2"]);
|
int rc = keywords["value1"].compare(keywords["value2"]);
|
||||||
|
@ -14,17 +14,13 @@ modified1=[ABCD]
|
|||||||
multiplication=[15]
|
multiplication=[15]
|
||||||
nested=[64]
|
nested=[64]
|
||||||
newname=[another container value]
|
newname=[another container value]
|
||||||
noeval=[this is the value store in #[name1].]
|
noeval=[this is the value store in $[%name1].]
|
||||||
numbers=[0123456789]
|
numbers=[0123456789]
|
||||||
subtraction=[2]
|
subtraction=[2]
|
||||||
theexpr=[bcd]
|
theexpr=[bcd]
|
||||||
thename=[this is the value store in localname.]
|
thename=[this is the value store in .]
|
||||||
tohex=[tohex]
|
tohex=[tohex]
|
||||||
varname1=[vardata]
|
varname1=[vardata]
|
||||||
*** LOCAL VARIABLES ***
|
*** LOCAL VARIABLES ***
|
||||||
cgi=[true]
|
localvar=[This is a container set with '']
|
||||||
filterblanklines=[true]
|
testinclude=[xThis is a container set with ''x]
|
||||||
localvar=[This is a container set with 'localname']
|
|
||||||
name1=[localname]
|
|
||||||
testinclude=[xThis is a container set with 'localname'x]
|
|
||||||
trimlines=[true]
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<set name="localvar" scope="local">This is a container set with '#[name1]'</set>
|
<set name="localvar" scope="local">This is a container set with '$[%name1]'</set>
|
||||||
This is from an include tag.
|
This is from an include tag.
|
||||||
localname='#[name1]'
|
localname='$[%name1]'
|
||||||
<set name="include" value="yes" />
|
<set name="include" value="yes" />
|
||||||
<set name="testinclude" value="x#[localvar]x" scope="local" />
|
<set name="testinclude" value="x#[localvar]x" scope="local" />
|
||||||
test='#[testinclude]'
|
test='#[testinclude]'
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<header name="Content-Type" value="text/html" />
|
<header name="Content-Type" value="text/html" />
|
||||||
<comment>This is a comment and should not show up in the output.</comment>
|
<comment>This is a comment and should not show up in the output.</comment>
|
||||||
<html>
|
<html>
|
||||||
---#[name1]
|
---$[%name1]
|
||||||
<set name="modified1" value="ABCD" />
|
<set name="modified1" value="ABCD" />
|
||||||
$[modified1;tohex]
|
$[modified1;tohex]
|
||||||
<set name="tohex" value="tohex" />
|
<set name="tohex" value="tohex" />
|
||||||
@ -37,12 +37,12 @@
|
|||||||
5*3($[multiplication])
|
5*3($[multiplication])
|
||||||
5/3($[division])
|
5/3($[division])
|
||||||
<set name="varname$[ix]" value="vardata" scope="global" />
|
<set name="varname$[ix]" value="vardata" scope="global" />
|
||||||
<set name="noeval" eval="no">this is the value store in #[name1].</set>
|
<set name="noeval" eval="no">this is the value store in $[%name1].</set>
|
||||||
<set name="thename" eval="yes">this is the value store in #[name1].</set>
|
<set name="thename" eval="yes">this is the value store in $[%name1].</set>
|
||||||
<set name="newname" scope="global">another container value</set>
|
<set name="newname" scope="global">another container value</set>
|
||||||
<include file="./testinclude.jet" />
|
<comment><include file="./testinclude.jet" />
|
||||||
include: $[include]
|
include: $[include]
|
||||||
localvar='#[localvar]'
|
localvar='#[localvar]'</comment>
|
||||||
>>>$[noeval]<<<
|
>>>$[noeval]<<<
|
||||||
>>>$[thename]<<<
|
>>>$[thename]<<<
|
||||||
<set name="iz" value="data" />
|
<set name="iz" value="data" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!../jet-2.0
|
#!../jet-2.0
|
||||||
<jet name1="localhost" filterblanklines="true" trimlines="true">
|
<jet name1="localhost" filterblanklines="true" trimlines="true">
|
||||||
<set name="test1" value="#[name1]" />
|
<set name="test1" value="$[%name1]" />
|
||||||
test1=[$[test1]]
|
test1=[$[test1]]
|
||||||
<set name="ix" value="1" />
|
<set name="ix" value="1" />
|
||||||
<set name="letterx" value="x" />
|
<set name="letterx" value="x" />
|
||||||
@ -8,7 +8,7 @@ test1=[$[test1]]
|
|||||||
<set name="1var1" value="This is another test" />
|
<set name="1var1" value="This is another test" />
|
||||||
<set name="var1var" value="Yet another test" />
|
<set name="var1var" value="Yet another test" />
|
||||||
<set name="var11" value="it seems to work." />
|
<set name="var11" value="it seems to work." />
|
||||||
name1=[#[name1]]
|
name1=[$[%name1]]
|
||||||
$[$[ix]var$[ix];tobinary]
|
$[$[ix]var$[ix];tobinary]
|
||||||
$[var$[ix]]
|
$[var$[ix]]
|
||||||
$[var$[ix]var]
|
$[var$[ix]var]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user