aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorAdam Branes <adam@adam>2021-05-02 17:46:29 +0300
committerGalin Simeonov <gts@volconst.com>2021-07-15 18:00:07 +0300
commit679cbe58c4e53f0163588a7731154f3afe2d25aa (patch)
treea2dbc2317a3f107899d60f5e68c8d6cf8d27e146 /main.c
parenta3e36c1918e63761dfc4d2221cca3636b98e93aa (diff)
downloadMEGATRON-679cbe58c4e53f0163588a7731154f3afe2d25aa.tar.gz
lexer formed
Diffstat (limited to 'main.c')
-rw-r--r--main.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/main.c b/main.c
index 79018d6..bfc09c0 100644
--- a/main.c
+++ b/main.c
@@ -1,9 +1,44 @@
#include<stdio.h>
+#include<program.h>
#include<lexer.h>
+#include<string.h>
+#include<print.h>
-int main()
+int main(int argc,char **argv)
{
+ struct Options *options;
+ struct Source *source;
+ struct Program *program;
+ struct Translation_Data *translation_data;
+
+ options=parse_command_line(argv);
+ if(options->source==NULL)
+ {
+ printf("No source file specified\n");
+ return 0;
+ }
+ source=extract_source(strdup(options->source));
+ translation_data=get_translation_data();
+
+
+ if(options->print_tokens)
+ {
+ lex(translation_data->tokens,source,translation_data);
+ if(translation_data->errors->size>0)
+ {
+ printf("There was an error!\n");
+ print_tokens(translation_data->tokens);
+ return 1;
+ }else
+ {
+ print_tokens(translation_data->tokens);
+ }
+
+ }
+
+ delete_source(source);
+ delete_options(options);
return 0;
}