Added VarAssign, VarAccess and MultiNode

This commit is contained in:
Pasha Bibko
2025-04-28 19:59:45 +01:00
parent d8773d4020
commit 3ec6cc0c6e
7 changed files with 186 additions and 20 deletions

View File

@@ -4,9 +4,9 @@
namespace LX::AST
{
void Node::Log(std::ofstream* log, unsigned depth)
void MultiNode::Log(std::ofstream* log, unsigned depth)
{
(*log) << std::string(depth, '\t') << "NULL node";
throw int(); // <- TODO: Make an error for this
}
void NumberLiteral::Log(std::ofstream* log, unsigned depth)
@@ -46,4 +46,19 @@ namespace LX::AST
(*log) << std::string(depth, '\t');
(*log) << "Variable declaration: " << m_Name << "\n";
}
void VariableAssignment::Log(std::ofstream* log, unsigned depth)
{
(*log) << std::string(depth, '\t');
(*log) << "Variable assignment:\n";
(*log) << std::string(depth + 1, '\t') << "To: " << m_Name << "\n";
(*log) << std::string(depth + 1, '\t') << "Value:\n";
m_Value.get()->Log(log, depth + 2);
}
void VariableAccess::Log(std::ofstream* log, unsigned depth)
{
(*log) << std::string(depth, '\t');
(*log) << "Variable: " << m_Name << '\n';
}
}