diff --git a/data/languages/c/highlight.xml b/data/languages/c/highlight.xml index 48b8370..9740fbc 100644 --- a/data/languages/c/highlight.xml +++ b/data/languages/c/highlight.xml @@ -10,43 +10,51 @@ *.m *.mm - + commentDoxygen - /\*\*(.|\r|\n)*?\*/ + /\*(\*|!)(.|\r|\n)*?\*/ - + SYNTAX_ERROR - /\*[ \t]*TODO :(.|\r|\n)*?\*/ + /\*[ \t]*TODO :(.|\r|\n)*?(\*/|\0) - + comment - /\*(.|\r|\n)*?\*/ + /\*(.|\r|\n)*?(\*/|\0) - + + SYNTAX_ERROR + /\*(.|\r|\n)* + + preprocesseur - #[ \t]*if 0(.|\r|\n)*?#(endif|else) + #[ \t]*if 0(.|\r|\n)*?(#endif|else) - + + SYNTAX_ERROR + #[ \t]*if 0(.|\r|\n)* + + preprocesseur #(.|\\[\\\n])* - + commentDoxygen //!.* - + SYNTAX_ERROR //[ \t]*TODO[ \t]*:.* - + comment //.* - + doubleQuoteText - "(.|\\[\\"])*" + "(.|\\[\\"])*?" - + doubleQuoteText '\\?.' diff --git a/sources/appl/Buffer.cpp b/sources/appl/Buffer.cpp index 63ef63d..6d56e1e 100644 --- a/sources/appl/Buffer.cpp +++ b/sources/appl/Buffer.cpp @@ -723,7 +723,7 @@ void appl::Buffer::regenerateHighLightAt(int64_t _pos, int64_t _nbDeleted, int64 return; } // normal case - //APPL_INFO("(pos="<" << 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 - if ( startId == -1 - && stopId == -1) { + if ( startId <= -1 + && stopId <= -1) { m_HLDataPass1.clear(); - } else if (startId == -1) { + APPL_VERBOSE("1 * clear"); + } else if (startId <= -1) { if (stopId == 0){ m_HLDataPass1.erase(m_HLDataPass1.begin()); - //APPL_DEBUG("1 * Erase 0"); + APPL_VERBOSE("1 * Erase 0"); } else { 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) { - //APPL_DEBUG("3 * Erase " << startId+1 << "-> end"); + } else if (stopId <= -1) { + APPL_VERBOSE("3 * Erase " << startId+1 << "-> end"); m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1, m_HLDataPass1.end()); stopId = -1; } else { int32_t currentSize = m_HLDataPass1.size(); - //APPL_DEBUG("4 * Erase " << startId+1 << "->" << stopId << " in " << currentSize << " elements" ); - m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1, m_HLDataPass1.begin()+stopId); + APPL_VERBOSE("4 * Erase " << startId+1 << "->" << stopId << " in " << currentSize << " elements" ); + m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1, m_HLDataPass1.begin()+stopId+1); if (stopId == currentSize-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 : int64_t elemStart; if (startId == -1) { @@ -775,18 +788,18 @@ void appl::Buffer::regenerateHighLightAt(int64_t _pos, int64_t _nbDeleted, int64 it->stop += _nbAdded - _nbDeleted; } //Regenerate Element inside range - if ( startId == -1 - && stopId == -1) { - //APPL_DEBUG("******* Regenerate ALL"); + if ( startId <= -1 + && stopId <= -1) { + APPL_VERBOSE("******* Regenerate ALL"); generateHighLightAt(0, m_data.size()); - } else if(-1 == startId) { - //APPL_DEBUG("******* Regenerate START"); + } else if(startId <= -1) { + APPL_VERBOSE("******* Regenerate START"); generateHighLightAt(0, m_HLDataPass1[0].start, 0); - } else if(-1 == stopId) { - //APPL_DEBUG("******* Regenerate STOP"); + } else if(stopId <= -1) { + APPL_VERBOSE("******* Regenerate STOP"); generateHighLightAt(m_HLDataPass1[m_HLDataPass1.size() -1].stop, m_data.size(), m_HLDataPass1.size()); } else { - //APPL_DEBUG("******* Regenerate RANGE"); + APPL_VERBOSE("******* Regenerate RANGE"); generateHighLightAt(m_HLDataPass1[startId].stop, m_HLDataPass1[startId+1].start, startId+1); } } diff --git a/sources/appl/Highlight.cpp b/sources/appl/Highlight.cpp index 893caa9..ae6cada 100644 --- a/sources/appl/Highlight.cpp +++ b/sources/appl/Highlight.cpp @@ -179,73 +179,54 @@ void appl::Highlight::parse(int64_t _start, appl::HighlightInfo resultat; int64_t startTime = ewol::getTime(); while (elementStart <= elementStop) { - //APPL_DEBUG("Parse element in the buffer pos=" << elementStart); - appl::HighlightInfo resultatLast; - int64_t findAnOtherId = -1; + //HL_DEBUG("Parse element in the buffer pos=" << elementStart); int64_t currentTime = ewol::getTime(); //try to fond the HL in ALL of we have for (int64_t jjj=0; jjj<(int64_t)m_listHighlightPass1.size(); jjj++){ enum resultFind ret = HLP_FIND_OK; /* 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 { - 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) ret = m_listHighlightPass1[jjj]->find(elementStart, _buffer.size(), resultat, _buffer); if (HLP_FIND_ERROR != ret) { - if (elementStart == resultat.start) { - //APPL_DEBUG(" native Find"); - findAnOtherId = jjj; - resultatLast = resultat; - break; - } else { - // stack last find to prevent a unneded seach: - if ( findAnOtherId == -1 - || resultat.start < resultatLast.start) { - findAnOtherId = jjj; - resultatLast = resultat; - } - } - } - } - int64_t currentTimeEnd = ewol::getTime(); - int64_t deltaTime = currentTimeEnd - currentTime; - 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; + int64_t currentTimeEnd = ewol::getTime(); + int64_t deltaTime = currentTimeEnd - currentTime; + HL_DEBUG("Find Pattern in the Buffer : time=" << (float)deltaTime/1000.0f << " ms (" << resultat.start << "," << resultat.stop << ") startPos=" << elementStart << " for=" << m_listHighlightPass1[jjj]->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 <= resultat.stop) { + // remove element + HL_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 before the end of the next element + elementStop = _metaData[kkk].start-1; + } else { + // end of the buffer + elementStop = _buffer.size(); + } } else { - // end of the buffer - elementStop = _buffer.size(); + // Not find == > exit the cycle : + 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 ...). elementStart++; @@ -276,42 +257,21 @@ void appl::Highlight::parse2(int64_t _start, if (elementStart == 306) { //etk::log::setLevel(etk::log::logLevelVerbose); } - appl::HighlightInfo resultatLast; - int64_t findAnOtherId = -1; //HL2_DEBUG("Parse element in the buffer pos=" << elementStart << "," << _buffer.size() << ")" ); //try to fond the HL in ALL of we have for (int64_t jjj=0; jjj<(int64_t)m_listHighlightPass2.size(); jjj++){ enum resultFind ret; - HL_DEBUG("Parse HL id=" << jjj << " position search: (" << + HL2_DEBUG("Parse HL id=" << jjj << " position search: (" << elementStart << "," << elementStop << ") in='" << _buffer[elementStart] << "' " << m_listHighlightPass2[jjj]->getPaternString()); // Stop the search to the end (to get the end of the pattern) ret = m_listHighlightPass2[jjj]->find(elementStart, elementStop, resultat, _buffer); if (ret != HLP_FIND_ERROR) { - if (elementStart == resultat.start) { - //APPL_DEBUG("Find Pattern in the Buffer : (" << resultat.start << "," << resultat.stop << ") startPos=" << elementStart ); - findAnOtherId = jjj; - resultatLast = resultat; - break; - } else { - // stack last find to prevent a unneded seach: - if ( findAnOtherId == -1 - || resultat.start < resultatLast.start) { - findAnOtherId = jjj; - resultatLast = resultat; - } - } + _metaData.push_back(resultat); + elementStart = resultat.stop-1; + break; } } - - 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 ...). elementStart++; } diff --git a/sources/appl/HighlightPattern.cpp b/sources/appl/HighlightPattern.cpp index f40dc47..679b231 100644 --- a/sources/appl/HighlightPattern.cpp +++ b/sources/appl/HighlightPattern.cpp @@ -115,19 +115,8 @@ enum resultFind appl::HighlightPattern::find(int32_t _start, 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::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 << "'"); if ((int64_t)_stop <= (int64_t)_buffer.size()) { @@ -147,9 +136,9 @@ enum resultFind appl::HighlightPattern::find(int32_t _start, if (_start>0) { 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) { - _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); //APPL_DEBUG("find data at : start=" << _resultat.start << " stop=" << _resultat.stop << " data='" <