summaryrefslogtreecommitdiffstats
path: root/sencha/main.cpp
blob: 4be25f9fdc39df4759a275ed0c38f7ee4261498f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#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\"; string kaboom(num how_many_times) { def z; }";
    string test_line2 = "i like \"lol\" ,function: bananananananas, lol, ==555% % % += 1sas /> \n";
    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; }");
    Lexer lexer;
    vector<Token> tokens;
    for(i=0; i<lines.size(); i++)
    {
        tokens = lexer.parse_line(lines[i]);
        Parser parser = Parser(tokens);
        parser.interpret();
        cout << parser.report_message;
        cout << parser.error_message;
    }

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