aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2013-08-04 11:50:41 +0800
committerTeddy <ted.sybil@gmail.com>2013-08-04 11:50:41 +0800
commit65f17438de5983ca010e10b4b24c5da65756a9b5 (patch)
treedfa88443d6cd10a14f587377f101e14359e98f56 /main.cpp
parentd42c4bd97982c1252c5ad638a11aea5319c4be7f (diff)
added exception facilities
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp11
1 files changed, 10 insertions, 1 deletions
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 <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());
+ }
}
}