Add a "inverseLCharacter" static function to tok

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-02-08 18:31:00 +01:00
parent 7cbb424416
commit de2259b6ed
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 4 additions and 1 deletions

View File

@ -17,6 +17,9 @@ struct tok {
LCOMP = '>', RCOMP = '<',
SQUOTE = '\'', ASTERISK = '*', STRING = '"',
};
static auto inverseLCharacter(const unsigned char& character) {
return static_cast<unsigned char>(((character + 2) - (character == tok::LPAR)));
};
const type toktype;
const std::string toktext;
const unsigned long line;

View File

@ -62,7 +62,7 @@ namespace Parser {
break;
}
case LPAR: case LBRACE: case LBRACKET: {
const auto inverseCharacter = static_cast<tok::type>((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;
});