-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
45 lines (34 loc) · 1.1 KB
/
main.cpp
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
#include <iostream>
#include <map>
#include <sstream>
#include "instruction_parser.h"
#include "context.h"
#include "value.h"
int main(void) {
Context* context = Context::create();
InstructionParser* i = new InstructionParser(context);
Class* A = new Class("A");
context->registerClass(A);
// context->scope->set("a", Value(42));
// std::cout << context->scope->get("a") << std::endl;
//
while (true) {
std::string input;
std::cout << "input > ";
std::getline(std::cin, input);
try {
std::istringstream iss(input);
Value res;
for (std::string instr; std::getline(iss, instr, ';'); ) {
res = i->parse(instr);
}
// only keep last returned value
std::cout << "--> " << res << std::endl;
// std::cout << "--> a = " << *(context->scope->get("a")) << std::endl;
} catch (std::string e) {
std::cout << e << std::endl;
}
i->clear();
}
return 0;
}