Support variable declaration initializer
This commit is contained in:
@@ -340,17 +340,20 @@ namespace elna::boot
|
||||
/**
|
||||
* Variable declaration.
|
||||
*/
|
||||
class variable_declaration : public declaration
|
||||
class variable_declaration : public node
|
||||
{
|
||||
std::shared_ptr<type_expression> m_variable_type;
|
||||
|
||||
public:
|
||||
variable_declaration(const struct position position, identifier_definition identifier,
|
||||
std::shared_ptr<type_expression> variable_type);
|
||||
variable_declaration(const struct position position,
|
||||
std::vector<identifier_definition>&& identifier, std::shared_ptr<type_expression> variable_type,
|
||||
expression *body = nullptr);
|
||||
|
||||
void accept(parser_visitor *visitor) override;
|
||||
|
||||
const std::vector<identifier_definition> identifiers;
|
||||
type_expression& variable_type();
|
||||
expression *const body;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -79,6 +79,14 @@ namespace elna::boot
|
||||
std::string what() const override;
|
||||
};
|
||||
|
||||
class variable_initializer_error : public error
|
||||
{
|
||||
public:
|
||||
variable_initializer_error(const char *path, const struct position position);
|
||||
|
||||
std::string what() const override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks types.
|
||||
*/
|
||||
@@ -174,5 +182,7 @@ namespace elna::boot
|
||||
void visit(program *program) override;
|
||||
void visit(import_declaration *) override;
|
||||
void visit(unit *unit) override;
|
||||
void visit(variable_declaration *declaration) override;
|
||||
void visit(procedure_declaration *definition) override;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user