diff --git a/furc/include/furc/ast/expression.hpp b/furc/include/furc/ast/expression.hpp index 6bc6f0a..617d0a8 100644 --- a/furc/include/furc/ast/expression.hpp +++ b/furc/include/furc/ast/expression.hpp @@ -115,7 +115,7 @@ enum class unaryop_expression_node_t { /** * @brief Unary operation expression AST node. */ -class unaryop_expression_node final : public expression_node { +class unary_op_expression_node final : public expression_node { public: /** * @brief Construct a new unaryop expression node object from type and expression node handle. @@ -124,7 +124,7 @@ public: * @param type Operation type. * @param node Handle to the inner expression node. */ - unaryop_expression_node(struct location location, unaryop_expression_node_t type, expression_node_p&& node) + unary_op_expression_node(struct location location, unaryop_expression_node_t type, expression_node_p&& node) : expression_node(location), m_type(type), m_node(std::move(node)) {} /** @@ -201,7 +201,7 @@ enum class binop_expression_node_t { /** * @brief Binary operation expression AST node. */ -class binop_expression_node final : public expression_node { +class binary_op_expression_node final : public expression_node { public: /** * @brief Construct a new binary operation expression AST node. @@ -211,10 +211,10 @@ public: * @param lhs Left-hand-side expression. * @param rhs Right-hand-side expression. */ - binop_expression_node(struct location location, - binop_expression_node_t type, - expression_node_p&& lhs, - expression_node_p&& rhs) + binary_op_expression_node(struct location location, + binop_expression_node_t type, + expression_node_p&& lhs, + expression_node_p&& rhs) : expression_node(location), m_type(type), m_lhs(std::move(lhs)), m_rhs(std::move(rhs)) {} /** diff --git a/furc/include/furc/ast/fwd.hpp b/furc/include/furc/ast/fwd.hpp index e89c55a..0f4bca6 100644 --- a/furc/include/furc/ast/fwd.hpp +++ b/furc/include/furc/ast/fwd.hpp @@ -125,19 +125,19 @@ using var_read_expression_node_p = using var_read_expression_node_r = node_r; /**< Alias for var_read_expression_node result */ -class unaryop_expression_node; +class unary_op_expression_node; -using unaryop_expression_node_p = - node_p; /**< Alias for a shared pointer to unaryop_expression_node. */ +using unary_op_expression_node_p = + node_p; /**< Alias for a shared pointer to unaryop_expression_node. */ -using unaryop_expression_node_r = node_r; /**< Alias for unaryop_expression_node result */ +using unary_op_expression_node_r = node_r; /**< Alias for unaryop_expression_node result */ -class binop_expression_node; +class binary_op_expression_node; -using binop_expression_node_p = - node_p; /**< Alias for a shared pointer to binop_expression_node. */ +using binary_op_expression_node_p = + node_p; /**< Alias for a shared pointer to binop_expression_node. */ -using binop_expression_node_r = node_r; /**< Alias for binop_expression_node result */ +using binary_op_expression_node_r = node_r; /**< Alias for binop_expression_node result */ class var_assign_expression_node; diff --git a/furc/include/furc/ast/visitor.hpp b/furc/include/furc/ast/visitor.hpp index 0259460..f3cb9ac 100644 --- a/furc/include/furc/ast/visitor.hpp +++ b/furc/include/furc/ast/visitor.hpp @@ -64,7 +64,7 @@ public: * * @param node Node. */ - virtual void visit(const unaryop_expression_node& node) {} + virtual void visit(const unary_op_expression_node& node) {} /** * @brief Visit a binop_expression_node. @@ -72,7 +72,7 @@ public: * * @param node Node. */ - virtual void visit(const binop_expression_node& node) {} + virtual void visit(const binary_op_expression_node& node) {} /** * @brief Visit a var_assign_expression_node. diff --git a/furc/include/furc/front/ir_generator.hpp b/furc/include/furc/front/ir_generator.hpp index c459005..03c7654 100644 --- a/furc/include/furc/front/ir_generator.hpp +++ b/furc/include/furc/front/ir_generator.hpp @@ -31,8 +31,8 @@ public: void visit(const ast::string_literal_node& node) override; void visit(const ast::integer_literal_node& node) override; void visit(const ast::var_read_expression_node& node) override; - void visit(const ast::unaryop_expression_node& node) override; - void visit(const ast::binop_expression_node& node) override; + void visit(const ast::unary_op_expression_node& node) override; + void visit(const ast::binary_op_expression_node& node) override; void visit(const ast::var_assign_expression_node& node) override; private: template diff --git a/furc/src/ast.cpp b/furc/src/ast.cpp index 5c49da5..46f919f 100644 --- a/furc/src/ast.cpp +++ b/furc/src/ast.cpp @@ -41,11 +41,11 @@ std::ostream& operator<<(std::ostream& os, unaryop_expression_node_t type) { return os; } -void unaryop_expression_node::accept(visitor& visitor) const { +void unary_op_expression_node::accept(visitor& visitor) const { visitor.visit(*this); } -std::ostream& unaryop_expression_node::print(std::ostream& os) const { +std::ostream& unary_op_expression_node::print(std::ostream& os) const { if (m_node == nullptr) return os; switch (m_type) { case unaryop_expression_node_t::Positive: @@ -58,8 +58,8 @@ std::ostream& unaryop_expression_node::print(std::ostream& os) const { return os; } -bool unaryop_expression_node::equal(const node& rhsNode) const { - const auto& rhs = dynamic_cast(rhsNode); +bool unary_op_expression_node::equal(const node& rhsNode) const { + const auto& rhs = dynamic_cast(rhsNode); return expression_node::equal(rhsNode) && m_type == rhs.m_type && m_node == rhs.m_node; } @@ -81,17 +81,17 @@ std::ostream& operator<<(std::ostream& os, binop_expression_node_t type) { } } -void binop_expression_node::accept(visitor& visitor) const { +void binary_op_expression_node::accept(visitor& visitor) const { visitor.visit(*this); } -std::ostream& binop_expression_node::print(std::ostream& os) const { +std::ostream& binary_op_expression_node::print(std::ostream& os) const { if (m_type == binop_expression_node_t::None) return os; return os << '(' << *m_lhs << ' ' << m_type << ' ' << *m_rhs << ')'; } -bool binop_expression_node::equal(const node& rhsNode) const { - const auto& rhs = dynamic_cast(rhsNode); +bool binary_op_expression_node::equal(const node& rhsNode) const { + const auto& rhs = dynamic_cast(rhsNode); return expression_node::equal(rhsNode) && m_type == rhs.m_type && m_lhs == rhs.m_lhs && m_rhs == rhs.m_rhs; } diff --git a/furc/src/front/ir_generator.cpp b/furc/src/front/ir_generator.cpp index f66b82b..a2f6644 100644 --- a/furc/src/front/ir_generator.cpp +++ b/furc/src/front/ir_generator.cpp @@ -80,7 +80,7 @@ void ir_generator::visit(const ast::var_read_expression_node& node) { } } -void ir_generator::visit(const ast::unaryop_expression_node& node) { +void ir_generator::visit(const ast::unary_op_expression_node& node) { throw std::runtime_error("unimplemented"); } @@ -102,7 +102,7 @@ static inline furlang::ir::binary_op_instruction_t binary_op_instruction_t(ast:: } } -void ir_generator::visit(const ast::binop_expression_node& node) { +void ir_generator::visit(const ast::binary_op_expression_node& node) { node.lhs()->accept(*this); ir_register lhs = m_registerCounter - 1; node.rhs()->accept(*this); diff --git a/furc/src/front/parser.cpp b/furc/src/front/parser.cpp index 6f0f467..035d5e3 100644 --- a/furc/src/front/parser.cpp +++ b/furc/src/front/parser.cpp @@ -223,7 +223,7 @@ ast::expression_node_r parser::parse_expression_unary(std::uint32_t precedence) { token_t::DMinus, unaryop_info{ ast::unaryop_expression_node_t::PrefixDecrement, 2 } }, }; - std::shared_ptr result; + std::shared_ptr result; while (true) { auto it = s_prefixes.find(peek_token()->type); if (it == s_prefixes.end()) break; @@ -243,8 +243,9 @@ ast::expression_node_r parser::parse_expression_unary(std::uint32_t precedence) expression = std::move(std::move(expr.value())); } - result = - m_arena.allocate_shared(token->location, current.type, std::move(expression)); + result = m_arena.allocate_shared(token->location, + current.type, + std::move(expression)); } if (result == nullptr) return parse_expression_primary(); @@ -369,11 +370,12 @@ ast::expression_node_r parser::parse_expression_rhs(ast::expression_node_p&& ini switch (current.type) { case rhsop_info_t::Unaryop: - lhs = - m_arena.allocate_shared(opToken->location, current.unary, std::move(lhs)); + lhs = m_arena.allocate_shared(opToken->location, + current.unary, + std::move(lhs)); break; case rhsop_info_t::Binop: - lhs = m_arena.allocate_shared(opToken->location, + lhs = m_arena.allocate_shared(opToken->location, current.binary, std::move(lhs), std::move(rhs));