forked from Kapcash/Compilation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource.cpp
92 lines (78 loc) · 2.1 KB
/
Source.cpp
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
87
88
89
90
91
92
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
void manual() {
printf("\n");
printf("========== NAME\n");
printf("\n");
printf("The WHILE pretty-printer\n");
printf("\n");
printf("========== SYNOPSIS\n");
printf("\n");
printf("whpp fichier [-o file, -all x, -if x] \n");
printf("\n\n ou \n\n");
printf("whpp --help \n");
printf("\n");
printf("\n");
printf("========== DESCRIPTION\n");
printf("\n");
printf("Lit un fichier while syntaxiquement correct et rend le même fichier mais joliment composé.\n");
printf("\n");
printf("========== OPTIONS\n");
printf("\n");
printf("-o file\n");
printf("file : nom du fichier de sortie, par defaut (sth.whpp)\n\n");
printf("-all x\n");
printf("x : valeur par defaut de l'indentation, par defaut (x=2)\n\n");
printf("\n");
printf("\n");
printf("========== SEE ALSO\n");
printf("\n");
printf("\n");
printf("========== AUTHORS\n");
printf("\n");
printf("Programme realise par Dylan BEHETRE, Yoann BOYERE, Alexis BRAULT, Mehidine CHUPEAU, Florent CATIAU, Quentin OLIVIER");
printf("\n");
printf("\n");
printf("==================== \n");
}
int main(int argc, char *argv[]) {
if (argc<2 && argc % 2 != 0) {
manual();
return 0;
}
int arg_all = 2,
arg_if = 0,
debug = 0;
std::string arg_fileSrc,
arg_fileDest = "sth.whpp";
if (strcmp("--help", argv[1]) == 0) {
manual();
return 0;
}
arg_fileSrc = argv[1];
int i = 0;
for (i = 2; i<argc; i = i + 2) {
if (strcmp("-all", argv[i]) == 0) {
arg_all = atoi(argv[i + 1]);
continue;
}
if (strcmp("-o", argv[i]) == 0) {
arg_fileDest = argv[i + 1];
continue;
}
if (strcmp("-debug", argv[i]) == 0) {
debug = atoi(argv[i + 1]);
continue;
}
}
std::string cmdLine = "java -jar whilepp2.jar " + arg_fileSrc + " " + arg_fileDest + " "+ std::to_string(arg_all);
if (debug) {
std::cout << "CMD : " << cmdLine << std::endl;
std::cout << "ALL : " << arg_all << std::endl;
std::cout << std::endl;
}
int status = system(cmdLine.c_str());
return 0;
}