[DEBUG] correction of end of file regexp change

This commit is contained in:
Edouard DUPIN 2014-10-08 21:32:41 +02:00
parent 7952872980
commit 67a08dd775
4 changed files with 95 additions and 138 deletions

View File

@ -10,43 +10,51 @@
<ext>*.m</ext> <ext>*.m</ext>
<ext>*.mm</ext> <ext>*.mm</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification --> <pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline doxygen"> <rule name="doxygen multiline">
<color>commentDoxygen</color> <color>commentDoxygen</color>
<regex>/\*\*(.|\r|\n)*?\*/</regex> <regex>/\*(\*|!)(.|\r|\n)*?\*/</regex>
</rule> </rule>
<rule name="code Review"> <rule name="comment multiline TODO">
<color>SYNTAX_ERROR</color> <color>SYNTAX_ERROR</color>
<regex>/\*[ \t]*TODO :(.|\r|\n)*?\*/</regex> <regex>/\*[ \t]*TODO :(.|\r|\n)*?(\*/|\0)</regex>
</rule> </rule>
<rule name="my comment multiline"> <rule name="comment multiline">
<color>comment</color> <color>comment</color>
<regex>/\*(.|\r|\n)*?\*/</regex> <regex>/\*(.|\r|\n)*?(\*/|\0)</regex>
</rule> </rule>
<rule name="my if 0"> <rule name="comment miltiline ERROR">
<color>SYNTAX_ERROR</color>
<regex>/\*(.|\r|\n)*</regex>
</rule>
<rule name="#if 0">
<color>preprocesseur</color> <color>preprocesseur</color>
<regex>#[ \t]*if 0(.|\r|\n)*?#(endif|else)</regex> <regex>#[ \t]*if 0(.|\r|\n)*?(#endif|else)</regex>
</rule> </rule>
<rule name="my preprocesseur"> <rule name="#if 0 ERROR">
<color>SYNTAX_ERROR</color>
<regex>#[ \t]*if 0(.|\r|\n)*</regex>
</rule>
<rule name="#preproc">
<color>preprocesseur</color> <color>preprocesseur</color>
<regex>#(.|\\[\\\n])*</regex> <regex>#(.|\\[\\\n])*</regex>
</rule> </rule>
<rule name="my comment doxygen"> <rule name="inline doxygen">
<color>commentDoxygen</color> <color>commentDoxygen</color>
<regex>//!.*</regex> <regex>//!.*</regex>
</rule> </rule>
<rule name="my todo comment"> <rule name="inline comment TODO">
<color>SYNTAX_ERROR</color> <color>SYNTAX_ERROR</color>
<regex>//[ \t]*TODO[ \t]*:.*</regex> <regex>//[ \t]*TODO[ \t]*:.*</regex>
</rule> </rule>
<rule name="my comment"> <rule name="inline comment">
<color>comment</color> <color>comment</color>
<regex>//.*</regex> <regex>//.*</regex>
</rule> </rule>
<rule name="doubleQuteText"> <rule name="double quote text">
<color>doubleQuoteText</color> <color>doubleQuoteText</color>
<regex>"(.|\\[\\"])*"</regex> <regex>"(.|\\[\\"])*?"</regex> <!-- " -->
</rule> </rule>
<rule name="simpleQuteText"> <rule name="simple quote text">
<color>doubleQuoteText</color> <color>doubleQuoteText</color>
<regex>'\\?.'</regex> <regex>'\\?.'</regex>
</rule> </rule>

View File

@ -723,7 +723,7 @@ void appl::Buffer::regenerateHighLightAt(int64_t _pos, int64_t _nbDeleted, int64
return; return;
} }
// normal case // normal case
//APPL_INFO("(pos="<<pos<<", nbDeleted="<<nbDeleted<<", nbAdded=" << nbAdded << "\");"); APPL_VERBOSE("(_pos="<<_pos<<", _nbDeleted="<<_nbDeleted<<", _nbAdded=" << _nbAdded << "\");");
int64_t posEnd = _pos + _nbDeleted; int64_t posEnd = _pos + _nbDeleted;
// search position of the old element to reparse IT... // search position of the old element to reparse IT...
int64_t startId; int64_t startId;
@ -736,32 +736,45 @@ void appl::Buffer::regenerateHighLightAt(int64_t _pos, int64_t _nbDeleted, int64
} }
// find element previous // find element previous
findMainHighLightPosition(_pos, posEnd, startId, stopId, true); findMainHighLightPosition(_pos, posEnd, startId, stopId, true);
APPL_VERBOSE(" list old parse:");
for (auto &elem : m_HLDataPass1) {
APPL_VERBOSE(" " << elem.start << "=>" << elem.stop);
}
// Remove previous element to prevent many errors like parsing of // for example
startId--;
APPL_VERBOSE("Find startId=" << startId << " stopId=" << stopId << " list size=" << m_HLDataPass1.size());
// remove deprecated element // remove deprecated element
if ( startId == -1 if ( startId <= -1
&& stopId == -1) { && stopId <= -1) {
m_HLDataPass1.clear(); m_HLDataPass1.clear();
} else if (startId == -1) { APPL_VERBOSE("1 * clear");
} else if (startId <= -1) {
if (stopId == 0){ if (stopId == 0){
m_HLDataPass1.erase(m_HLDataPass1.begin()); m_HLDataPass1.erase(m_HLDataPass1.begin());
//APPL_DEBUG("1 * Erase 0"); APPL_VERBOSE("1 * Erase 0");
} else { } else {
m_HLDataPass1.erase(m_HLDataPass1.begin(), m_HLDataPass1.begin()+stopId); m_HLDataPass1.erase(m_HLDataPass1.begin(), m_HLDataPass1.begin()+stopId);
//APPL_DEBUG("2 * Erase 0->" << stopId); APPL_VERBOSE("2 * Erase 0->" << stopId);
} }
} else if (stopId == -1) { } else if (stopId <= -1) {
//APPL_DEBUG("3 * Erase " << startId+1 << "-> end"); APPL_VERBOSE("3 * Erase " << startId+1 << "-> end");
m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1, m_HLDataPass1.end()); m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1, m_HLDataPass1.end());
stopId = -1; stopId = -1;
} else { } else {
int32_t currentSize = m_HLDataPass1.size(); int32_t currentSize = m_HLDataPass1.size();
//APPL_DEBUG("4 * Erase " << startId+1 << "->" << stopId << " in " << currentSize << " elements" ); APPL_VERBOSE("4 * Erase " << startId+1 << "->" << stopId << " in " << currentSize << " elements" );
m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1, m_HLDataPass1.begin()+stopId); m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1, m_HLDataPass1.begin()+stopId+1);
if (stopId == currentSize-1) { if (stopId == currentSize-1) {
stopId = -1; stopId = -1;
} }
} }
//APPL_DEBUG("new size=" << (int32_t)m_HLDataPass1.size()-1); APPL_VERBOSE(" list afterRemove:");
for (auto &elem : m_HLDataPass1) {
APPL_VERBOSE(" " << elem.start << "=>" << elem.stop);
}
// update position after the range position : // update position after the range position :
int64_t elemStart; int64_t elemStart;
if (startId == -1) { if (startId == -1) {
@ -775,18 +788,18 @@ void appl::Buffer::regenerateHighLightAt(int64_t _pos, int64_t _nbDeleted, int64
it->stop += _nbAdded - _nbDeleted; it->stop += _nbAdded - _nbDeleted;
} }
//Regenerate Element inside range //Regenerate Element inside range
if ( startId == -1 if ( startId <= -1
&& stopId == -1) { && stopId <= -1) {
//APPL_DEBUG("******* Regenerate ALL"); APPL_VERBOSE("******* Regenerate ALL");
generateHighLightAt(0, m_data.size()); generateHighLightAt(0, m_data.size());
} else if(-1 == startId) { } else if(startId <= -1) {
//APPL_DEBUG("******* Regenerate START"); APPL_VERBOSE("******* Regenerate START");
generateHighLightAt(0, m_HLDataPass1[0].start, 0); generateHighLightAt(0, m_HLDataPass1[0].start, 0);
} else if(-1 == stopId) { } else if(stopId <= -1) {
//APPL_DEBUG("******* Regenerate STOP"); APPL_VERBOSE("******* Regenerate STOP");
generateHighLightAt(m_HLDataPass1[m_HLDataPass1.size() -1].stop, m_data.size(), m_HLDataPass1.size()); generateHighLightAt(m_HLDataPass1[m_HLDataPass1.size() -1].stop, m_data.size(), m_HLDataPass1.size());
} else { } else {
//APPL_DEBUG("******* Regenerate RANGE"); APPL_VERBOSE("******* Regenerate RANGE");
generateHighLightAt(m_HLDataPass1[startId].stop, m_HLDataPass1[startId+1].start, startId+1); generateHighLightAt(m_HLDataPass1[startId].stop, m_HLDataPass1[startId+1].start, startId+1);
} }
} }

