#include <iostream>

using namespace std;

#include "session.hpp"
#include "memory.hpp"
#include "dict.hpp"

const char * name[] = {
"PUSH","POP","DUPE","SWAP","AND",
"OR","NOT","XOR","ADD","SUB",
"SHIFTL","SHIFTR","NUM", "EXEC", "TXT",
"ZERO"
};

void printWord()
{
    for (int i=0;i<15;i++)
        cout << "#define " 
             << name[i] << " " 
             << txt2word(name[i]) 
             << endl;
}

int main()
{
//    printWord();
    memory mem(8000);
    session machine(&mem);
    
    machine.parse("NUM");
    machine.parse("1");
    machine.parse("2");
    machine.parse("3");
    machine.parse("0");
    machine.parse("ADD");
    machine.parse("SUB");
    machine.parse("NUM");
    machine.parse("5");
    machine.parse("6");
    machine.parse("0");
    machine.parse("ADD");

    machine.accumPrint();
    
    //test dict
    word un[] = {txt2word("dog"), 0};
    word deux[] = {txt2word("cat"), 0};
    word trois[] = {txt2word("mouse"), 0};
    
    dict * d = new dict();
    d = new dict(d, txt2word("chien"), un);
    d = new dict(d, txt2word("chat"), deux);
    d = new dict(d, txt2word("souris"), trois);
    
    cout << "chien = " << word2txt(*d->find(txt2word("chien"))) << endl;
    cout << "chat = " << word2txt(*d->find(txt2word("chat"))) << endl;
    cout << "souris = " << word2txt(*d->find(txt2word("souris"))) << endl;
    cout << "porc = " << word2txt(*d->find(txt2word("porc"))) << endl;
    
    return 0;
}
