Tabs -> Spaces
This commit is contained in:
92
LXC/LXC.cpp
92
LXC/LXC.cpp
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user