Split code generation from the ui

This commit is contained in:
2024-03-07 09:15:11 +01:00
parent 4dbf3ddb47
commit fe805ca893
26 changed files with 279 additions and 336 deletions

View File

@ -1,9 +1,7 @@
#include "elna/source/parser.hpp"
#include <stdexcept>
namespace elna
{
namespace source
namespace elna::source
{
/**
* AST node.
@ -67,17 +65,17 @@ namespace source
return m_number;
}
variable::variable(const std::string& name)
variable_expression::variable_expression(const std::string& name)
: m_name(name)
{
}
void variable::accept(ParserVisitor *visitor)
void variable_expression::accept(ParserVisitor *visitor)
{
visitor->visit(this);
}
const std::string& variable::name() const noexcept
const std::string& variable_expression::name() const noexcept
{
return m_name;
}
@ -154,7 +152,7 @@ namespace source
{
if (tokens->of() == source::token::type::identifier)
{
auto result = std::make_unique<variable>(tokens->identifier());
auto result = std::make_unique<variable_expression>(tokens->identifier());
++tokens;
return result;
}
@ -291,4 +289,3 @@ namespace source
return std::make_unique<block>(std::move(definitions), std::move(parsed_statement));
}
}
}