28 if(configFile ==
"")
return false;
34 std::cerr <<
"PMultiFileParser::load : can't open file '" << configFile <<
"'" << std::endl;
51 p_parser->setFileContent(fileContent);
59 std::cerr <<
"PMultiFileParser::fullParsing : the parser is not initialised, please call PMultiFileParser::load or PMultiFileParser::setFileContent before this function" << std::endl;
63 bool isParseGood(
true);
65 long unsigned int currentPos =
p_parser->getCurrentCharIdx();
68 std::cerr <<
"PMultiFileParser::fullParsing : the parser is stucked at the position :" << std::endl <<
"\t" <<
p_parser->getLocation() << std::endl;
127 std::cerr <<
"\033[31mError at " <<
p_parser->getLocation() <<
" :\033[0m" << std::endl;
133 std::cerr <<
"PMultiFileParser::parseFile : unexpected token '"<<
p_parser->getNextToken()<<
"'" << std::endl;
139 std::cerr <<
"\tAt row :\n" <<
p_parser->getCurrentRow() << std::endl;
140 for(
size_t i(0lu); i <
p_parser->getColumn(); ++i){
143 std::cerr <<
"^" << std::endl;
154 std::cerr <<
"Unexpected token '"<<
p_currentToken<<
"'" << std::endl;
155 std::cerr <<
"Expected token '"<<tokenExpected<<
"'" << std::endl;
156 if(tokenBefore !=
"") std::cerr <<
" after " << tokenBefore << std::endl;
167 if(
p_parser->isMatch(tokenExpected))
return true;
169 std::cerr <<
"Unexpected token '"<<
p_parser->getNextToken()<<
"'" << std::endl;
170 std::cerr <<
"Expected token '"<<tokenExpected<<
"'" << std::endl;
171 if(tokenBefore !=
"") std::cerr <<
" after " << tokenBefore << std::endl;
178 bool isCommentFound(
false);
180 isCommentFound =
false;
185 isCommentFound =
true;
218 return p_parser->isMatchRewind(token);
230 return p_parser->isMatchSeq(patern, alwaysPopBack);
243 return p_parser->isMatch(patern, forbiddenCharBefore);
265 return p_parser->isMatchToken(vecToken);
276 return p_parser->getStrComposedOf(charset);
284 bool currentTokenIsComment(
true);
285 while(currentTokenIsComment &&
p_run && !
p_parser->isEndOfFile()){
287 currentTokenIsComment =
false;
291 currentTokenIsComment =
true;
std::pair< PString, PString > PMultiCommentConfig
Describes a comment config.
#define MULTI_PARSER_SEPARATORS_STRING
classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
void setFileContent(const PString &fileContent)
Set the file content to be parsed.
bool isMatchSeq(const PVecString &patern, bool alwaysPopBack=false)
Match a sequence of token in a vector.
virtual ~PMultiFileParser()
Destructeur of PMultiFileParser.
void getCurrentTokenWithoutComment()
Get the current token and skip the comment.
const PString & getLastComment() const
Get the last comment.
virtual void postLoadFile()
Post load file.
PMultiFileParser(const PPath &inputDirectory=PPath(), const PPath &outputDirectory=PPath())
Default constructeur of PMultiFileParser.
PString isMatchToken(const PVecString &vecToken)
Check the matching between the current caracters and all the string in the vector but treats the stri...
PPath p_inputDirectory
Input directory of the parser.
bool load(const PPath &configFile)
Load the PMultiFileParser with the configFile.
virtual bool parseFile()=0
void clearComment()
Clear comment.
PString getStrComposedOf(const PString &charset)
Get the string composed of charset charcters.
virtual void preLoadFile()
Pre load file.
std::list< PFileParser > p_listFileParser
List of all the parsers for all the loaded files.
bool isMatch(const PString &token)
Check if the given token matches the current read file.
void errorAt()
Write a parsing error.
void initialisationPMultiFileParser(const PPath &inputDirectory, const PPath &outputDirectory)
Initialisation function of the class PMultiFileParser.
void unexpectedToken()
Print unexpected token error.
PString p_lastComment
last comment
void pointAtRow()
Point the problem.
bool checkExpectedToken(const PString &tokenExpected, const PString &tokenBefore="")
Check if the p_currentToken == tokenExpected.
PFileParser * p_parser
Parser helper for the config file.
bool fullParsing()
Perform the full parsing pf data.
bool p_run
Run the parsing if true.
void addCommentConfig(const PMultiCommentConfig &commentConfig)
Adds a comment config for the parser.
bool isMatchRewind(const PString &token)
Check if the given token matches the current read file and goes back even if the token matches.
PListMultiCommentConfig p_listCommentConfig
Defines the differents comments we allow in the parsing.
void stopParsing()
Stop the parsing of all the files.
bool checkExpectedMatch(const PString &tokenExpected, const PString &tokenBefore="")
Check if the tokenExpected match.
PFileParser * getCurrentParser()
Gets the current parser.
PString p_currentToken
CurrentToken parsed.
PPath p_outputDirectory
Output directory of the parser.
void skipComment()
Skip comment.