-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
56 lines (39 loc) · 1.23 KB
/
main.c
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
45
46
47
48
49
50
51
52
53
54
/*
==========================================
Author: Hendrik Martina
==========================================
*/
#include "lexer.h"
int main() {
char line[1024];
char input[10];
// input es el archivo de entrada
FILE *tokens = fopen("tokens.txt","w");
FILE *errors = fopen("errors.txt","w");
FILE *fp;
printf(BLUE"Input the name of the file you wanna read\n$ "RESET);
scanf("%s", input);
fp = fopen(input,"r");
if(fp == NULL)
{
printf(RED"File not found [press any botton to exit]...");
getchar();
getchar();
exit(0);
}
puts(GREEN"##############################################################################################");
printf("# %-14s %-50s %-10s #\n","Numberline" ,"Lexeme" ,"Token");
puts("##############################################################################################"RESET);
printBorders(tokens,1);
printBorders(errors, 0);
char * TEMP;
int numberLine = 1;
while( fgets(line,1024,fp) ) {
lexerAnalyzer(line, numberLine, errors, tokens);
numberLine++;
}
fclose(fp);
fclose(tokens);
fclose(errors);
return 0;
}