[DEV] might work, but not at all
This commit is contained in:
parent
9e770c657b
commit
7eba645b45
@ -18,20 +18,35 @@ eci::Lexer::~Lexer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void eci::Lexer::append(int32_t _tokenId, const std::string& _regularExpression) {
|
void eci::Lexer::append(int32_t _tokenId, const std::string& _regularExpression) {
|
||||||
m_searchList.insert(std::make_pair(_tokenId, std::regex(_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 << "'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eci::LexerResult eci::Lexer::interprete(const std::string& _data) {
|
eci::LexerResult eci::Lexer::interprete(const std::string& _data) {
|
||||||
eci::LexerResult result;
|
eci::LexerResult result;
|
||||||
|
ECI_INFO("Parse : \n" << _data);
|
||||||
for (auto &it : m_searchList) {
|
for (auto &it : m_searchList) {
|
||||||
ECI_INFO("Parse RegEx : " << it.first);// << " : '" << it.second.str() << "'");
|
ECI_INFO("Parse RegEx : " << it.first);// << " : '" << it.second.str() << "'");
|
||||||
std::sregex_iterator it_search(_data.begin(), _data.end(), it.second);
|
std::smatch m;
|
||||||
std::sregex_iterator it_end;
|
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) {
|
for (std::sregex_iterator i = it_search; i != it_end; ++i) {
|
||||||
std::smatch match = *i;
|
std::smatch match = *i;
|
||||||
std::string match_str = match.str();
|
std::string match_str = "eee";//match.str();
|
||||||
ECI_INFO(" " << match_str);
|
ECI_INFO(" " << match_str);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ int main(int argc, char** argv) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
eci::ParserCpp tmpParser;
|
eci::ParserCpp tmpParser;
|
||||||
std::string data = etk::FSNodeReadAllData(argv[1]);
|
std::string data = "/* plop */ \n int main(void) {\n return 0;\n}\n";//etk::FSNodeReadAllData(argv[1]);
|
||||||
tmpParser.parse(data);
|
tmpParser.parse(data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -11,12 +11,14 @@
|
|||||||
enum cppTokenList {
|
enum cppTokenList {
|
||||||
tokenCppMultilineComment,
|
tokenCppMultilineComment,
|
||||||
tokenCppSingleLineComment,
|
tokenCppSingleLineComment,
|
||||||
|
tokenCppString,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
eci::ParserCpp::ParserCpp() {
|
eci::ParserCpp::ParserCpp() {
|
||||||
m_lexer.append(tokenCppMultilineComment, "/\\*.*\\*/");
|
m_lexer.append(tokenCppMultilineComment, "/\\*.*\\*/");
|
||||||
m_lexer.append(tokenCppSingleLineComment, "//$");
|
m_lexer.append(tokenCppSingleLineComment, "//$");
|
||||||
|
m_lexer.append(tokenCppString, "[a-z]");
|
||||||
}
|
}
|
||||||
|
|
||||||
eci::ParserCpp::~ParserCpp() {
|
eci::ParserCpp::~ParserCpp() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user