From 8772be9d5c5def55ddd8e8b86c7f87038b9f5114 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Sat, 6 Mar 2021 13:38:26 +0100 Subject: [PATCH] Use a switch-case expression instead of an if statement in lexer.cpp. --- src/etc/lexer.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/etc/lexer.cpp b/src/etc/lexer.cpp index b5cd636..8cdcc34 100644 --- a/src/etc/lexer.cpp +++ b/src/etc/lexer.cpp @@ -63,9 +63,14 @@ vector& lex(const string& in) } } else { tok::type currentType = getIdentifierCharType(current); - if ((currentType == tok::STRING) || ((currentType == tok::UNEXPECTED) && ((generated.first == tok::IDENTIFIER) || (generated.first == tok::NUMBER)))) { - longLex = false; - } else generated.second.append(string(1, current)); + switch (currentType) { + case tok::UNEXPECTED: if ((generated.first == currentType) || (generated.first == tok::STRING)) break; + case tok::STRING: { + longLex = false; + break; + } + default: generated.second.append(string(1, current)); break; + } } } /* Test