-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
48 lines (39 loc) · 999 Bytes
/
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
/* Main program for eineshell */
#include <stdlib.h>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include "src/environment.h"
#include "src/shell.h"
#include "src/parser.h"
#include "src/execute.h"
using std::cout;
using std::string;
using std::vector;
void run_repl_loop();
void print_prompt();
int main(int argc, char **argv) {
set_up_environment(argc, argv);
set_up_shell();
// RUN LOOP
run_repl_loop();
// RETURN STATUS CODE
return EXIT_SUCCESS;
}
void run_repl_loop() {
std::string input;
std::vector<std::string> tokens;
int exit_called = 0;
do {
print_prompt();
input = read_input_line();
if(input.length() > 0) {
tokens = parse_into_tokens(input);
exit_called = execute_command(tokens);
}
} while (!exit_called);
}
void print_prompt() {
std::cout << ENV_VARS_MAP[std::string("PROMPT")] << " " << ENV_VARS_MAP[std::string("USERNAME")] << " >> ";
}