aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index 438f282..1001c51 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,6 +3,7 @@
#include <lexer.h>
#include <string.h>
#include <parser.h>
+#include <backend.h>
#include <print.h>
@@ -24,7 +25,7 @@ int main(int argc,char **argv)
source=extract_source(strndup(options->src_name,100));
translation_data=get_translation_data();
- if(options->target==OPTION_TARGET_TOKENS || options->target==OPTION_TARGET_AST)
+ if(options->target==OPTION_TARGET_TOKENS || options->target==OPTION_TARGET_AST || options->target==OPTION_TARGET_C)
{
lex(translation_data->tokens,source,translation_data);
if(translation_data->errors->size>0)
@@ -35,18 +36,25 @@ int main(int argc,char **argv)
}else if(options->target==OPTION_TARGET_TOKENS)
{
print_tokens(translation_data->tokens);
- }else if(options->target==OPTION_TARGET_AST) //we check because we will probably add more options
+ }else if(options->target==OPTION_TARGET_AST || options->target==OPTION_TARGET_C)
{
- translation_unit=parse_unit(translation_data);
+ //we check because we will probably add more options
+
+
+ translation_unit=parse_source(translation_data);
if(has_new_errors(translation_data))
{
print_errors(translation_data);
return 1;
- }else
+ }
+ if(options->target==OPTION_TARGET_AST)
{
print_ast(translation_unit);
- delete_ast(translation_unit);
+ }else if(options->target==OPTION_TARGET_C)
+ {
+ ast_to_c(stdout,translation_unit);
}
+ delete_ast(translation_unit);
}
}else