More work for includes, still commented out. Tokenizer needs #file handling
This commit is contained in:
parent
0177f77505
commit
3f98024215
|
@ -24,6 +24,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#include <ctype>
|
#include <ctype>
|
||||||
|
@ -255,11 +256,10 @@ void Preprocessor::preprocess(std::istream &istr, std::string &processedFile, st
|
||||||
// Remove space characters that are after or before new line character
|
// Remove space characters that are after or before new line character
|
||||||
processedFile = removeSpaceNearNL(processedFile);
|
processedFile = removeSpaceNearNL(processedFile);
|
||||||
|
|
||||||
processedFile = replaceIfDefined(processedFile);
|
|
||||||
|
|
||||||
// TODO, uncomment below when handling of includes is implemented well enough
|
|
||||||
// processedFile = handleIncludes(processedFile);
|
// processedFile = handleIncludes(processedFile);
|
||||||
|
|
||||||
|
processedFile = replaceIfDefined(processedFile);
|
||||||
|
|
||||||
// Get all possible configurations..
|
// Get all possible configurations..
|
||||||
resultConfigurations = getcfgs(processedFile);
|
resultConfigurations = getcfgs(processedFile);
|
||||||
}
|
}
|
||||||
|
@ -487,9 +487,22 @@ std::string Preprocessor::handleIncludes(std::string code)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// filename contains now a file name e.g. "menu.h"
|
// filename contains now a file name e.g. "menu.h"
|
||||||
|
std::ifstream fin(filename.c_str());
|
||||||
|
std::string processedFile = Preprocessor::read(fin);
|
||||||
|
if (processedFile.length() > 0)
|
||||||
|
{
|
||||||
|
// Replace all tabs with spaces..
|
||||||
|
std::replace(processedFile.begin(), processedFile.end(), '\t', ' ');
|
||||||
|
|
||||||
// TODO, add the file here, except do not mess up with the line numbers.
|
// Remove all indentation..
|
||||||
// So me must tokenize, before we can append.
|
if (!processedFile.empty() && processedFile[0] == ' ')
|
||||||
|
processedFile.erase(0, processedFile.find_first_not_of(" "));
|
||||||
|
|
||||||
|
// Remove space characters that are after or before new line character
|
||||||
|
processedFile = removeSpaceNearNL(processedFile);
|
||||||
|
processedFile = "#file " + filename + "\n" + processedFile + "#endfile";
|
||||||
|
code.insert(pos, processedFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
void preprocess(std::istream &istr, std::string &processedFile, std::list<std::string> &resultConfigurations);
|
void preprocess(std::istream &istr, std::string &processedFile, std::list<std::string> &resultConfigurations);
|
||||||
|
|
||||||
/** Just read the code into a string. Perform simple cleanup of the code */
|
/** Just read the code into a string. Perform simple cleanup of the code */
|
||||||
std::string read(std::istream &istr);
|
static std::string read(std::istream &istr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get preprocessed code for a given configuration
|
* Get preprocessed code for a given configuration
|
||||||
|
|
Loading…
Reference in New Issue