#include #include using namespace std; #include "include/input.h" #include "include/errors.h" #include "include/colors.h" #include "include/parser.h" #include "include/tokenize.h" #include "include/interpreter.h" int main(int argc, char* argv[]) { bool print_ast = false; int i=1; while (i < argc) { if (!strcmp(argv[i], "--show-ast") || !strcmp(argv[i], "-s")) { print_ast = true; } else { cerr << "Unknow argument: " << argv[i] << endl; } i++; } vector input; vector tokens; while (true) { try { input = get_input(); tokens = tokenize(input); Node ast = parse(tokens); if (print_ast) _debug_print_tree(ast, 0, ""); EvalResult res = eval(ast); cout << get(res) << endl; } catch (const SyntaxError& e) { pretty_print_error(input, e.pos); cout << BOLD RED "Syntax Error: " RESET << e.what() << endl; } catch (const ParseException& e) { cout << RED "ParsingError" RESET << endl; } cout << endl; } }