<commit_before>#ifndef AST_VISITOR_H__TOSTITOS
#define AST_VISITOR_H__TOSTITOS

#include "../AST/ast.h"

#include <functional>

namespace TosLang
{
    namespace Common
    {
        /*
        * \class ASTVisitor
        * \brief Tree visitor that does a traversal of the AST.
        *        It is based of CRTP, so any derived class should provide itself as the template argument
        */
        template <typename Derived>
        class ASTVisitor
        {
        public:
            ASTVisitor() : mCurrentNode(nullptr) { }
            ~ASTVisitor() = default;

        protected:
            /*
            * \fn VisitPostOrder
            * \param root   Root node of the tree to visit
            * \brief        Visit the tree rooted at root by doing a post-order traversal
            */
            void VisitPostOrder(const std::unique_ptr<FrontEnd::ASTNode>& root)
            {
                if (root != nullptr)
                {
                    mCurrentNode = root.get();
                    mPrologueFtr();

                    for (auto& childNode : root->GetChildrenNodes())
                        VisitPostOrder(childNode);

                    mCurrentNode = root.get();
                    DispatchNode(root.get());
                 
                    mEpilogueFtr();
                }
            }

            /*
            * \fn VisitPreOrder
            * \param root   Root node of the tree to visit
            * \brief        Visit the tree rooted at root by doing a pre-order traversal
            */
            void VisitPreOrder(const std::unique_ptr<FrontEnd::ASTNode>& root)
            {
                if (root != nullptr)
                {
                    mCurrentNode = root.get();
                    mPrologueFtr();
                    
                    DispatchNode(root.get());

                    for (auto& childNode : root->GetChildrenNodes())
                        VisitPreOrder(childNode);

                    mCurrentNode = root.get();
                    mEpilogueFtr();
                }
            }

        protected:  // Declarations
            /*
            * \fn       HandleFunctionDecl
            * \brief    Handle a node of the FUNCTION_DECL kind
            */
            void HandleFunctionDecl() { }

            /*
            * \fn       HandleParamVarDecl
            * \brief    Handle a node of the PARAM_VAR_DECL kind
            */
            void HandleParamVarDecl() { }

            /*
            * \fn       HandleProgramDecl
            * \brief    Handle a node of the PROGRAM_DECL kind
            */
            void HandleProgramDecl() { }

            /*
            * \fn       HandleVarDecl
            * \brief    Handle a node of the VAR_DECL kind
            */
            void HandleVarDecl() { }

        protected:  // Expressions
            /*
            * \fn       HandleBinrayExpr
            * \brief    Handle a node of the BINARY_EXPR kind
            */
            void HandleBinaryExpr() { }

            /*
            * \fn       HandleBooleanExpr
            * \brief    Handle a node of the BOOLEAN_EXPR kind
            */
            void HandleBooleanExpr() { }

            /*
            * \fn       HandleCallExpr
            * \brief    Handle a node of the CALL_EXPR kind
            */
            void HandleCallExpr() { }

            /*
            * \fn       HandleIdentifierExpr
            * \brief    Handle a node of the IDENTIFIER_EXPR kind
            */
            void HandleIdentifierExpr() { }

            /*
            * \fn       HandleNumberExpr
            * \brief    Handle a node of the NUMBER_EXPR kind
            */
            void HandleNumberExpr() { }
        
        protected:  // Statements
            /*
            * \fn       HandleCompoundStmt
            * \brief    Handle a node of the COMPOUND_STMT kind
            */
            void HandleCompoundStmt() { }

            /*
            * \fn       HandleIfStmt
            * \brief    Handle a node of the IF_STMT kind
            */
            void HandleIfStmt() { }

