diff options
author | Galin Simeonov <gts@volconst.com> | 2021-06-01 18:21:02 +0300 |
---|---|---|
committer | Galin Simeonov <gts@volconst.com> | 2021-07-15 18:03:43 +0300 |
commit | 85b23fbee717f047af5a89eac6f4dba8e7812524 (patch) | |
tree | dc88ef3f4cb826f4f3a3c9e12c67562878460aa5 /src/main.c | |
parent | 255a49ba5a41b3854dbdfebdec75fb6229450507 (diff) | |
download | MEGATRON-85b23fbee717f047af5a89eac6f4dba8e7812524.tar.gz |
restructuring
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -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 |