Updated logging

This commit is contained in:
Pasha Bibko
2025-07-20 14:50:50 +01:00
parent ac656b7b0f
commit f5bb46788c
3 changed files with 48 additions and 16 deletions

View File

@@ -7,31 +7,28 @@ int main(int argc, char** argv)
using namespace LXC;
// Reads the given file to a string //
Util::ReturnVal fileContents = Util::ReadFile("example/example.jk.lx");
if (fileContents.Failed())
Util::ReturnVal fileContents = Util::ReadFile("example/example.lx");
if (fileContents.Failed()) _UNLIKELY
{
// Stores the error for easier access //
Util::FileReadError& err = fileContents.Error();
// Prints the error to the console //
Util::PrintAs<Util::Color::WHITE>("[LXC]");
Util::PrintAs<Util::Color::LIGHT_RED>(" Error: ");
Util::PrintAs<Util::WHITE>("[LXC]");
Util::PrintAs<Util::LIGHT_RED>(" Error: ");
Util::PrintLn(Util::FileReadError::ReasonStr(err.reason), " [", std::filesystem::absolute(err.path), ']');
std::cout
<< Util::FileReadError::ReasonStr(err.reason) << ' '
<< '[' << std::filesystem::absolute(err.path) << ']'
<< std::endl;
// Returns with default exit code //
return -1;
Util::Stop();
}
// Turns the file contents into a vector of tokens //
Util::ReturnVal tokens = Lexer::TokenizeFile(fileContents);
if (tokens.Failed())
if (tokens.Failed()) _UNLIKELY
{
// Returns with default error code //
return -1;
// Stores the error for easier access //
Lexer::LexerError& err = tokens.Error();
Util::Stop();
}
return 0;