<commit_before>#include <fstream>
#include <memory>
#include <string>

#include <Program.h>
#include <DotLangVisitor.h>
#include <PrintCodeVisitor.h>

#include "BisonParser.h"

std::string AstToDotLanguage( const CProgram* root, bool verbose ) {
    CDotLangVisitor visitor( verbose );
    visitor.Visit( root );
    return visitor.GetTraversalInDotLanguage();
}

std::string AstToCode( const CProgram* root, bool verbose ) {
    CPrintCodeVisitor visitor( verbose );
    visitor.Visit( root );
    return visitor.GetCode();
}

void printHelp(const std::string& programName) {
    std::cerr << programName << " <inputFilePath> <outputFilePath> <mode>" << std::endl;
    std::cerr << "<mode>: dot / code" << std::endl;
}

int main(int argc, char* argv[]) {
    if (argc < 4) {
        printHelp(argv[0]);
        throw std::logic_error("Too few arguments provided");
    }
    const std::string inputFilePath(argv[1]);
    const std::string outputFilePath(argv[2]);
    const std::string mode(argv[3]);
    CBisonParser parser(inputFilePath);
    std::unique_ptr<const CProgram> astRoot = parser.buildAST( inputFilePath );
    std::string traversal;
    if (mode == "code") {
        traversal = AstToCode( astRoot.get(), false );
    } else if (mode == "dot") {
        traversal = AstToDotLanguage( astRoot.get(), false );
    } else {<commit_msg>Hint to main.cpp added<commit_after>#include <fstream>
#include <memory>
#include <string>

#include <Program.h>
#include <DotLangVisitor.h>
#include <PrintCodeVisitor.h>

#include "BisonParser.h"

std::string AstToDotLanguage( const CProgram* root, bool verbose ) {
    CDotLangVisitor visitor( verbose );
    visitor.Visit( root );
    return visitor.GetTraversalInDotLanguage();
}

std::string AstToCode( const CProgram* root, bool verbose ) {
    CPrintCodeVisitor visitor( verbose );
    visitor.Visit( root );
    return visitor.GetCode();
}

void printHelp(const std::string& programName) {
    std::cerr << programName << " <inputFilePath> <outputFilePath> <mode>" << std::endl;
    std::cerr << "<mode>: dot / code" << std::endl;
}

int main(int argc, char* argv[]) {
    if (argc < 4) {
        printHelp(argv[0]);
        throw std::logic_error("Too few arguments provided");
    }
    const std::string inputFilePath(argv[1]);
    const std::string outputFilePath(argv[2]);
    const std::string mode(argv[3]);
    CBisonParser parser(inputFilePath);
    std::unique_ptr<const CProgram> astRoot = parser.buildAST( inputFilePath );
    std::string traversal;
    if (mode == "code") {
        traversal = AstToCode( astRoot.get(), false );
    } else if (mode == "dot") {
        traversal = AstToDotLanguage( astRoot.get(), false );
    } else if (mode == "errors") {
        // TODO
    } else {
{'fraction_non_alphanumeric': 0.14912917271407838, 'fraction_numerical': 0.00362844702467344, 'mean_word_length': 3.9232142857142858, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 25, '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': '5307289', 'n_tokens_mistral': 870, 'n_tokens_neox': 859, 'n_words': 218}