[DEV] add test for regExp

This commit is contained in:
Edouard DUPIN 2014-07-20 20:21:33 +02:00
parent d5365428ea
commit d92b12b3e1
3 changed files with 6 additions and 19 deletions

View File

@ -29,26 +29,8 @@ eci::LexerResult eci::Lexer::interprete(const std::string& _data) {
ECI_INFO("Parse RegEx : " << it.first << " : " << it.second.getRegExDecorated());
if (it.second.parse(_data, 0, _data.size()) == true) {
ECI_INFO(" match [" << it.second.start() << ".." << it.second.stop() << "] ");
ECI_INFO(" ==> '" << std::string(_data, it.second.start(), it.second.stop()) << "'");
ECI_INFO(" ==> '" << std::string(_data, it.second.start(), it.second.stop()-it.second.start()) << "'");
}
/*
std::smatch m;
std::regex_search (_data, m, it.second);
for (unsigned i=0; i<m.size(); ++i) {
ECI_INFO(" match " << i << " (" << m[i] << ") ");
ECI_INFO(" @ " << m.position(i) );
}
*/
//std::regex_iterator it_search(_data.begin(), _data.end(), it.second);
//std::sregex_iterator it_end;
/*
for (std::sregex_iterator i = it_search; i != it_end; ++i) {
std::smatch match = *i;
std::string match_str = "eee";//match.str();
ECI_INFO(" " << match_str);
}
*/
}
return result;
}

View File

@ -12,6 +12,8 @@
#include <etk/os/FSNode.h>
int main(int argc, char** argv) {
etk::log::setLevel(etk::log::logLevelDebug);
etk::log::setLevel(etk::log::logLevelInfo);
ECI_INFO("Start Application interpeter languages");
if (argc<=1) {
ECI_CRITICAL("need the file to parse");
@ -19,6 +21,8 @@ int main(int argc, char** argv) {
}
eci::ParserCpp tmpParser;
std::string data = "/* plop */ \n int eee = 22; // error value \nint main(void) {\n return 0;\n}\n";//etk::FSNodeReadAllData(argv[1]);
//std::string data = "alpha /* plop */ test";
//std::string data = "pp \n // qdfqdfsdf \nde";
tmpParser.parse(data);
return 0;

View File

@ -18,6 +18,7 @@ enum cppTokenList {
eci::ParserCpp::ParserCpp() {
m_lexer.append(tokenCppMultilineComment, "/\\*.*\\*/");
m_lexer.append(tokenCppSingleLineComment, "//.*$");
m_lexer.append(82939, "/\\*.*");
m_lexer.append(tokenCppString, "[a-z]");
}