Support while … else
This commit is contained in:
@ -175,17 +175,22 @@ namespace elna::boot
|
||||
virtual literal_expression *is_literal();
|
||||
};
|
||||
|
||||
struct identifier_definition
|
||||
{
|
||||
std::string identifier;
|
||||
bool exported;
|
||||
};
|
||||
|
||||
/**
|
||||
* Symbol definition.
|
||||
*/
|
||||
class definition : public node
|
||||
{
|
||||
protected:
|
||||
definition(const struct position position, const std::string& identifier, const bool exported);
|
||||
definition(const struct position position, identifier_definition identifier);
|
||||
|
||||
public:
|
||||
const std::string identifier;
|
||||
const bool exported;
|
||||
const identifier_definition identifier;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -298,8 +303,8 @@ namespace elna::boot
|
||||
std::shared_ptr<type_expression> m_variable_type;
|
||||
|
||||
public:
|
||||
variable_declaration(const struct position position, const std::string& identifier,
|
||||
std::shared_ptr<type_expression> variable_type, const bool exported = false);
|
||||
variable_declaration(const struct position position, identifier_definition identifier,
|
||||
std::shared_ptr<type_expression> variable_type);
|
||||
|
||||
void accept(parser_visitor *visitor) override;
|
||||
|
||||
@ -326,8 +331,8 @@ namespace elna::boot
|
||||
expression *m_body;
|
||||
|
||||
public:
|
||||
constant_definition(const struct position position, const std::string& identifier,
|
||||
const bool exported, expression *body);
|
||||
constant_definition(const struct position position, identifier_definition identifier,
|
||||
expression *body);
|
||||
void accept(parser_visitor *visitor) override;
|
||||
|
||||
expression& body();
|
||||
@ -364,8 +369,8 @@ namespace elna::boot
|
||||
block *const body;
|
||||
std::vector<std::string> parameter_names;
|
||||
|
||||
procedure_definition(const struct position position, const std::string& identifier,
|
||||
const bool exported, procedure_type_expression *heading, block *body = nullptr);
|
||||
procedure_definition(const struct position position, identifier_definition identifier,
|
||||
procedure_type_expression *heading, block *body = nullptr);
|
||||
void accept(parser_visitor *visitor) override;
|
||||
|
||||
procedure_type_expression& heading();
|
||||
@ -381,8 +386,8 @@ namespace elna::boot
|
||||
type_expression *m_body;
|
||||
|
||||
public:
|
||||
type_definition(const struct position position, const std::string& identifier,
|
||||
const bool exported, type_expression *expression);
|
||||
type_definition(const struct position position, identifier_definition identifier,
|
||||
type_expression *expression);
|
||||
~type_definition();
|
||||
|
||||
void accept(parser_visitor *visitor) override;
|
||||
@ -595,10 +600,11 @@ namespace elna::boot
|
||||
conditional_statements *m_body;
|
||||
|
||||
public:
|
||||
std::vector<conditional_statements *> branches;
|
||||
const std::vector<conditional_statements *> branches;
|
||||
const std::vector<statement *> *alternative;
|
||||
|
||||
if_statement(const struct position position, conditional_statements *body,
|
||||
std::vector<conditional_statements *>&& branches,
|
||||
std::vector<statement *> *alternative = nullptr);
|
||||
void accept(parser_visitor *visitor) override;
|
||||
|
||||
@ -628,11 +634,13 @@ namespace elna::boot
|
||||
public:
|
||||
const std::vector<conditional_statements *> branches;
|
||||
const std::optional<std::string> label;
|
||||
const std::vector<statement *> *alternative;
|
||||
|
||||
while_statement(const struct position position, conditional_statements *body,
|
||||
std::vector<conditional_statements *>&& branches);
|
||||
std::vector<conditional_statements *>&& branches, std::vector<statement *> *alternative = nullptr);
|
||||
while_statement(const struct position position, conditional_statements *body,
|
||||
std::vector<conditional_statements *>&& branches, const std::string& label);
|
||||
std::vector<conditional_statements *>&& branches, const std::string& label,
|
||||
std::vector<statement *> *alternative = nullptr);
|
||||
void accept(parser_visitor *visitor) override;
|
||||
|
||||
conditional_statements& body();
|
||||
|
Reference in New Issue
Block a user