From de2259b6ed8d226659093f3c2a8514530dc0b06a Mon Sep 17 00:00:00 2001 From: Username404 Date: Tue, 8 Feb 2022 18:31:00 +0100 Subject: [PATCH] Add a "inverseLCharacter" static function to tok Signed-off-by: Username404 --- src/headers/lex.hpp | 3 +++ src/headers/parsing/Parser.hpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/headers/lex.hpp b/src/headers/lex.hpp index 9487289..635b4be 100644 --- a/src/headers/lex.hpp +++ b/src/headers/lex.hpp @@ -17,6 +17,9 @@ struct tok { LCOMP = '>', RCOMP = '<', SQUOTE = '\'', ASTERISK = '*', STRING = '"', }; + static auto inverseLCharacter(const unsigned char& character) { + return static_cast(((character + 2) - (character == tok::LPAR))); + }; const type toktype; const std::string toktext; const unsigned long line; diff --git a/src/headers/parsing/Parser.hpp b/src/headers/parsing/Parser.hpp index 957d955..f3b09ee 100644 --- a/src/headers/parsing/Parser.hpp +++ b/src/headers/parsing/Parser.hpp @@ -62,7 +62,7 @@ namespace Parser { break; } case LPAR: case LBRACE: case LBRACKET: { - const auto inverseCharacter = static_cast((current.toktype + 2) - (current.toktype == LPAR)); + const auto inverseCharacter = tok::inverseLCharacter(current.toktype); const auto closingCharacter = find_if(lexed.cbegin(), lexed.cend(), [&inverseCharacter](const tok& it){ return it.toktype == inverseCharacter; });