From 7ebf0ab5a4c5822e6f3e89aeac62df81d43ff518 Mon Sep 17 00:00:00 2001 From: Username404 Date: Thu, 26 May 2022 13:33:14 +0200 Subject: [PATCH] Parser.hpp: Shorten two "if" statements Signed-off-by: Username404 --- src/headers/parsing/Parser.hpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/headers/parsing/Parser.hpp b/src/headers/parsing/Parser.hpp index c69e239..1d7f58c 100644 --- a/src/headers/parsing/Parser.hpp +++ b/src/headers/parsing/Parser.hpp @@ -89,9 +89,8 @@ namespace Parser { } if (nextAre({LCOMP, LCOMP, LBRACE})) { Function function(current.toktext); - if (parametersDistance > 2) { + if (parametersDistance > 2) function.parameters = parse(filter_comma_list(lexed.begin() + ((i + 2) - parametersDistance), lexed.begin() + i)); - } parseTree << function; i += 2; break; @@ -100,11 +99,8 @@ namespace Parser { bool isFinalDefine = nextAre({TAG, DEFINE}); if (isFinalDefine || next.toktype == DEFINE) { const optional previousDefinition = parseTree.template findReferenceByName(current.toktext); - if (previousDefinition.has_value()) { - 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); - } - } + if (previousDefinition.has_value() && (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); const unsigned increment = 2 + isFinalDefine; const auto beginning = lexed.begin() + i + increment; const auto end = find_if(beginning, lexed.end(), [¤t](const tok& it){