Skip to content

Commit

Permalink
chore: added docstrs
Browse files Browse the repository at this point in the history
  • Loading branch information
charliekush committed Sep 30, 2024
1 parent 532303b commit 31c9bfa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
14 changes: 7 additions & 7 deletions src/expression_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#include <memory>
#include <string>

/**
* @brief Default constructor for ExpressionNode.
*
* Initializes the node with no token and no children.
*/
/**
* @brief Default constructor for ExpressionNode.
*
* Initializes the node with no token and no children.
*/
ExpressionNode::ExpressionNode()
{
this->token = nullptr;
Expand Down Expand Up @@ -219,9 +219,9 @@ std::shared_ptr<ExpressionNode> ExpressionNode::addChild(

/**
* @brief swaps the left and right children
*
*
*/
void ExpressionNode::swapChildren()
{
std::swap(this->leftChild,this->rightChild);
std::swap(this->leftChild, this->rightChild);
}
27 changes: 14 additions & 13 deletions src/expression_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,31 @@
#include "token.hpp"

#include <memory>

class ExpressionNode : public std::enable_shared_from_this<ExpressionNode>
{
public:
/**
* @brief Default constructor for ExpressionNode.
*
*
* Initializes the node with no token and no children.
*/
ExpressionNode();

/**
* @brief Constructs a node from the given token.
*
*
* @param token The token that the node represents.
*/
ExpressionNode(std::shared_ptr<Token> token);

/**
* @brief Adds a child node to this node.
*
* @details Attempts to set the provided node as the left child. If the
* left child is already set, it attempts to set the node as the
*
* @details Attempts to set the provided node as the left child. If the
* left child is already set, it attempts to set the node as the
* right child.
*
*
* @param node A shared pointer to the node to add as a child.
* @return A shared pointer to the newly set child.
* @return nullptr if both left and right children are already set.
Expand All @@ -44,7 +45,7 @@ class ExpressionNode : public std::enable_shared_from_this<ExpressionNode>
/**
* @brief Sets the left child of this node.
*
* @details If the left child is currently null, the provided node is set
* @details If the left child is currently null, the provided node is set
* as the left child.
*
* @param node A shared pointer to the node to set as the left child.
Expand All @@ -57,7 +58,7 @@ class ExpressionNode : public std::enable_shared_from_this<ExpressionNode>
/**
* @brief Sets the right child of this node.
*
* @details If the right child is currently null, the provided node is set
* @details If the right child is currently null, the provided node is set
* as the right child.
*
* @param node A shared pointer to the node to set as the right child.
Expand All @@ -69,7 +70,7 @@ class ExpressionNode : public std::enable_shared_from_this<ExpressionNode>

/**
* @brief swaps the left and right children
*
*
*/
void swapChildren();

Expand All @@ -91,21 +92,21 @@ class ExpressionNode : public std::enable_shared_from_this<ExpressionNode>
* @return A shared pointer to the removed left child node.
*/
std::shared_ptr<ExpressionNode> removeLeftChild();

/**
* @brief Removes the right child of this node.
*
* @return A shared pointer to the removed right child node.
*/
std::shared_ptr<ExpressionNode> removeRightChild();

/**
* @brief Gets the parent of the node.
*
*
* @return A weak pointer to the parent node.
*/
std::weak_ptr<ExpressionNode> getParent();

/**
* @brief Gets the right child of the node.
*
Expand Down

0 comments on commit 31c9bfa

Please sign in to comment.