aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
blob: bfc09c09133874ca7d04053e677768962d3834fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<stdio.h>
#include<program.h>
#include<lexer.h>
#include<string.h>
#include<print.h>



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;
}