diff --git a/src/errors.cpp b/src/errors.cpp index 5309ac7..9db6893 100644 --- a/src/errors.cpp +++ b/src/errors.cpp @@ -11,6 +11,7 @@ void pretty_print_error(vector 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); diff --git a/src/include/input.h b/src/include/input.h index ebb5574..390b11b 100644 --- a/src/include/input.h +++ b/src/include/input.h @@ -8,6 +8,6 @@ using namespace std; /* Retrieves user input */ -vector get_input(); +vector get_input(vector history); #endif \ No newline at end of file diff --git a/src/include/tokenize.h b/src/include/tokenize.h index 6793636..7339572 100644 --- a/src/include/tokenize.h +++ b/src/include/tokenize.h @@ -34,7 +34,7 @@ public: /* Parses a string into a vector of tokens */ -vector tokenize(vector str); +vector tokenize(vector str, int initial_line=0); /* Format and print a Token diff --git a/src/input.cpp b/src/input.cpp index e9bdebd..ed5eb7a 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -8,11 +8,10 @@ using namespace std; -vector get_input() { +vector get_input(vector input) { string buffer; - vector input; - int line_num = 0; + int line_num = input.size(); while (1) { line_num++; printf(BOLD "%4d " RESET , line_num); diff --git a/src/main.cpp b/src/main.cpp index 45e511a..52c27ef 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,8 +25,9 @@ int main(int argc, char* argv[]) { vector 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); diff --git a/src/tokenize.cpp b/src/tokenize.cpp index d7f33e7..6238cfb 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -64,10 +64,10 @@ void _debug_print_tokens(vector tokens) { cout << endl; } -vector tokenize(vector input) { +vector tokenize(vector input, int initial_line) { vector 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;