            /*
            * \fn       HandlePrintStmt
            * \brief    Handle a node of the PRINT_STMT kind
            */
            void HandlePrintStmt() { }
<commit_msg>Adding new method to the AST visitor<commit_after>#ifndef AST_VISITOR_H__TOSTITOS
#define AST_VISITOR_H__TOSTITOS

#include "../AST/ast.h"

#include <functional>

namespace TosLang
{
    namespace Common
    {
        /*
        * \class ASTVisitor
        * \brief Tree visitor that does a traversal of the AST.
        *        It is based of CRTP, so any derived class should provide itself as the template argument
        */
        template <typename Derived>
        class ASTVisitor
        {
        public:
            ASTVisitor() : mCurrentNode(nullptr) { }
            ~ASTVisitor() = default;

        protected:
            /*
            * \fn VisitPostOrder
            * \param root   Root node of the tree to visit
            * \brief        Visit the tree rooted at root by doing a post-order traversal
            */
            void VisitPostOrder(const std::unique_ptr<FrontEnd::ASTNode>& root)
            {
                if (root != nullptr)
                {
                    mCurrentNode = root.get();
                    mPrologueFtr();

                    for (auto& childNode : root->GetChildrenNodes())
                        VisitPostOrder(childNode);

                    mCurrentNode = root.get();
                    DispatchNode(root.get());
                 
                    mEpilogueFtr();
                }
            }

            /*
            * \fn VisitPreOrder
            * \param root   Root node of the tree to visit
            * \brief        Visit the tree rooted at root by doing a pre-order traversal
            */
            void VisitPreOrder(const std::unique_ptr<FrontEnd::ASTNode>& root)
            {
                if (root != nullptr)
                {
                    mCurrentNode = root.get();
                    mPrologueFtr();
                    
                    DispatchNode(root.get());

                    for (auto& childNode : root->GetChildrenNodes())
                        VisitPreOrder(childNode);

                    mCurrentNode = root.get();
                    mEpilogueFtr();
                }
            }

        protected:  // Declarations
            /*
            * \fn       HandleFunctionDecl
            * \brief    Handle a node of the FUNCTION_DECL kind
            */
            void HandleFunctionDecl() { }

            /*
            * \fn       HandleParamVarDecl
            * \brief    Handle a node of the PARAM_VAR_DECL kind
            */
            void HandleParamVarDecl() { }

            /*
            * \fn       HandleProgramDecl
            * \brief    Handle a node of the PROGRAM_DECL kind
            */
            void HandleProgramDecl() { }

            /*
            * \fn       HandleVarDecl
            * \brief    Handle a node of the VAR_DECL kind
            */
            void HandleVarDecl() { }

        protected:  // Expressions
            /*
            * \fn       HandleBinrayExpr
            * \brief    Handle a node of the BINARY_EXPR kind
            */
            void HandleBinaryExpr() { }

            /*
            * \fn       HandleBooleanExpr
            * \brief    Handle a node of the BOOLEAN_EXPR kind
            */
            void HandleBooleanExpr() { }

            /*
            * \fn       HandleCallExpr
            * \brief    Handle a node of the CALL_EXPR kind
            */
            void HandleCallExpr() { }

            /*
            * \fn       HandleIdentifierExpr
            * \brief    Handle a node of the IDENTIFIER_EXPR kind
            */
            void HandleIdentifierExpr() { }

            /*
            * \fn       HandleNumberExpr
            * \brief    Handle a node of the NUMBER_EXPR kind
            */
            void HandleNumberExpr() { }

            /*
            * \fn       HandleStringExpr
            * \brief    Handle a node of the STRING_EXPR kind
            */
            void HandleStringExpr() { }
        
        protected:  // Statements
            /*
            * \fn       HandleCompoundStmt
            * \brief    Handle a node of the COMPOUND_STMT kind
            */
            void HandleCompoundStmt() { }

            /*
            * \fn       HandleIfStmt
            * \brief    Handle a node of the IF_STMT kind
            */
            void HandleIfStmt() { }

            /*
            * \fn       HandlePrintStmt
            * \brief    Handle a node of the PRINT_STMT kind
            */
            void HandlePrintStmt() { }

{'fraction_non_alphanumeric': 0.07430973752982616, 'fraction_numerical': 0.0, 'mean_word_length': 1.0304498269896194, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5495368', 'n_tokens_mistral': 2199, 'n_tokens_neox': 2095, 'n_words': 588}