-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
86 lines (77 loc) · 1.55 KB
/
Copy pathmain.c
File metadata and controls
86 lines (77 loc) · 1.55 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include "printer.h"
/*
Main file
by Stefan Dunst, Michael Faisst, Markus Mohanty
*/
extern FILE *yyin;
int main(int argc, char *argv[])
{
/*
check if arguments are valid, exit if not
*/
if(argc < 2)
{
printf("Please enter: epic_parser *in_filename* \n");
return 0;
}
/*
check if file exists
*/
if( access( argv[1], F_OK ) != -1 ) {
/*
open filestreams
*/
yyin = fopen(argv[1],"r");
FILE* astFile = fopen("./output/tree.txt", "w");
FILE* tableFile = fopen("./output/table.txt", "w");
FILE* cfaFile = fopen("./output/CFA.out", "w");
FILE* lifenessFile = fopen("./output/Liveness.out", "w");
/*
check if file to parse is opened
*/
if(yyin)
{
printf("'%s' successfully opened\n",argv[1]);
}
/*
when parsing is done, print success and output files
*/
if(!yyparse())
{
printf("'%s' successfully parsed. Tree in 'tree.txt', symboltable in 'table.txt'\n",argv[1]);
//set_timer();
generateOutput(astFile, tableFile);
generateCFG(cfaFile);
set_timer();
generateLiveliness(lifenessFile);
double time = get_timer();
printf("EPIC TOTAL TIME: %f\n", time);
}
/*
when error occured, print
*/
else
{
printf("Error while parsing. See error message\n");
}
/*
close filestreams
*/
fclose(astFile);
fclose(tableFile);
fclose(cfaFile);
fclose(lifenessFile);
fclose(yyin);
}
/*
when file not exists, print error
*/
else
{
printf("File: '%s' does not exist, please check.\n",argv[1]);
}
return 0;
}