<commit_before>// Copyright 2008 <NAME>

#include "common_headers.h"

#include "circa.h"
#include "testing.h"

using namespace circa;

int circa_main(std::vector<std::string> args)
{
    initialize();

    // load args into kernel
    List *cl_args = new List();
    
    for (unsigned int i=0; i < args.size(); i++) {
        cl_args->append(args[i]);
    }

    create_value(KERNEL, "List", cl_args, "cl-args");

    args.erase(args.begin());

    bool justPrintBranch = false;
    bool justPrintSource = false;

    if (args.size() == 0) {
        run_all_tests();
        goto shutdown;
    }

    if (args[0] == "-e") {
        args.erase(args.begin());
        std::stringstream command;
        bool firstArg = true;
        while (!args.empty()) {
            if (!firstArg) command << " ";
            command << args[0];
            args.erase(args.begin());
            firstArg = false;
        }

        Branch workspace;
        Term* result = workspace.eval(command.str());
        std::cout << result->toString() << std::endl;
        goto shutdown;
    }

    if (args[0] == "--list-tests") {
        std::vector<std::string> testNames = list_all_test_names();

        std::vector<std::string>::const_iterator it;
        for (it = testNames.begin(); it != testNames.end(); ++it) {
            std::cout << *it << std::endl;
        }
        goto shutdown;
    }

    if (args[0] == "-p") {
        justPrintBranch = true;
        args.erase(args.begin());
    }

    if (args[0] == "-s") {
        justPrintSource = true;
        args.erase(args.begin());

        if (justPrintBranch) {
            // todo: fatal
        }
    }

    try
    {
        Branch workspace;
        string_value(workspace, args[0], "filename");
        Branch& branch = as_branch(workspace.eval("evaluate-file(filename)"));

        if (justPrintBranch) {
            print_raw_branch(branch, std::cout);
        }

        else if (justPrintSource) {
            print_source(branch, std::cout);
        }

        else if (has_compile_errors(branch)) {
            print_compile_errors(branch, std::cout);
        } else {

            Term* error_listener = new Term();

            evaluate_branch(branch, error_listener);<commit_msg>Fix an issue where parsing errors would not show up<commit_after>// Copyright 2008 <NAME>

#include "common_headers.h"

#include "circa.h"
#include "testing.h"

using namespace circa;

int circa_main(std::vector<std::string> args)
{
    initialize();

    // load args into kernel
    List *cl_args = new List();
    
    for (unsigned int i=0; i < args.size(); i++) {
        cl_args->append(args[i]);
    }

    create_value(KERNEL, "List", cl_args, "cl-args");

    args.erase(args.begin());

    bool justPrintBranch = false;
    bool justPrintSource = false;

    if (args.size() == 0) {
        run_all_tests();
        goto shutdown;
    }

    if (args[0] == "-e") {
        args.erase(args.begin());
        std::stringstream command;
        bool firstArg = true;
        while (!args.empty()) {
            if (!firstArg) command << " ";
            command << args[0];
            args.erase(args.begin());
            firstArg = false;
        }

        Branch workspace;
        Term* result = workspace.eval(command.str());
        std::cout << result->toString() << std::endl;
        goto shutdown;
    }

    if (args[0] == "--list-tests") {
        std::vector<std::string> testNames = list_all_test_names();

        std::vector<std::string>::const_iterator it;
        for (it = testNames.begin(); it != testNames.end(); ++it) {
            std::cout << *it << std::endl;
        }
        goto shutdown;
    }

    if (args[0] == "-p") {
        justPrintBranch = true;
        args.erase(args.begin());
    }

    if (args[0] == "-s") {
        justPrintSource = true;
        args.erase(args.begin());

        if (justPrintBranch) {
            // todo: fatal
        }
    }

    try
    {
        Branch workspace;
        string_value(workspace, args[0], "filename");

        Term* evaluated_file = workspace.eval("evaluate-file(filename)");
        if (evaluated_file->hasError()) {
            std::cout << "Parsing error: " << evaluated_file->getErrorMessage()
                << std::endl;
        }
        Branch& branch = as_branch(evaluated_file);

        if (justPrintBranch) {
            print_raw_branch(branch, std::cout);
        }

        else if (justPrintSource) {
            print_source(branch, std::cout);
        }

        else if (has_compile_errors(branch)) {
            print_compile_errors(branch, std::cout);
        } else {

            Term* error_listener = new Term();

            evaluate_branch(branch, error_listener);
{'fraction_non_alphanumeric': 0.1516497461928934, 'fraction_numerical': 0.005076142131979695, 'mean_word_length': 2.047036082474227, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 17, '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': '2039637', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1433, 'n_words': 306}