Don't throw an exception when "isTypeString" is false in lexer.cpp

This commit is contained in:
Username404 2021-09-14 20:20:34 +02:00
parent 4201e3bcfb
commit 44e160ebf9
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 4 additions and 3 deletions

View File

@ -34,7 +34,7 @@ vector<tok> lex(const string& in)
for (;i < in.size(); ++i) {
const tok::type currentCharType = getIdentifierCharType(in[i]);
const bool isString = currentCharType == STRING;
if (i == in.size() - 1 && not isString) throw tok::LexerException("A never ending string was found", lineNumber);
if (isTypeString && (i == in.size() - 1 && not isString)) throw tok::LexerException("A never ending string was found", lineNumber);
if ((currentCharType == type || isTypeString) && !isString) {
formedString += string(1, in[i]);
} else {

View File

@ -69,10 +69,11 @@ int main(int argc, char* argv[]) {
for (future<pair<string, optional<Yerbacon::Exception>>>& currentFuture: Units) {
const auto&& result = currentFuture.get();
if (not result.second.has_value()) {
if (printResult) cout << result.first << "\n\n";
if (printResult) cout << result.first;
} else {
cout << "Compilation of " << result.first << " has failed with the following error:\n" << result.second.value().what() << "\n\n";
cout << "Compilation of " << result.first << " has failed with the following error:\n" << result.second.value().what();
}
cout << "\n\n";
}
} else cout << "No valid file provided.\n";
}