-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
29 lines (26 loc) · 696 Bytes
/
main.cpp
File metadata and controls
29 lines (26 loc) · 696 Bytes
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
// Python Interpreter and REPL
#include "src/python_parser.hpp"
void interpret(std::istream& input, std::string input_name) {
TokenStream ts {std::cin, "<stdin>"};
Parser p {ts};
while (true) {
std::cout << ">>> ";
try {
std::unique_ptr<Node> parse_tree = p.parse_next_line(false);
if (parse_tree != nullptr)
parse_tree->print("");
}
catch (SyntaxError& e) {
std::cout << e.what() << std::endl;
}
}
}
int main(int argc, char *argv[]) {
switch (argc) {
// Python Interactive
case 1: {
interpret(std::cin, "<stdin>");
break;
}
}
}