-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrpythagore.cpp
48 lines (39 loc) · 906 Bytes
/
drpythagore.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
#include <iostream>
#include <readline/history.h>
#include <readline/readline.h>
#include "lexer.h"
#include "stack.h"
using namespace std;
using namespace DP;
/* The string containing the entered line */
static char *line_read = nullptr;
char *rl_gets()
{
if (line_read) {
free(line_read);
line_read = NULL;
}
/* Get a line from the user */
line_read = readline(">> ");
/* If the line has any text in it, save it on the history */
if (line_read && *line_read)
add_history(line_read);
return line_read;
}
int main()
{
Plane plane;
Lexer lexer(&plane);
do {
char *ret = rl_gets();
if (ret == NULL || strcmp(ret, "quit") == 0)
break;
if (*ret) {
lexer.parse(ret);
cout << "\t" << lexer.getResult() << endl;
}
}
while (true);
cout << endl;
return 0;
}