-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (46 loc) · 1.21 KB
/
main.cpp
File metadata and controls
60 lines (46 loc) · 1.21 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
#include "main.h"
#include "object.h"
#include "lispString.h"
#include "number.h"
#include "symbolsList.h"
#include "nil.h"
#include "doublet.h"
#include "lispFunctions.h"
#include "read.h"
#include <iostream>
#include <vector>
#include <sstream>
int main(int argc, char * argv[]) {
if (argc == 1)
return readEvalPrintLoop();
if (argc == 2)
return execute(argv[1]);
else {
cout << "L'intepréteur doit être lancé soit sans argument pour démarrer l'interpréteur soit avec un seul argument qui sera le fichier à exécuter" << endl;
return 0;
}
}
int readEvalPrintLoop() {
bool finished = false;
while (not finished) {
std::string input;
std::cout << "> ";
std::getline(std::cin, input);
if (input == "exit")
finished = true;
else if (input != "") {
try {
std::stringstream stream(input);
Read * toRead = new Read(stream);
toRead->read();
std::cout << input << endl;
} catch (exception& e) {
std::cout << e.what() << endl;
}
}
}
return 0;
}
int execute(string fileName) {
return 0;
}