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){