c-repl/src/errors.cpp

24 lines
504 B
C++
Raw Normal View History

2023-11-15 14:37:20 +01:00
#include <vector>
#include <string>
#include <iostream>
using namespace std;
#include "include/colors.h"
#include "include/tokenize.h"
2023-12-15 14:52:46 +01:00
void print_error_position(vector<string> history, CodePosition pos) {
2023-11-15 14:37:20 +01:00
if (pos.column == -1 || pos.line == -1)
return;
2023-11-15 16:08:05 +01:00
cout << endl;
2023-11-15 14:37:20 +01:00
string line = history[pos.line];
printf(BOLD "%4d " RESET , pos.line+1);
cout << line << endl;
for (int i=0; i < pos.column + 5; i++)
cout << " ";
cout << BOLD RED "^--" RESET << endl;
}