Made nice parsing errors
This commit is contained in:
@@ -1,4 +1,15 @@
|
|||||||
#include "RNGLRParser.h"
|
#include "RNGLRParser.h"
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
//sorry about the macros
|
||||||
|
#define RESET "\033[0m"
|
||||||
|
#define BOLDRED "\033[1m\033[31m"
|
||||||
|
#define BOLDWHITE "\033[1m\033[37m"
|
||||||
|
#define BOLDGREEN "\033[1m\033[32m"
|
||||||
|
#define BOLDYELLOW "\033[1m\033[33m"
|
||||||
|
#define BOLDBLUE "\033[1m\033[34m"
|
||||||
|
#define BOLDMAGENTA "\033[1m\033[35m"
|
||||||
|
#define BOLDCYAN "\033[1m\033[36m"
|
||||||
|
|
||||||
RNGLRParser::RNGLRParser() {
|
RNGLRParser::RNGLRParser() {
|
||||||
//
|
//
|
||||||
@@ -107,25 +118,24 @@ NodeTree<Symbol>* RNGLRParser::parseInput(std::string inputString, std::string f
|
|||||||
//std::cout << "Frontier " << i << " is empty." << std::endl;
|
//std::cout << "Frontier " << i << " is empty." << std::endl;
|
||||||
//std::cerr << "Parsing failed on " << input[i].toString() << std::endl;
|
//std::cerr << "Parsing failed on " << input[i].toString() << std::endl;
|
||||||
//std::cerr << "Problem is on line: " << findLine(i) << std::endl;
|
//std::cerr << "Problem is on line: " << findLine(i) << std::endl;
|
||||||
std::cerr << filename << ":" << findLine(i) << std::endl;
|
// std::cerr << filename << ":" << findLine(i) << std::endl;
|
||||||
errord = true;
|
errord = true;
|
||||||
std::cerr << "parse error" << std::endl;
|
std::cout << BOLDMAGENTA << "parse error" << std::endl;
|
||||||
std::cerr << "Nearby is:" << std::endl;
|
|
||||||
int range = 10;
|
std::cout << BOLDWHITE << "Error at: " << BOLDBLUE << filename << ":" << findLine(i) << std::endl;
|
||||||
for (int j = (i-range >= 0 ? i-range : 0); j < (i+range < input.size() ? i+range : input.size()); j++)
|
|
||||||
if (j == i)
|
std::ifstream infile(filename);
|
||||||
std::cerr << "||*||*||" << input[j].toString() << "||*||*|| ";
|
std::string line;
|
||||||
else
|
int linecount = 0;
|
||||||
std::cerr << input[j].toString() << " ";
|
while(std::getline(infile,line))
|
||||||
std::cerr << std::endl;
|
{
|
||||||
range = 1;
|
if(linecount == findLine(i) - 1)
|
||||||
/* std::cout << "\n\n\nThe states in the GSS at last frontiers:" << std::endl;
|
std::cout << BOLDRED << line << std::endl;
|
||||||
for (int j = (i-range >= 0 ? i-range : 0); j < i; j++) {
|
linecount++;
|
||||||
std::cout << "Frontier:" << j << " (would get): " << input[j].toString() << std::endl;
|
|
||||||
printReconstructedFrontier(j);
|
|
||||||
}
|
}
|
||||||
std::cout << "\n\n\n\n" << std::endl;
|
std::cout << RESET << std::endl;
|
||||||
*/ break;
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clear the vector of SPPF nodes created every step
|
//Clear the vector of SPPF nodes created every step
|
||||||
|
|||||||
Reference in New Issue
Block a user