-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
84 lines (72 loc) · 2.23 KB
/
main.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
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include <sys/stat.h>
#include <cstring>
#include "Scanner.h"
#include "Parser.h"
using namespace std;
int main(int argc, char *argv[]) {
std::cout << argc << " " << argv[1] << std::endl;
vector<CwithClasses> files;
for (int i = 1; i < argc; i++) {
ifstream in(argv[i]);
string accumulator;
char currentChar;
while (in.peek() != EOF) {
in.get(currentChar);
accumulator += currentChar;
}
cout << "Making Tokens" << endl;
Scanner scanner(accumulator);
vector<Token> tokens;
Token currToken = scanner.scanToken();
tokens.push_back(currToken);
while (scanner.getSize() != 0) {
currToken = scanner.scanToken();
tokens.push_back(currToken);
//cout << currToken << endl;
}
cout << tokens.size() << " tokens" << endl;
/*for (auto token : tokens) {
//cout << token << endl;
}*/
stringstream headerName = stringstream(argv[i]);
string name;
getline(headerName,name,'.');
cout << "Parsing Tokens" << endl;
Parser parser(tokens);
CwithClasses file = parser.startParsing();
for (auto& clasS : file.getClasses()) {
clasS.setHeader(argv[i]);
}
file.setName(name);
files.push_back(file);
in.close();
}
for(size_t i = files.size()-1; i < files.size(); i--) {
files.at(i).setupInheritance(files);
}
for(size_t i = 0; i < files.size(); i++) {
files.at(i).setupInheritance(files);
}
/*for (auto& file : files) {
for (auto& claSS : file.getClasses()) {
claSS.initializeConstructDeconstruct();
}
}*/
if (mkdir("output", 0777) == -1)
cerr << "Error : " << strerror(errno) << endl;
else
cout << "Directory created";
for (auto file :files) {
ofstream header("output/" + file.getName() + ".h");
ofstream source("output/" + file.getName() + ".c");
header << file.makeHeaderFile();
source << file.makeSourceFile();
header.close();
source.close();
}
return 0;
}