From 85b23fbee717f047af5a89eac6f4dba8e7812524 Mon Sep 17 00:00:00 2001 From: Galin Simeonov Date: Tue, 1 Jun 2021 18:21:02 +0300 Subject: restructuring --- src/main.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/main.c') 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 #include #include +#include #include @@ -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 -- cgit v1.2.3