Add lexer and parser sources
This commit is contained in:
50
boot/ast.cc
50
boot/ast.cc
@ -225,7 +225,7 @@ namespace elna::boot
|
||||
|
||||
variable_declaration::variable_declaration(const struct position position, identifier_definition identifier,
|
||||
std::shared_ptr<type_expression> variable_type)
|
||||
: definition(position, identifier), m_variable_type(variable_type)
|
||||
: declaration(position, identifier), m_variable_type(variable_type)
|
||||
{
|
||||
}
|
||||
|
||||
@ -239,28 +239,28 @@ namespace elna::boot
|
||||
return *m_variable_type;
|
||||
}
|
||||
|
||||
definition::definition(const struct position position, identifier_definition identifier)
|
||||
declaration::declaration(const struct position position, identifier_definition identifier)
|
||||
: node(position), identifier(identifier)
|
||||
{
|
||||
}
|
||||
|
||||
constant_definition::constant_definition(const struct position position, identifier_definition identifier,
|
||||
constant_declaration::constant_declaration(const struct position position, identifier_definition identifier,
|
||||
expression *body)
|
||||
: definition(position, identifier), m_body(body)
|
||||
: declaration(position, identifier), m_body(body)
|
||||
{
|
||||
}
|
||||
|
||||
void constant_definition::accept(parser_visitor *visitor)
|
||||
void constant_declaration::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
expression& constant_definition::body()
|
||||
expression& constant_declaration::body()
|
||||
{
|
||||
return *m_body;
|
||||
}
|
||||
|
||||
constant_definition::~constant_definition()
|
||||
constant_declaration::~constant_declaration()
|
||||
{
|
||||
delete m_body;
|
||||
}
|
||||
@ -307,55 +307,55 @@ namespace elna::boot
|
||||
return this;
|
||||
}
|
||||
|
||||
procedure_definition::procedure_definition(const struct position position, identifier_definition identifier,
|
||||
procedure_declaration::procedure_declaration(const struct position position, identifier_definition identifier,
|
||||
procedure_type_expression *heading, block&& body)
|
||||
: definition(position, identifier), m_heading(heading), body(std::move(body))
|
||||
: declaration(position, identifier), m_heading(heading), body(std::move(body))
|
||||
{
|
||||
}
|
||||
|
||||
procedure_definition::procedure_definition(const struct position position, identifier_definition identifier,
|
||||
procedure_declaration::procedure_declaration(const struct position position, identifier_definition identifier,
|
||||
procedure_type_expression *heading)
|
||||
: definition(position, identifier), m_heading(heading), body(std::nullopt)
|
||||
: declaration(position, identifier), m_heading(heading), body(std::nullopt)
|
||||
{
|
||||
}
|
||||
|
||||
void procedure_definition::accept(parser_visitor *visitor)
|
||||
void procedure_declaration::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
procedure_type_expression& procedure_definition::heading()
|
||||
procedure_type_expression& procedure_declaration::heading()
|
||||
{
|
||||
return *m_heading;
|
||||
}
|
||||
|
||||
procedure_definition::~procedure_definition()
|
||||
procedure_declaration::~procedure_declaration()
|
||||
{
|
||||
delete m_heading;
|
||||
}
|
||||
|
||||
type_definition::type_definition(const struct position position, identifier_definition identifier,
|
||||
type_declaration::type_declaration(const struct position position, identifier_definition identifier,
|
||||
type_expression *body)
|
||||
: definition(position, identifier), m_body(body)
|
||||
: declaration(position, identifier), m_body(body)
|
||||
{
|
||||
}
|
||||
|
||||
type_definition::~type_definition()
|
||||
type_declaration::~type_declaration()
|
||||
{
|
||||
delete m_body;
|
||||
}
|
||||
|
||||
void type_definition::accept(parser_visitor *visitor)
|
||||
void type_declaration::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
type_expression& type_definition::body()
|
||||
type_expression& type_declaration::body()
|
||||
{
|
||||
return *m_body;
|
||||
}
|
||||
|
||||
block::block(std::vector<constant_definition *>&& constants, std::vector<variable_declaration *>&& variables,
|
||||
block::block(std::vector<constant_declaration *>&& constants, std::vector<variable_declaration *>&& variables,
|
||||
std::vector<statement *>&& body)
|
||||
: m_variables(std::move(variables)), m_constants(std::move(constants)), m_body(std::move(body))
|
||||
{
|
||||
@ -381,7 +381,7 @@ namespace elna::boot
|
||||
return m_variables;
|
||||
}
|
||||
|
||||
const std::vector<constant_definition *>& block::constants()
|
||||
const std::vector<constant_declaration *>& block::constants()
|
||||
{
|
||||
return m_constants;
|
||||
}
|
||||
@ -401,7 +401,7 @@ namespace elna::boot
|
||||
{
|
||||
delete variable;
|
||||
}
|
||||
for (constant_definition *constant : this->constants())
|
||||
for (constant_declaration *constant : this->constants())
|
||||
{
|
||||
delete constant;
|
||||
}
|
||||
@ -419,7 +419,7 @@ namespace elna::boot
|
||||
|
||||
unit::~unit()
|
||||
{
|
||||
for (procedure_definition *procedure : this->procedures)
|
||||
for (procedure_declaration *procedure : this->procedures)
|
||||
{
|
||||
delete procedure;
|
||||
}
|
||||
@ -427,11 +427,11 @@ namespace elna::boot
|
||||
{
|
||||
delete variable;
|
||||
}
|
||||
for (type_definition *type : this->types)
|
||||
for (type_declaration *type : this->types)
|
||||
{
|
||||
delete type;
|
||||
}
|
||||
for (constant_definition *constant : this->constants)
|
||||
for (constant_declaration *constant : this->constants)
|
||||
{
|
||||
delete constant;
|
||||
}
|
||||
|
Reference in New Issue
Block a user