-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
73 lines (65 loc) · 2.35 KB
/
Copy pathmain.cpp
File metadata and controls
73 lines (65 loc) · 2.35 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ael-kadh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/05/04 16:18:51 by ael-kadh #+# #+# */
/* Updated: 2015/05/08 19:55:35 by ael-kadh ### ########.fr */
/* */
/* ************************************************************************** */
#include "Parse.hpp"
#include "IOperand.hpp"
#include "Factory.hpp"
#include "Emulator.hpp"
void emulate(t_instruct instruct, bool rainbow) {
Emulator fac = Emulator(rainbow);
for(auto& ins : instruct)
fac.Execute(ins);
}
int main(int ac, char **av) {
bool rainbow = false;
bool info = false;
if (ac < 2)
{
try {
t_instruct instruct = Parse::getInstructions(info);
std::cout << std::endl;
emulate(instruct, rainbow);
} catch (std::runtime_error &e) {
std::cout << e.what() << std::endl;
}
}
else
{
for (int i = 1; i < ac; i++)
{
if (std::string(av[i]) == "-rainbow")
rainbow = true;
if (std::string(av[i]) == "-info")
info = true;
}
if (ac == 2 && std::string(av[1]) == "-rainbow")
{
try {
t_instruct instruct = Parse::getInstructions(info);
emulate(instruct, rainbow);
} catch (std::runtime_error &e) {
std::cout << e.what() << std::endl;
}
}
for (int i = 1; i<ac; i++)
{
if (std::string(av[i]) == "-rainbow" || std::string(av[i]) == "-info")
continue;
try {
t_instruct instruct = Parse::getInstructions(std::string(av[i]), info);
emulate(instruct, rainbow);
} catch (std::runtime_error &e) {
std::cout << av[i] << " : " << e.what() << std::endl;
}
}
}
return 0;
}