Parser.hpp: Shorten two "if" statements

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-05-26 13:33:14 +02:00
parent 46a09217fe
commit 7ebf0ab5a4
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 3 additions and 7 deletions

View File

@ -89,9 +89,8 @@ namespace Parser {
} }
if (nextAre({LCOMP, LCOMP, LBRACE})) { if (nextAre({LCOMP, LCOMP, LBRACE})) {
Function function(current.toktext); Function function(current.toktext);
if (parametersDistance > 2) { if (parametersDistance > 2)
function.parameters = parse(filter_comma_list(lexed.begin() + ((i + 2) - parametersDistance), lexed.begin() + i)); function.parameters = parse(filter_comma_list(lexed.begin() + ((i + 2) - parametersDistance), lexed.begin() + i));
}
parseTree << function; parseTree << function;
i += 2; i += 2;
break; break;
@ -100,11 +99,8 @@ namespace Parser {
bool isFinalDefine = nextAre({TAG, DEFINE}); bool isFinalDefine = nextAre({TAG, DEFINE});
if (isFinalDefine || next.toktype == DEFINE) { if (isFinalDefine || next.toktype == DEFINE) {
const optional previousDefinition = parseTree.template findReferenceByName<Define>(current.toktext); const optional previousDefinition = parseTree.template findReferenceByName<Define>(current.toktext);
if (previousDefinition.has_value()) { if (previousDefinition.has_value() && (previousDefinition.value().get().final || isFinalDefine))
if (previousDefinition.value().get().final || isFinalDefine) { parsingError(current, previousDefinition->get().final ? " cannot be redefined as it is final" : " cannot be made final after it has been declared", true);
parsingError(current, previousDefinition->get().final ? " cannot be redefined as it is final" : " cannot be made final after it has been declared", true);
}
}
const unsigned increment = 2 + isFinalDefine; const unsigned increment = 2 + isFinalDefine;
const auto beginning = lexed.begin() + i + increment; const auto beginning = lexed.begin() + i + increment;
const auto end = find_if(beginning, lexed.end(), [&current](const tok& it){ const auto end = find_if(beginning, lexed.end(), [&current](const tok& it){