#include <iostream>
#include <string>
#include "Token.h"
#include "Lexer.h"
#include "Parser.h"

using namespace std;

void test_lexer()
{
    string test_line = "def i; bulb; i + 3; string banan; banan = \"banan and other stuff\"; string kaboom(num how_many_times) { def z; }";
    string test_line2 = "def how_many_trees = 1; how_many_trees + 3 == 2; num cut_tree( num how_many) {return how_many -1; != <=}";
    Lexer lexer;
    vector<Token> tokens = lexer.parse_line(test_line);


    for(int i=0; i< tokens.size(); i++)
    {
        cout << tokens[i].get_value() << " type: " << tokens[i].get_type() << endl;
    }


    tokens = lexer.parse_line(test_line2);

    /*for(int i=0; i< tokens.size(); i++)
    {
        cout << tokens[i].get_value() << " type: " << tokens[i].get_type() << endl;
    }*/
}

void test_parser()
{
    vector<string> lines;
    lines.push_back("def i; bulb; i + 3; string banan = \"kartofel\"; banan = \"banan\"; string kaboom(num how_many_times) { def z; }");
    lines.push_back("{ i like bananas; string hello = \"hello\"; hello(); }");
    lines.push_back("def how_many_trees = 1; how_many_trees + 3 == 2; num cut_tree(num how_many) {return how_many -1;}");
    Lexer lexer;
    vector<Token> tokens;
    for(int i=0; i<lines.size(); i++)
    {
        tokens = lexer.parse_line(lines[i]);
        Parser parser = Parser(tokens);
        parser.interpret();
        cout << "<<<Parsing number: " << i << " >>>" << endl;
        cout << "Instructions: " << endl ;
        cout << lines[i] << endl << endl;
        cout << parser.report_message;
        cout << parser.error_message << endl;
    }

}
int main()
{
    cout << "Hello world!" << endl;
    //test_parser();
    //test_lexer();
    return 0;
}
