Made $[%name] to retrieve keyword values in a tag. Has bugs.
This commit is contained in:
1 parent
9622b5cf8c
commit
f6dda8496c
17 files changed
+85
-64
No files matched your search
+18
-10
@@ -59,15 +59,20 @@ namespace jet {
|
||||
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("$[")) {
|
||||
coreutils::MString name;
|
||||
coreutils::MString modifier;
|
||||
if(variable.ifNext("!")) {
|
||||
renderVariableName(variable, name, modifier, lvariables);
|
||||
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||
return variables[name];
|
||||
} if(variable.ifNext(":")) {
|
||||
renderVariableName(variable, name, modifier, lvariables);
|
||||
} else if(variable.ifNext("%")) {
|
||||
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||
return keywords[name];
|
||||
} else if(variable.ifNext(":")) {
|
||||
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||
if(name.find(":") == -1) {
|
||||
name << ":0";
|
||||
}
|
||||
@@ -75,10 +80,10 @@ namespace jet {
|
||||
} if(variable.ifNext("@")) {
|
||||
// TODO: should only allow session variables. Allow substitution.
|
||||
} if(variable.ifNext("%")) {
|
||||
renderVariableName(variable, name, modifier, lvariables);
|
||||
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||
return getenv(name.c_str());
|
||||
} else {
|
||||
renderVariableName(variable, name, modifier, lvariables);
|
||||
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||
name.split(".");
|
||||
if(name.getList().size() == 1) {
|
||||
if(variables.find(name[0]) == variables.end())
|
||||
@@ -91,7 +96,7 @@ namespace jet {
|
||||
} if(variable.ifNext("#[")) {
|
||||
coreutils::MString name;
|
||||
coreutils::MString modifier;
|
||||
renderVariableName(variable, name, modifier, lvariables);
|
||||
renderVariableName(variable, name, modifier, lvariables, keywords);
|
||||
if(lvariables.find(name) == lvariables.end())
|
||||
throw coreutils::Exception("local variable is not initialized.");
|
||||
return lvariables[name];
|
||||
@@ -99,16 +104,19 @@ namespace jet {
|
||||
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("]")) {
|
||||
name << variable.getTokenInclude("?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
|
||||
if(variable.ifNext(";")) {
|
||||
renderVariableName(variable, modifier, modifier, lvariables);
|
||||
renderVariableName(variable, modifier, modifier, lvariables, keywords);
|
||||
return;
|
||||
} else if(variable.ifNext(":")) {
|
||||
name << ":";
|
||||
} else if(variable.startsWith("$[") || variable.startsWith("#[")) {
|
||||
name << getVariable(variable, lvariables);
|
||||
name << getVariable(variable, lvariables, keywords);
|
||||
} else if(variable.ifNext("]"))
|
||||
return;
|
||||
else if(!variable.ifNextInclude("?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"))
|
||||
|
||||
Reference in new issue
Block a user