diff options
author | Teddy <ted.sybil@gmail.com> | 2013-08-04 11:50:41 +0800 |
---|---|---|
committer | Teddy <ted.sybil@gmail.com> | 2013-08-04 11:50:41 +0800 |
commit | 65f17438de5983ca010e10b4b24c5da65756a9b5 (patch) | |
tree | dfa88443d6cd10a14f587377f101e14359e98f56 /main.cpp | |
parent | d42c4bd97982c1252c5ad638a11aea5319c4be7f (diff) |
added exception facilities
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -2,6 +2,7 @@ #include "builtin.h" #include "parser.h" #include "eval.h" +#include "exc.h" #include <cstdio> #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()); + } } } |