patterns: Fixed multiple parse and evaluate issues

This commit is contained in:
WerWolv
2021-06-22 16:04:47 +02:00
parent fde5b39495
commit 1e1cdb0ef0
3 changed files with 9 additions and 3 deletions

View File

@@ -113,7 +113,8 @@ namespace hex::lang {
PatternData *currPattern = nullptr;
// Local variable access
currPattern = this->findPattern(*this->m_localVariables.back(), path);
if (!this->m_localVariables.empty())
currPattern = this->findPattern(*this->m_localVariables.back(), path);
// If no local variable was found try local structure members
if (this->m_currMembers.size() > 1) {

View File

@@ -365,7 +365,8 @@ namespace hex::lang {
std::vector<std::string> params;
// Parse parameter list
while (MATCHES(sequence(IDENTIFIER))) {
bool hasParams = MATCHES(sequence(IDENTIFIER));
while (hasParams) {
params.push_back(getValue<std::string>(-1));
if (!MATCHES(sequence(SEPARATOR_COMMA))) {
@@ -375,6 +376,10 @@ namespace hex::lang {
throwParseError("expected closing ')' after parameter list");
}
}
if (!hasParams) {
if (!MATCHES(sequence(SEPARATOR_ROUNDBRACKETCLOSE)))
throwParseError("expected closing ')' after parameter list");
}
if (!MATCHES(sequence(SEPARATOR_CURLYBRACKETOPEN)))
throwParseError("expected opening '{' after function definition");