-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
62 lines (46 loc) · 1.08 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "main.h"
#include <iostream>
#include <vector>
#include <string>
#include <stdexcept>
#include "py_functions.h"
using namespace std;
namespace test {
vector<string> inputstrings;
unsigned square(unsigned number) {
return number * number;
}
void process_input(string s) {
if (s == "p") {
py_functions::interact();
} else {
s = py_functions::invoke_callbacks(s);
inputstrings.push_back(s);
cout << "processed input: " << s << endl;
}
}
int main(Args args) {
try {
cout << "exctest returned " << py_functions::exctest(1337) << endl;
} catch (runtime_error &e) {
cout << "exception during exctest: " << e.what() << endl;
}
py_functions::print_square(args.thatnumber);
cout << "type p to enter interactive python interp, anything else to add strings" << endl;
while (true) {
string l;
cout << "> " << flush;
getline(cin, l);
if (l.size() == 0) {
cout << "kthxbai" << endl;
break;
}
try {
test::process_input(l);
} catch (runtime_error &e) {
cout << "error processing line: " << e.what() << endl;
}
}
return 0;
}
} // namespace test