[DEBUG] correct C regExp

This commit is contained in:
Edouard DUPIN 2014-07-30 23:24:26 +02:00
parent 86d54590c0
commit 1d60917575
4 changed files with 15 additions and 9 deletions

View File

@ -25,7 +25,7 @@
</rule> </rule>
<rule name="my preprocesseur"> <rule name="my preprocesseur">
<color>preprocesseur</color> <color>preprocesseur</color>
<regex>#(\\|\\n|.)*$</regex> <regex>#(\\[\\\n]|.)*$</regex>
</rule> </rule>
<rule name="my comment doxygen"> <rule name="my comment doxygen">
<color>commentDoxygen</color> <color>commentDoxygen</color>
@ -37,19 +37,18 @@
</rule> </rule>
<rule name="my comment"> <rule name="my comment">
<color>comment</color> <color>comment</color>
<regex>//(\\|\\n|.)*$</regex> <regex>//.*$</regex>
</rule> </rule>
<rule name="doubleQuteText"> <rule name="doubleQuteText">
<color>doubleQuoteText</color> <color>doubleQuoteText</color>
<regex>"(\\|"|.)*"</regex> <regex>"(\\[\\"]|.)*"</regex>
</rule> </rule>
<rule name="simpleQuteText"> <rule name="simpleQuteText">
<color>doubleQuoteText</color> <color>doubleQuoteText</color>
<regex>'(\\|'|.)*'</regex> <regex>'(\\[\\'])|.)*'</regex>
</rule> </rule>
</pass1> </pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear --> <pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<!--
<rule name="my keyword"> <rule name="my keyword">
<color>keyword</color> <color>keyword</color>
<regex>\@return|goto|if|else|case|default|switch|break|continue|while|do|for|sizeof\@</regex> <regex>\@return|goto|if|else|case|default|switch|break|continue|while|do|for|sizeof\@</regex>
@ -102,7 +101,6 @@
<color>boolean</color> <color>boolean</color>
<regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex> <regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex>
</rule> </rule>
-->
<!-- With all elementes : <!-- With all elementes :
<rule name="BIG LETTER"> <rule name="BIG LETTER">
<color>macro</color> <color>macro</color>

View File

@ -177,7 +177,7 @@ void appl::Highlight::parse(int64_t _start,
//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;
HL_DEBUG("Parse HL id=" << jjj << " position search: (" << elementStart << "," << _stop << ")" ); 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) {
@ -234,15 +234,19 @@ void appl::Highlight::parse2(int64_t _start,
appl::HighlightInfo resultat; appl::HighlightInfo resultat;
while (elementStart < elementStop) { while (elementStart < elementStop) {
if (elementStart == 306) {
//etk::log::setLevel(etk::log::logLevelVerbose);
}
//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 = HLP_FIND_OK; enum resultFind ret = HLP_FIND_OK;
HL2_DEBUG("Parse HL id=" << jjj << " position search: (" << HL2_DEBUG("Parse HL id=" << jjj << " position search: (" <<
_start << "," << _buffer.size() << ")" ); elementStart << "," << elementStop << ") in='"
<< _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 (HLP_FIND_ERROR != ret) { if (ret != HLP_FIND_ERROR) {
HL2_DEBUG("Find Pattern in the Buffer : (" << resultat.start << "," << resultat.stop << ")" ); HL2_DEBUG("Find Pattern in the Buffer : (" << resultat.start << "," << resultat.stop << ")" );
// add curent element in the list ... // add curent element in the list ...
_metaData.push_back(resultat); _metaData.push_back(resultat);

View File

@ -32,6 +32,9 @@ void appl::HighlightPattern::setPatern(std::string& _regExp) {
} }
m_regExp->compile(_regExp); m_regExp->compile(_regExp);
} }
std::string appl::HighlightPattern::getPaternString() {
return m_regExp->getRegExDecorated();
}
void appl::HighlightPattern::setColorGlyph(std::string& _colorName) { void appl::HighlightPattern::setColorGlyph(std::string& _colorName) {
m_colorName = _colorName; m_colorName = _colorName;

View File

@ -47,6 +47,7 @@ namespace appl {
std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExp; //!< Start of Regular expression std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExp; //!< Start of Regular expression
public: public:
void setPatern(std::string& _regExp); void setPatern(std::string& _regExp);
std::string getPaternString();
private: private:
std::string m_colorName; //!< Current color name std::string m_colorName; //!< Current color name
int32_t m_colorId; //!< Id of the the glyph painting int32_t m_colorId; //!< Id of the the glyph painting