diff --git a/eci/Lexer.cpp b/eci/Lexer.cpp index 9e12fa4..4b369cd 100644 --- a/eci/Lexer.cpp +++ b/eci/Lexer.cpp @@ -18,25 +18,27 @@ eci::Lexer::~Lexer() { } void eci::Lexer::append(int32_t _tokenId, const std::string& _regularExpression) { - try { - m_searchList.insert(std::make_pair(_tokenId, std::regex(_regularExpression, std::regex_constants::basic))); - } catch (std::regex_error e) { - ECI_ERROR("plop : " << e.what() << " from '" << _regularExpression << "'"); - } + m_searchList.insert(std::make_pair(_tokenId, etk::RegExp(_regularExpression))); + etk::RegExp(_regularExpression).display(); } eci::LexerResult eci::Lexer::interprete(const std::string& _data) { eci::LexerResult result; - ECI_INFO("Parse : \n" << _data); + ECI_INFO("Parse : \n" << _data); for (auto &it : m_searchList) { - ECI_INFO("Parse RegEx : " << it.first);// << " : '" << it.second.str() << "'"); + 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()) << "'"); + } + /* std::smatch m; std::regex_search (_data, m, it.second); for (unsigned i=0; i #include -#include +#include #include #include @@ -21,7 +21,7 @@ namespace eci { class Lexer { private: - std::map m_searchList; + std::map> m_searchList; public: Lexer(); ~Lexer(); diff --git a/eci/eci.cpp b/eci/eci.cpp index e133f73..fe86047 100644 --- a/eci/eci.cpp +++ b/eci/eci.cpp @@ -18,7 +18,7 @@ int main(int argc, char** argv) { return -1; } eci::ParserCpp tmpParser; - std::string data = "/* plop */ \n int main(void) {\n return 0;\n}\n";//etk::FSNodeReadAllData(argv[1]); + std::string data = "/* plop */ \n int eee = 22; // error value \nint main(void) {\n return 0;\n}\n";//etk::FSNodeReadAllData(argv[1]); tmpParser.parse(data); return 0; diff --git a/eci/lang/ParserCpp.cpp b/eci/lang/ParserCpp.cpp index 9084689..1c0b828 100644 --- a/eci/lang/ParserCpp.cpp +++ b/eci/lang/ParserCpp.cpp @@ -17,7 +17,7 @@ enum cppTokenList { eci::ParserCpp::ParserCpp() { m_lexer.append(tokenCppMultilineComment, "/\\*.*\\*/"); - m_lexer.append(tokenCppSingleLineComment, "//$"); + m_lexer.append(tokenCppSingleLineComment, "//.*$"); m_lexer.append(tokenCppString, "[a-z]"); }