Merge branch 'main' of gitlab.aliens-lyon.fr:alucas03/c-repl into main
This commit is contained in:
commit
1a37e67b2c
@ -11,6 +11,7 @@ void pretty_print_error(vector<string> history, CodePosition pos) {
|
||||
if (pos.column == -1 || pos.line == -1)
|
||||
return;
|
||||
|
||||
cout << endl;
|
||||
string line = history[pos.line];
|
||||
|
||||
printf(BOLD "%4d " RESET , pos.line+1);
|
||||
|
@ -8,6 +8,6 @@ using namespace std;
|
||||
/*
|
||||
Retrieves user input
|
||||
*/
|
||||
vector<string> get_input();
|
||||
vector<string> get_input(vector<string> history);
|
||||
|
||||
#endif
|
@ -34,7 +34,7 @@ public:
|
||||
/*
|
||||
Parses a string into a vector of tokens
|
||||
*/
|
||||
vector<Token> tokenize(vector<string> str);
|
||||
vector<Token> tokenize(vector<string> str, int initial_line=0);
|
||||
|
||||
/*
|
||||
Format and print a Token
|
||||
|
@ -8,11 +8,10 @@ using namespace std;
|
||||
|
||||
|
||||
|
||||
vector<string> get_input() {
|
||||
vector<string> get_input(vector<string> input) {
|
||||
string buffer;
|
||||
vector<string> input;
|
||||
|
||||
int line_num = 0;
|
||||
int line_num = input.size();
|
||||
while (1) {
|
||||
line_num++;
|
||||
printf(BOLD "%4d " RESET , line_num);
|
||||
|
@ -25,8 +25,9 @@ int main(int argc, char* argv[]) {
|
||||
vector<Token> tokens;
|
||||
while (true) {
|
||||
try {
|
||||
input = get_input();
|
||||
tokens = tokenize(input);
|
||||
int initial_line = input.size();
|
||||
input = get_input(input);
|
||||
tokens = tokenize(input, initial_line);
|
||||
|
||||
Node ast = parse(tokens);
|
||||
|
||||
|
@ -64,10 +64,10 @@ void _debug_print_tokens(vector<Token> tokens) {
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
vector<Token> tokenize(vector<string> input) {
|
||||
vector<Token> tokenize(vector<string> input, int initial_line) {
|
||||
vector<Token> tokens;
|
||||
|
||||
for (int i = 0; i < int(input.size()); i++) {
|
||||
for (int i = initial_line; i < int(input.size()); i++) {
|
||||
string line = input[i];
|
||||
int j = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user