Tabs -> Spaces

This commit is contained in:
Pasha Bibko
2025-07-21 17:39:43 +01:00
parent 24fde1b770
commit 5bfeb75536
10 changed files with 514 additions and 515 deletions

View File

@@ -4,64 +4,64 @@
int main(int argc, char** argv)
{
using namespace LXC;
using namespace LXC;
// Creates the debug log //
Util::CreateLog("LXC.log");
// Creates the debug log //
Util::CreateLog("LXC.log");
std::filesystem::path src = "example/example.lx";
std::filesystem::path src = "example/example.lx";
// Reads the given file to a string //
Util::ReturnVal fileContents = Util::ReadFile(src);
if (fileContents.Failed()) _UNLIKELY
{
// Stores the error for easier access //
Util::FileReadError& err = fileContents.Error();
// Reads the given file to a string //
Util::ReturnVal fileContents = Util::ReadFile(src);
if (fileContents.Failed()) _UNLIKELY
{
// Stores the error for easier access //
Util::FileReadError& err = fileContents.Error();
// Prints the error to the console //
Util::PrintAs<Util::WHITE>("[LXC]");
Util::PrintAs<Util::LIGHT_RED>(" Error: ");
Util::PrintLn(Util::FileReadError::ReasonStr(err.reason), " [", std::filesystem::absolute(err.path), ']');
// Prints the error to the console //
Util::PrintAs<Util::WHITE>("[LXC]");
Util::PrintAs<Util::LIGHT_RED>(" Error: ");
Util::PrintLn(Util::FileReadError::ReasonStr(err.reason), " [", std::filesystem::absolute(err.path), ']');
Util::Log("Opening source file failed. Stopping program.");
Util::Stop();
}
Util::Log("Opening source file failed. Stopping program.");
Util::Stop();
}
// Turns the file contents into a vector of tokens //
Util::ReturnVal tokens = Lexer::TokenizeFile(fileContents);
if (tokens.Failed()) _UNLIKELY
{
// Stores the error for easier access //
Lexer::LexerError& err = tokens.Error();
// Turns the file contents into a vector of tokens //
Util::ReturnVal tokens = Lexer::TokenizeFile(fileContents);
if (tokens.Failed()) _UNLIKELY
{
// Stores the error for easier access //
Lexer::LexerError& err = tokens.Error();
// Finds the file location of the error //
Util::FileLocation location;
Util::GetFileLocationAtIndex(location, fileContents, err.index);
// Finds the file location of the error //
Util::FileLocation location;
Util::GetFileLocationAtIndex(location, fileContents, err.index);
// Prints the error to the console //
Util::PrintAs<Util::WHITE>("[LXC] ");
Util::Print(src.filename().string(), '(', location.line, ',', location.col, ')');
Util::PrintAs<Util::LIGHT_RED>(" Error: ");
Util::Print(Lexer::LexerError::ReasonStr(err.reason));
// Prints the error to the console //
Util::PrintAs<Util::WHITE>("[LXC] ");
Util::Print(src.filename().string(), '(', location.line, ',', location.col, ')');
Util::PrintAs<Util::LIGHT_RED>(" Error: ");
Util::Print(Lexer::LexerError::ReasonStr(err.reason));
if (err.reason == Lexer::LexerError::InvalidCharacter)
Util::PrintLn(": {", fileContents.Result()[err.index], '}');
if (err.reason == Lexer::LexerError::InvalidCharacter)
Util::PrintLn(": {", fileContents.Result()[err.index], '}');
if (err.reason == Lexer::LexerError::UnknownSymbolOrOperand)
Util::PrintLn(": {", err.info, '}');
if (err.reason == Lexer::LexerError::UnknownSymbolOrOperand)
Util::PrintLn(": {", err.info, '}');
else
Util::PrintLn();
else
Util::PrintLn();
Util::Log("Error occured in Lexer: ", Lexer::LexerError::ReasonStr(err.reason));
Util::Stop();
}
Util::Log("Error occured in Lexer: ", Lexer::LexerError::ReasonStr(err.reason));
Util::Stop();
}
// Prints all of the tokens to the log //
for (const auto& token : tokens.Result())
{
Util::Log(token);
}
// Prints all of the tokens to the log //
for (const auto& token : tokens.Result())
{
Util::Log(token);
}
return 0;
return 0;
}