mirror of
https://github.com/hyprwm/hyprlang.git
synced 2025-05-12 21:30:37 +01:00
Merge 7499aef331
into 557241780c
This commit is contained in:
commit
d3b5db8a3d
1 changed files with 23 additions and 2 deletions
|
@ -642,10 +642,22 @@ CParseResult CConfig::parseLine(std::string line, bool dynamic) {
|
|||
anyMatch = true;
|
||||
}
|
||||
|
||||
// parse expressions $(somevar + 2)
|
||||
// parse expressions {{somevar + 2}}
|
||||
// We only support single expressions for now
|
||||
while (RHS.contains("{{")) {
|
||||
const auto BEGIN_EXPR = RHS.find("{{");
|
||||
auto firstUnescaped = RHS.find("{{");
|
||||
//keep searching until the escape char is not found.
|
||||
while(firstUnescaped != 0 && RHS.at(firstUnescaped - 1) == '\\'){
|
||||
firstUnescaped = RHS.find("{{", firstUnescaped + 1);
|
||||
//break if the next match is never found
|
||||
if(firstUnescaped == std::string::npos)
|
||||
break;
|
||||
}
|
||||
//real match was never found.
|
||||
if(firstUnescaped == std::string::npos)
|
||||
break;
|
||||
const auto BEGIN_EXPR = firstUnescaped;
|
||||
// }} doesnt need escaping. Would be invalid expression anyways.
|
||||
const auto END_EXPR = RHS.find("}}", BEGIN_EXPR + 2);
|
||||
if (END_EXPR != std::string::npos) {
|
||||
// try to parse the expression
|
||||
|
@ -669,6 +681,15 @@ CParseResult CConfig::parseLine(std::string line, bool dynamic) {
|
|||
}
|
||||
}
|
||||
|
||||
// Removing escape chars. -- in the future, maybe map all the chars that can be escaped.
|
||||
// Right now only expression parsing has escapeable chars
|
||||
for(long i = 0; i < (long)RHS.length()-(long)1; i++){
|
||||
if(RHS.at(i) == '\\' && (RHS.at(i+1) == '{' || RHS.at(i+1) == '}')){
|
||||
RHS.erase(i--, 1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (ISVARIABLE)
|
||||
return parseVariable(LHS, RHS, dynamic);
|
||||
|
||||
|
|
Loading…
Reference in a new issue