aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/src/compiler_main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c_compiler/src/compiler_main.cpp')
-rw-r--r--c_compiler/src/compiler_main.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/c_compiler/src/compiler_main.cpp b/c_compiler/src/compiler_main.cpp
index 15276dd..dcc9e09 100644
--- a/c_compiler/src/compiler_main.cpp
+++ b/c_compiler/src/compiler_main.cpp
@@ -1,19 +1,27 @@
#include "node.hpp"
#include "bindings.hpp"
-#include <iostream>
+#include <cstdio>
+#include <string>
Node* parseAST();
int main(int argc, char *argv[])
{
(void)argc, (void)argv;
- std::unique_ptr<Node> ast(parseAST());
-
- VariableStackBindings bindings;
- unsigned label_count = 0;
-
- ast->printAsm(bindings, label_count);
+
+ try {
+ std::unique_ptr<Node> ast(parseAST());
+ VariableStackBindings bindings;
+ unsigned label_count = 0;
+ ast->printAsm(bindings, label_count);
+
+ } catch(std::string error_msg) {
+ fprintf(stderr, "%s\n", error_msg.c_str());
+
+ } catch(...) {
+ fprintf(stderr, "Error : Exception thrown\n");
+ }
return 0;
}