View File

@ -179,73 +179,54 @@ void appl::Highlight::parse(int64_t _start,
appl::HighlightInfo resultat; appl::HighlightInfo resultat;
int64_t startTime = ewol::getTime(); int64_t startTime = ewol::getTime();
while (elementStart <= elementStop) { while (elementStart <= elementStop) {
//APPL_DEBUG("Parse element in the buffer pos=" << elementStart); //HL_DEBUG("Parse element in the buffer pos=" << elementStart);
appl::HighlightInfo resultatLast;
int64_t findAnOtherId = -1;
int64_t currentTime = ewol::getTime(); int64_t currentTime = ewol::getTime();
//try to fond the HL in ALL of we have //try to fond the HL in ALL of we have
for (int64_t jjj=0; jjj<(int64_t)m_listHighlightPass1.size(); jjj++){ for (int64_t jjj=0; jjj<(int64_t)m_listHighlightPass1.size(); jjj++){
enum resultFind ret = HLP_FIND_OK; enum resultFind ret = HLP_FIND_OK;
/* /*
if (_buffer[elementStart] == '\n') { if (_buffer[elementStart] == '\n') {
APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << elementStart << "," << _stop << ") input start='\\n' " << m_listHighlightPass1[jjj]->getPaternString()); HL_DEBUG("Parse HL id=" << jjj << " position search: (" << elementStart << "," << _stop << ") input start='\\n' " << m_listHighlightPass1[jjj]->getPaternString());
} else { } else {
APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << elementStart << "," << _stop << ") input start='" << _buffer[elementStart] << "' " << m_listHighlightPass1[jjj]->getPaternString()); HL_DEBUG("Parse HL id=" << jjj << " position search: (" << elementStart << "," << _stop << ") input start='" << _buffer[elementStart] << "' " << m_listHighlightPass1[jjj]->getPaternString());
} }
*/ */
// Stop the search to the end (to get the end of the pattern) // Stop the search to the end (to get the end of the pattern)
ret = m_listHighlightPass1[jjj]->find(elementStart, _buffer.size(), resultat, _buffer); ret = m_listHighlightPass1[jjj]->find(elementStart, _buffer.size(), resultat, _buffer);
if (HLP_FIND_ERROR != ret) { if (HLP_FIND_ERROR != ret) {
if (elementStart == resultat.start) { int64_t currentTimeEnd = ewol::getTime();
//APPL_DEBUG(" native Find"); int64_t deltaTime = currentTimeEnd - currentTime;
findAnOtherId = jjj; HL_DEBUG("Find Pattern in the Buffer : time=" << (float)deltaTime/1000.0f << " ms (" << resultat.start << "," << resultat.stop << ") startPos=" << elementStart << " for=" << m_listHighlightPass1[jjj]->getPaternString());
resultatLast = resultat; // remove element in the current List where the current Element have a end inside the next...
break; int64_t kkk=_addingPos;
} else { while(kkk < (int64_t)_metaData.size() ) {
// stack last find to prevent a unneded seach: if (_metaData[kkk].start <= resultat.stop) {
if ( findAnOtherId == -1 // remove element
|| resultat.start < resultatLast.start) { HL_DEBUG("Erase element=" << kkk);
findAnOtherId = jjj; _metaData.erase(_metaData.begin()+kkk, _metaData.begin()+kkk+1);
resultatLast = resultat; // Increase the end of search
} if (kkk < (int64_t)_metaData.size()) {
} // just before the end of the next element
} elementStop = _metaData[kkk].start-1;
} } else {
int64_t currentTimeEnd = ewol::getTime(); // end of the buffer
int64_t deltaTime = currentTimeEnd - currentTime; elementStop = _buffer.size();
if (findAnOtherId != -1) { }
//APPL_DEBUG("Find Pattern in the Buffer : time=" << (float)deltaTime/1000.0f << " ms (" << resultatLast.start << "," << resultatLast.stop << ") startPos=" << elementStart << " for=" << m_listHighlightPass1[findAnOtherId]->getPaternString());
// remove element in the current List where the current Element have a end inside the next...
int64_t kkk=_addingPos;
while(kkk < (int64_t)_metaData.size() ) {
if (_metaData[kkk].start <= resultatLast.stop) {
// remove element
APPL_DEBUG("Erase element=" << kkk);
_metaData.erase(_metaData.begin()+kkk, _metaData.begin()+kkk+1);
// Increase the end of search
if (kkk < (int64_t)_metaData.size()) {
// just befor the end of the next element
elementStop = _metaData[kkk].start-1;
} else { } else {
// end of the buffer // Not find == > exit the cycle :
elementStop = _buffer.size(); break;
} }
} else {
// Not find == > exit the cycle :
break;
} }
// add curent element in the list ...
_metaData.insert(_metaData.begin()+_addingPos, resultat);
HL_DEBUG("INSERT at "<< _addingPos << " S=" << resultat.start << " E=" << resultat.stop );
// update the current research starting element: (set position at the end of the current element
elementStart = resultat.stop-1;
// increment the position of insertion:
_addingPos++;
// We find a pattern == > Stop search for the current element
break;
} }
// add curent element in the list ...
_metaData.insert(_metaData.begin()+_addingPos, resultatLast);
HL_DEBUG("INSERT at "<< _addingPos << " S=" << resultatLast.start << " E=" << resultatLast.stop );
// update the current research starting element: (set position at the end of the current element
elementStart = resultatLast.stop-1;
// increment the position of insertion:
_addingPos++;
// We find a pattern == > Stop search for the current element
} else {
//APPL_DEBUG("loose time : time=" << deltaTime << " us");
//break;
} }
// Go to the next element (and search again ...). // Go to the next element (and search again ...).
elementStart++; elementStart++;
@ -276,42 +257,21 @@ void appl::Highlight::parse2(int64_t _start,
if (elementStart == 306) { if (elementStart == 306) {
//etk::log::setLevel(etk::log::logLevelVerbose); //etk::log::setLevel(etk::log::logLevelVerbose);
} }
appl::HighlightInfo resultatLast;
int64_t findAnOtherId = -1;
//HL2_DEBUG("Parse element in the buffer pos=" << elementStart << "," << _buffer.size() << ")" ); //HL2_DEBUG("Parse element in the buffer pos=" << elementStart << "," << _buffer.size() << ")" );
//try to fond the HL in ALL of we have //try to fond the HL in ALL of we have
for (int64_t jjj=0; jjj<(int64_t)m_listHighlightPass2.size(); jjj++){ for (int64_t jjj=0; jjj<(int64_t)m_listHighlightPass2.size(); jjj++){
enum resultFind ret; enum resultFind ret;
HL_DEBUG("Parse HL id=" << jjj << " position search: (" << HL2_DEBUG("Parse HL id=" << jjj << " position search: (" <<
elementStart << "," << elementStop << ") in='" elementStart << "," << elementStop << ") in='"
<< _buffer[elementStart] << "' " << m_listHighlightPass2[jjj]->getPaternString()); << _buffer[elementStart] << "' " << m_listHighlightPass2[jjj]->getPaternString());
// Stop the search to the end (to get the end of the pattern) // Stop the search to the end (to get the end of the pattern)
ret = m_listHighlightPass2[jjj]->find(elementStart, elementStop, resultat, _buffer); ret = m_listHighlightPass2[jjj]->find(elementStart, elementStop, resultat, _buffer);
if (ret != HLP_FIND_ERROR) { if (ret != HLP_FIND_ERROR) {
if (elementStart == resultat.start) { _metaData.push_back(resultat);
//APPL_DEBUG("Find Pattern in the Buffer : (" << resultat.start << "," << resultat.stop << ") startPos=" << elementStart ); elementStart = resultat.stop-1;
findAnOtherId = jjj; break;
resultatLast = resultat;
break;
} else {
// stack last find to prevent a unneded seach:
if ( findAnOtherId == -1
|| resultat.start < resultatLast.start) {
findAnOtherId = jjj;
resultatLast = resultat;
}
}
} }
} }
if (findAnOtherId != -1) {
//APPL_DEBUG("Find Pattern in the Buffer : (" << resultat.start << "," << resultat.stop << ") startPos=" << elementStart );
// add curent element in the list ...
_metaData.push_back(resultat);
elementStart = resultat.stop-1;
} else {
//break;
}
// Go to the next element (and search again ...). // Go to the next element (and search again ...).
elementStart++; elementStart++;
} }

View File

@ -115,19 +115,8 @@ enum resultFind appl::HighlightPattern::find(int32_t _start,
return HLP_FIND_ERROR; return HLP_FIND_ERROR;
} }
/*
// when we have only one element:
if (true == m_regExp.processOneElement(_buffer, _start, _stop)) {
_resultat.start = m_regExp->start();
_resultat.stop = m_regExp->stop();
return HLP_FIND_OK;
}
//APPL_DEBUG("NOT find hightlightpatern ...");
return HLP_FIND_ERROR;
*/
std::smatch resultMatch; std::smatch resultMatch;
std::regex_constants::match_flag_type flags = std::regex_constants::match_continuous; std::regex_constants::match_flag_type flags = std::regex_constants::match_continuous; // check only the match at the first character.
//APPL_DEBUG("find data at : start=" << _start << " stop=" << _stop << " regex='" << m_regexValue << "'"); //APPL_DEBUG("find data at : start=" << _start << " stop=" << _stop << " regex='" << m_regexValue << "'");
if ((int64_t)_stop <= (int64_t)_buffer.size()) { if ((int64_t)_stop <= (int64_t)_buffer.size()) {
@ -147,9 +136,9 @@ enum resultFind appl::HighlightPattern::find(int32_t _start,
if (_start>0) { if (_start>0) {
flags |= std::regex_constants::match_prev_avail; flags |= std::regex_constants::match_prev_avail;
} }
std::regex_search(_buffer.begin() + _start, _buffer.begin() + _stop, resultMatch, m_regExp, flags); std::regex_search(_buffer.begin() + _start, _buffer.end(), resultMatch, m_regExp, flags);
if (resultMatch.size() > 0) { if (resultMatch.size() > 0) {
_resultat.start = std::distance(_buffer.begin(), resultMatch[0].first);; _resultat.start = std::distance(_buffer.begin(), resultMatch[0].first);
_resultat.stop = std::distance(_buffer.begin(), resultMatch[0].second); _resultat.stop = std::distance(_buffer.begin(), resultMatch[0].second);
//APPL_DEBUG("find data at : start=" << _resultat.start << " stop=" << _resultat.stop << " data='" <<std::string(_buffer, _resultat.start, _resultat.stop-_resultat.start) << "'" ); //APPL_DEBUG("find data at : start=" << _resultat.start << " stop=" << _resultat.stop << " data='" <<std::string(_buffer, _resultat.start, _resultat.stop-_resultat.start) << "'" );
/* /*
@ -163,19 +152,6 @@ enum resultFind appl::HighlightPattern::find(int32_t _start,
} }
} }
*/ */
/*
if (false){
TK_DEBUG("in line : '" << etk::to_string(_buffer) << "'");
TK_DEBUG(" Find " << resultMatch.size() << " elements");
for (size_t iii=0; iii<resultMatch.size(); ++iii) {
int32_t posStart = std::distance(_buffer.begin(), resultMatch[iii].first);
int32_t posStop = std::distance(_buffer.begin(), resultMatch[iii].second);
TK_DEBUG(" [" << iii << "] " << *resultMatch[iii].first);
TK_DEBUG(" [" << iii << "] " << *resultMatch[iii].second);
TK_DEBUG(" [" << iii << "] " << std::string(_buffer, posStart, posStop-posStart));
}
}
*/
return HLP_FIND_OK; return HLP_FIND_OK;
} }
return HLP_FIND_ERROR; return HLP_FIND_ERROR;