From 65f17438de5983ca010e10b4b24c5da65756a9b5 Mon Sep 17 00:00:00 2001 From: Teddy Date: Sun, 4 Aug 2013 11:50:41 +0800 Subject: added exception facilities --- main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index f32dac3..31d7943 100644 --- a/main.cpp +++ b/main.cpp @@ -2,6 +2,7 @@ #include "builtin.h" #include "parser.h" #include "eval.h" +#include "exc.h" #include #ifdef DEBUG @@ -15,6 +16,7 @@ void tree_print(Cons *ptr) { #endif int main() { + //freopen("in", "r", stdin); Tokenizor *tk = new Tokenizor(); ASTGenerator *ast = new ASTGenerator(); Evaluator *eval = new Evaluator(); @@ -24,6 +26,13 @@ int main() { Cons *tree = ast->absorb(tk); if (!tree) break; //tree_print(tree); - printf("%s\n", eval->run_expr(tree)->ext_repr().c_str()); + try + { + printf("%s\n", eval->run_expr(tree)->ext_repr().c_str()); + } + catch (GeneralError &e) + { + printf("An error occured: %s\n", e.get_msg().c_str()); + } } } -- cgit v1.2.3