Support the remainder operator
This commit is contained in:
@@ -19,6 +19,7 @@ namespace source
|
||||
subtraction,
|
||||
multiplication,
|
||||
division,
|
||||
remainder,
|
||||
equals,
|
||||
not_equals,
|
||||
less,
|
||||
@@ -40,7 +41,6 @@ namespace source
|
||||
class procedure_definition;
|
||||
class type_definition;
|
||||
class call_expression;
|
||||
class compound_statement;
|
||||
class assign_statement;
|
||||
class if_statement;
|
||||
class while_statement;
|
||||
@@ -75,7 +75,6 @@ namespace source
|
||||
virtual void visit(type_definition *) = 0;
|
||||
virtual void visit(call_expression *) = 0;
|
||||
virtual void visit(expression_statement *) = 0;
|
||||
virtual void visit(compound_statement *) = 0;
|
||||
virtual void visit(assign_statement *) = 0;
|
||||
virtual void visit(if_statement *) = 0;
|
||||
virtual void visit(while_statement *) = 0;
|
||||
@@ -112,7 +111,6 @@ namespace source
|
||||
virtual void visit(type_definition *definition) override;
|
||||
virtual void visit(call_expression *statement) override;
|
||||
virtual void visit(expression_statement *statement) override;
|
||||
virtual void visit(compound_statement *statement) override;
|
||||
virtual void visit(assign_statement *statement) override;
|
||||
virtual void visit(if_statement *) override;
|
||||
virtual void visit(while_statement *) override;
|
||||
@@ -484,15 +482,21 @@ namespace source
|
||||
virtual ~expression_statement() override;
|
||||
};
|
||||
|
||||
class compound_statement : public node
|
||||
/**
|
||||
* List of statements paired with a condition.
|
||||
*/
|
||||
class conditional_statements
|
||||
{
|
||||
expression *m_prerequisite;
|
||||
|
||||
public:
|
||||
std::vector<statement *> statements;
|
||||
|
||||
compound_statement(const struct position position, std::vector<statement *>&& statements);
|
||||
virtual void accept(parser_visitor *visitor) override;
|
||||
conditional_statements(expression *prerequisite);
|
||||
|
||||
virtual ~compound_statement() override;
|
||||
expression& prerequisite();
|
||||
|
||||
virtual ~conditional_statements();
|
||||
};
|
||||
|
||||
class return_statement : public statement
|
||||
@@ -609,24 +613,16 @@ namespace source
|
||||
*/
|
||||
class if_statement : public statement
|
||||
{
|
||||
expression *m_prerequisite;
|
||||
compound_statement *m_body;
|
||||
compound_statement *m_alternative;
|
||||
conditional_statements *m_body;
|
||||
std::vector<statement *> *m_alternative;
|
||||
|
||||
public:
|
||||
/**
|
||||
* \param position Source code position.
|
||||
* \param prerequisite Condition.
|
||||
* \param body Statement executed if the condition is met.
|
||||
* \param alternative Statement executed if the condition is not met.
|
||||
*/
|
||||
if_statement(const struct position position, expression *prerequisite,
|
||||
compound_statement *body, compound_statement *alternative = nullptr);
|
||||
if_statement(const struct position position, conditional_statements *body,
|
||||
std::vector<statement *> *alternative = nullptr);
|
||||
virtual void accept(parser_visitor *visitor) override;
|
||||
|
||||
expression& prerequisite();
|
||||
compound_statement& body();
|
||||
compound_statement *alternative();
|
||||
conditional_statements& body();
|
||||
std::vector<statement *> *alternative();
|
||||
|
||||
virtual ~if_statement() override;
|
||||
};
|
||||
@@ -636,21 +632,13 @@ namespace source
|
||||
*/
|
||||
class while_statement : public statement
|
||||
{
|
||||
expression *m_prerequisite;
|
||||
compound_statement *m_body;
|
||||
conditional_statements *m_body;
|
||||
|
||||
public:
|
||||
/**
|
||||
* \param position Source code position.
|
||||
* \param prerequisite Condition.
|
||||
* \param body Statement executed while the condition is met.
|
||||
*/
|
||||
while_statement(const struct position position, expression *prerequisite,
|
||||
compound_statement *body);
|
||||
while_statement(const struct position position, conditional_statements *body);
|
||||
virtual void accept(parser_visitor *visitor) override;
|
||||
|
||||
expression& prerequisite();
|
||||
compound_statement& body();
|
||||
conditional_statements& body();
|
||||
|
||||
virtual ~while_statement() override;
|
||||
};
|
||||
@@ -721,7 +709,7 @@ namespace source
|
||||
|
||||
public:
|
||||
binary_expression(const struct position position, expression *lhs,
|
||||
expression *rhs, const unsigned char operation);
|
||||
expression *rhs, const binary_operator operation);
|
||||
|
||||
virtual void accept(parser_visitor *visitor) override;
|
||||
expression& lhs();
|
||||
|
||||
Reference in New Issue
Block a user