-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
70 lines (69 loc) · 2.45 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "header.h"
int main(void) {
int option;
char tmps[400];
while (1) {
system("clear");
// system("cls");// windows 平台请注释上一行,并取消本行注释
printf(" +----------------------------+\n");
printf(" | Choose A Function |\n");
printf(" | 1. Lexical Analysis |\n");
printf(" | 2. Syntax Analysis |\n");
printf(" | 3. Save Formatted File |\n");
printf(" | 0. Exit |\n");
printf(" +----------------------------+\n");
scanf("%d", &option);
switch (option) {
case 1:
printf("请输入源文件路径:\n");
scanf("%s", fileIn);
fr = fopen(fileIn, "r");
if (fr == NULL) {
printf("ERR\n");
}
lexicalAnalyse();
fclose(fr);
printf("Press any key to continue\n");
getchar();
getchar();
break;
case 2:
printf("请输入源文件路径:\n");
scanf("%s", fileIn);
fr = fopen(fileIn, "r");
syntaxAnalyse();
printf("Press any key to continue\n");
fclose(fr);
getchar();
getchar();
break;
case 3:
printf("请输入源文件路径:\n");
scanf("%s", fileIn);
fr = fopen(fileIn, "r");
printf("请输入目标文件路径:\n");
scanf("%s", fileOut);
fw = fopen(fileOut, "w");
formatCode();
printf("Press any key to continue\n");
fclose(fr);
fclose(fw);
// sprintf(tmps, "code -d %s %s", fileIn, fileOut);
// system(tmps); // 快捷查看格式化后的文件
getchar();
getchar();
break;
case 0:
system("clear");
// system("cls");// windows 平台请注释上一行,并取消本行注释
printf("Thanks for using!\n");
return 0;
default:
printf("Unknown key, please enter again\n");
printf("Press any key to continue\n");
getchar();
getchar();
break;
}
}
}