mirror of
https://github.com/PashaBibko/LX.git
synced 2026-04-04 01:49:05 +00:00
Improved syntax for functions
Added logging system for AST nodes as well.
This commit is contained in:
@@ -81,6 +81,8 @@ namespace LX
|
||||
OPEN_BRACE, CLOSE_BRACE,
|
||||
OPEN_PAREN, CLOSE_PAREN,
|
||||
|
||||
COMMA,
|
||||
|
||||
// Operators //
|
||||
|
||||
ADD, SUB, MUL, DIV,
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace LX::AST
|
||||
{
|
||||
// General Nodes //
|
||||
|
||||
IDENTIFIER,
|
||||
NUMBER_LITERAL,
|
||||
OPERATION,
|
||||
|
||||
@@ -48,6 +47,9 @@ namespace LX::AST
|
||||
// Function for generating LLVN IR (Intermediate representation) //
|
||||
virtual llvm::Value* GenIR(InfoLLVM& LLVM) = 0;
|
||||
|
||||
// Function to log the node to a file //
|
||||
virtual void Log(std::ofstream* log, unsigned depth) = 0;
|
||||
|
||||
// Function for generating C/C++ code (Currently not implemented) //
|
||||
//virtual void GenC() = 0;
|
||||
|
||||
|
||||
@@ -178,9 +178,11 @@ int main(int argc, char** argv)
|
||||
LX::PrintStringAsColor("Error: ", LX::Color::LIGHT_RED);
|
||||
std::cout << "Invalid character found in ";
|
||||
LX::PrintStringAsColor(inpPath.filename().string(), LX::Color::WHITE);
|
||||
std::cout << ":\n";
|
||||
std::cout << " {";
|
||||
LX::PrintStringAsColor(std::string(1, e.invalid), LX::Color::LIGHT_RED);
|
||||
std::cout << "}:\n";
|
||||
std::cout << "Line: " << std::setw(lineNumberWidthInConsole) << e.line << " | " << line << "\n";
|
||||
std::cout << " " << std::setw(lineNumberWidthInConsole) << "" << " | " << std::setw(e.col);
|
||||
std::cout << " " << std::setw(lineNumberWidthInConsole) << "" << " | " << std::setw(e.col + 1);
|
||||
LX::PrintStringAsColor("^", LX::Color::LIGHT_RED);
|
||||
std::cout << "\n";
|
||||
|
||||
@@ -215,7 +217,7 @@ int main(int argc, char** argv)
|
||||
// Prints the code with the error to the console //
|
||||
std::string errorSquiggle(e.got.length, '~');
|
||||
std::cout << "Line: " << std::setw(lineNumberWidthInConsole) << e.got.line << " | " << line << "\n";
|
||||
std::cout << " " << std::setw(lineNumberWidthInConsole) << "" << " | " << std::setw(e.got.column) << "";
|
||||
std::cout << " " << std::setw(lineNumberWidthInConsole) << "" << " | " << std::setw(e.got.column + 1) << "";
|
||||
LX::PrintStringAsColor(errorSquiggle, LX::Color::LIGHT_RED);
|
||||
std::cout << "\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user