add else statements using '*'
parent
429b39cf08
commit
a3b1d3b9d8
|
@ -4,12 +4,11 @@
|
|||
<li class="left"><a id="research" href="/research.html">Research</a></li>
|
||||
<li class="left"><a id="git" href="/git.html">Git</a></li>
|
||||
<li class="left"><a id='about' href="/about.html">About</a></li>
|
||||
{{#_logged_in}}
|
||||
{{%_logged_in}}
|
||||
<li class="right"><a href="/logout.html">Logout</a></li>
|
||||
{{/_logged_in}}
|
||||
{{#_not_logged_in}}
|
||||
{{*_logged_in}}
|
||||
<li class="right"><a id='login' href="/login.html">Login</a></li>
|
||||
{{/_not_logged_in}}
|
||||
{{/_logged_in}}
|
||||
</ul>
|
||||
<script>
|
||||
const path = window.location.pathname;
|
||||
|
|
|
@ -119,8 +119,10 @@ namespace cs
|
|||
CLOSE // )
|
||||
};
|
||||
|
||||
static std::string decodeName(TokenType type){
|
||||
switch (type){
|
||||
static std::string decodeName(TokenType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TokenType::AND:
|
||||
return "AND";
|
||||
case TokenType::OR:
|
||||
|
@ -227,13 +229,15 @@ namespace cs
|
|||
//BLT_DEBUG("isTrue for token '%s' contains? %s", token.c_str(), context.contains(token) ? "True" : "False");
|
||||
return context.contains(token) && !context.at(token).empty();
|
||||
}
|
||||
|
||||
// http://www.cs.unb.ca/~wdu/cs4613/a2ans.htm
|
||||
bool factor(const RuntimeContext& context)
|
||||
{
|
||||
if (!hasNextToken())
|
||||
blt_throw(LexerSyntaxError("Processing boolean factor but no token was found!"));
|
||||
auto next = consumeToken();
|
||||
switch (next.type){
|
||||
switch (next.type)
|
||||
{
|
||||
case TokenType::IDENT:
|
||||
if (!next.value.has_value())
|
||||
blt_throw(LexerSyntaxError("Token identifier does not have a value!"));
|
||||
|
@ -258,7 +262,8 @@ namespace cs
|
|||
if (!hasNextToken())
|
||||
return fac;
|
||||
auto next = consumeToken();
|
||||
switch (next.type) {
|
||||
switch (next.type)
|
||||
{
|
||||
case TokenType::AND:
|
||||
return fac && expr(context);
|
||||
case TokenType::OR:
|
||||
|
@ -298,11 +303,12 @@ namespace cs
|
|||
|
||||
}
|
||||
|
||||
static void getTagLocations(std::vector<size_t>& tagLocations, const std::string& tag, const std::string& data){
|
||||
static void getTagLocations(std::vector<size_t>& tagLocations, const std::string& tag, const std::string& data)
|
||||
{
|
||||
RuntimeLexer lexer(data);
|
||||
while (lexer.hasNext())
|
||||
{
|
||||
if (lexer.hasTemplatePrefix('/'))
|
||||
if (lexer.hasTemplatePrefix('/') || lexer.hasTemplatePrefix('*'))
|
||||
{
|
||||
auto loc = lexer.index;
|
||||
auto token = lexer.consumeToken();
|
||||
|
@ -312,7 +318,7 @@ namespace cs
|
|||
lexer.consume();
|
||||
}
|
||||
if (tagLocations.empty())
|
||||
blt_throw( LexerSearchFailure(tag));
|
||||
blt_throw(LexerSearchFailure(tag));
|
||||
}
|
||||
|
||||
static size_t findLastTagLocation(const std::string& tag, const std::string& data)
|
||||
|
@ -322,7 +328,8 @@ namespace cs
|
|||
return tagLocations[tagLocations.size() - 1];
|
||||
}
|
||||
|
||||
static size_t findNextTagLocation(const std::string& tag, const std::string& data) {
|
||||
static size_t findNextTagLocation(const std::string& tag, const std::string& data)
|
||||
{
|
||||
std::vector<size_t> tagLocations{};
|
||||
getTagLocations(tagLocations, tag, data);
|
||||
return tagLocations[0];
|
||||
|
@ -342,17 +349,31 @@ namespace cs
|
|||
auto internalData = searchField.substr(0, endTokenLoc);
|
||||
|
||||
LogicalEval eval(token);
|
||||
bool expressionValue = eval.eval(context);
|
||||
|
||||
if (eval.eval(context)) {
|
||||
if (expressionValue)
|
||||
{
|
||||
results += searchAndReplace(internalData, context);
|
||||
}
|
||||
|
||||
lexer.index += endTokenLoc;
|
||||
if (lexer.hasTemplatePrefix('*'))
|
||||
{
|
||||
lexer.consumeToken();
|
||||
auto nextSearchField = lexer.str.substr(lexer.index);
|
||||
auto nextEndLoc = RuntimeLexer::findNextTagLocation(token, nextSearchField);
|
||||
auto nextInternalData = nextSearchField.substr(0, nextEndLoc);
|
||||
|
||||
if (!expressionValue)
|
||||
{
|
||||
results += searchAndReplace(nextInternalData, context);
|
||||
}
|
||||
lexer.index += nextEndLoc;
|
||||
}
|
||||
if (lexer.hasTemplatePrefix('/'))
|
||||
lexer.consumeToken();
|
||||
else {
|
||||
else
|
||||
blt_throw(LexerSyntaxError("Ending token not found!"));
|
||||
}
|
||||
|
||||
} else
|
||||
results += lexer.consume();
|
||||
|
@ -479,7 +500,8 @@ namespace cs
|
|||
while (prunedAmount < amount)
|
||||
{
|
||||
auto page = cachedPages[0];
|
||||
BLT_TRACE("Pruning page (%d bytes) aged %f seconds", page.memoryUsage,
|
||||
BLT_TRACE(
|
||||
"Pruning page (%d bytes) aged %f seconds", page.memoryUsage,
|
||||
toSeconds(blt::system::getCurrentTimeNanoseconds() - m_Pages[page.key].cacheTime));
|
||||
prunedAmount += page.memoryUsage;
|
||||
m_Pages.erase(page.key);
|
||||
|
|
Loading…
Reference in New Issue