feat(furc): add compound statement
This one: { [statement]... }
This commit is contained in:
@@ -11,7 +11,6 @@ namespace ast {
|
||||
enum class declaration_node_t {
|
||||
FunctionDeclaration,
|
||||
FunctionDefinition,
|
||||
Variable,
|
||||
};
|
||||
|
||||
class declaration_node : public statement_node {
|
||||
@@ -64,4 +63,4 @@ private:
|
||||
} // namespace ast
|
||||
} // namespace furc
|
||||
|
||||
#endif // FURC_AST_DECLARATION_HPP
|
||||
#endif // FURC_AST_DECLARATION_HPP
|
||||
|
||||
@@ -63,6 +63,8 @@ class return_statement_node;
|
||||
using return_statement_node_h = node_handle<return_statement_node>;
|
||||
class if_statement_node;
|
||||
using if_statement_node_h = node_handle<if_statement_node>;
|
||||
class compound_statement_node;
|
||||
using compound_statement_node_h = node_handle<compound_statement_node>;
|
||||
|
||||
} // namespace ast
|
||||
} // namespace furc
|
||||
|
||||
@@ -11,6 +11,7 @@ enum class statement_node_t {
|
||||
Declaration,
|
||||
Return,
|
||||
If,
|
||||
Compound,
|
||||
};
|
||||
|
||||
class statement_node : public node {
|
||||
@@ -67,6 +68,24 @@ private:
|
||||
statement_node_h m_else;
|
||||
};
|
||||
|
||||
class compound_statement_node : public statement_node {
|
||||
public:
|
||||
compound_statement_node(body_h&& body)
|
||||
: m_body(std::move(body)) {}
|
||||
public:
|
||||
const body_h& body() const { return m_body; }
|
||||
public:
|
||||
statement_node_t statement_type() const override { return statement_node_t::Compound; }
|
||||
public:
|
||||
void accept(visitor& visitor) const override;
|
||||
|
||||
std::ostream& print(std::ostream& os) const override;
|
||||
protected:
|
||||
bool equal(const node& rhs) const override;
|
||||
private:
|
||||
body_h m_body;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
} // namespace furc
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
virtual void visit_function_definition_node(const function_definition_node&) {}
|
||||
virtual void visit_return_statement_node(const return_statement_node&) {}
|
||||
virtual void visit_if_statement_node(const if_statement_node&) {}
|
||||
virtual void visit_compound_statement_node(const compound_statement_node&) {}
|
||||
|
||||
virtual void visit_error(const node_handle<node>& handle) {}
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
void visit_function_definition_node(const ast::function_definition_node& funcDef) override;
|
||||
void visit_return_statement_node(const ast::return_statement_node& returnStmt) override;
|
||||
void visit_if_statement_node(const ast::if_statement_node& node) override;
|
||||
void visit_compound_statement_node(const ast::compound_statement_node& node) override;
|
||||
void visit_string_literal_node(const ast::string_literal_node& node) override;
|
||||
void visit_integer_literal_node(const ast::integer_literal_node& node) override;
|
||||
void visit_var_read_expression_node(const ast::var_read_expression_node& node) override;
|
||||
|
||||
Reference in New Issue
Block a user