<commit_before>//=======================================================================
// Copyright <NAME> 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include <iostream>
#include <cstdio>

#include "Timer.hpp"
#include "Options.hpp"
#include "StringPool.hpp"
#include "Compiler.hpp"
#include "Program.hpp"
#include "Parser.hpp"
#include "MainDeclaration.hpp"
#include "Methods.hpp"
#include "il/IntermediateProgram.hpp"

using std::string;
using std::cout;
using std::endl;

using namespace eddic;

void execCommand(const string& command);

int Compiler::compile(const string& file) {
    cout << "Compile " << file << endl;

    Timer timer;

    string output = Options::get(ValueOption::OUTPUT);

    int code = 0;
    try {
        lexer.lex(file);

        Parser parser(lexer);

        std::shared_ptr<Program> program = parser.parse();

        std::shared_ptr<StringPool> pool(new StringPool(program->context()));

        program->addFirst(std::shared_ptr<ParseNode>(new MainDeclaration(program->context())));
        program->addLast(std::shared_ptr<ParseNode>(new Methods(program->context())));
        program->addLast(pool);

        //Semantical analysis
        program->checkVariables();
        program->checkStrings(*pool);
        program->checkFunctions(*program);

        //Optimize the parse tree
        program->optimize();

        //Compilation
//        writer.open("output.asm");
//        program->write(writer);

        IntermediateProgram il;
        program->writeIL(il);

        //Temporary test
//        writer.close();
        writer.open("output.asm");
        il.writeAsm(writer);
        //End of Temporary test
<commit_msg>Clean the compiler to use only the new method of compilation<commit_after>//=======================================================================
// Copyright <NAME> 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include <iostream>
#include <cstdio>

#include "Timer.hpp"
#include "Options.hpp"
#include "StringPool.hpp"
#include "Compiler.hpp"
#include "Program.hpp"
#include "Parser.hpp"
#include "MainDeclaration.hpp"
#include "Methods.hpp"
#include "il/IntermediateProgram.hpp"

using std::string;
using std::cout;
using std::endl;

using namespace eddic;

void execCommand(const string& command);

int Compiler::compile(const string& file) {
    cout << "Compile " << file << endl;

    Timer timer;

    string output = Options::get(ValueOption::OUTPUT);

    int code = 0;
    try {
        lexer.lex(file);

        Parser parser(lexer);

        std::shared_ptr<Program> program = parser.parse();

        std::shared_ptr<StringPool> pool(new StringPool(program->context()));

        program->addFirst(std::shared_ptr<ParseNode>(new MainDeclaration(program->context())));
        program->addLast(std::shared_ptr<ParseNode>(new Methods(program->context())));
        program->addLast(pool);

        //Semantical analysis
        program->checkVariables();
        program->checkStrings(*pool);
        program->checkFunctions(*program);

        //Optimize the parse tree
        program->optimize();

        //Write Intermediate representation of the parse tree
        IntermediateProgram il;
        program->writeIL(il);

        //Write assembly code
        writer.open("output.asm");
        il.writeAsm(writer);

{'fraction_non_alphanumeric': 0.208130081300813, 'fraction_numerical': 0.005962059620596206, 'mean_word_length': 3.62531328320802, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '459896', 'n_tokens_mistral': 1055, 'n_tokens_neox': 985, 'n_words': 232}