[DEV] remove problematic function parsing

This commit is contained in:
Edouard DUPIN 2014-10-02 22:40:40 +02:00
parent 2c3a64933d
commit b890f931ca
12 changed files with 36 additions and 12 deletions

View File

@ -28,10 +28,12 @@
<color>keyword</color> <color>keyword</color>
<regex>[\$]+[a-zA-Z_][a-zA-Z0-9_]*</regex> <regex>[\$]+[a-zA-Z_][a-zA-Z0-9_]*</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>function (\w|_)+[ \t]*\(</regex> <regex>function (\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<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>

View File

@ -44,7 +44,7 @@
</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>
@ -99,11 +99,14 @@
<rule name="function input"> <rule name="function input">
<color>inputFunction</color> <color>inputFunction</color>
<regex>\@_[A-Za-z_0-9]*\@</regex> <regex>\@_[A-Za-z_0-9]*\@</regex>
<max>false</max>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<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>

View File

@ -41,10 +41,11 @@
<color>macro</color> <color>macro</color>
<regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex> <regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
</pass2> </pass2>
</EdnLang> </EdnLang>

View File

@ -64,10 +64,12 @@
<color>macro</color> <color>macro</color>
<regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex> <regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<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>

View File

@ -40,10 +40,12 @@
<color>macro</color> <color>macro</color>
<regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex> <regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<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>

View File

@ -33,10 +33,12 @@
<color>boolean</color> <color>boolean</color>
<regex>\@true|false\@</regex> <regex>\@true|false\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<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>

View File

@ -55,10 +55,12 @@
<color>boolean</color> <color>boolean</color>
<regex>\@true|TRUE|false|FALSE\@</regex> <regex>\@true|TRUE|false|FALSE\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<color>boolean</color> <color>boolean</color>
<regex>==|&lt;=|&gt;=|!=|&lt;|&gt;|&amp;&amp;|\{|\}|</regex> <regex>==|&lt;=|&gt;=|!=|&lt;|&gt;|&amp;&amp;|\{|\}|</regex>

View File

@ -56,10 +56,12 @@
<color>macro</color> <color>macro</color>
<regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex> <regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<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>

View File

@ -25,12 +25,13 @@
#define HL2_DEBUG APPL_VERBOSE #define HL2_DEBUG APPL_VERBOSE
void appl::Highlight::parseRules(exml::Element* _child, void appl::Highlight::parseRules(exml::Element* _child,
std::vector<std::unique_ptr<HighlightPattern>>& _mListPatern, std::vector<std::unique_ptr<HighlightPattern>>& _mListPatern,
int32_t _level) { int32_t _level,
bool forceMaximize) {
// Create the patern ... // Create the patern ...
HighlightPattern *myPattern = new HighlightPattern(m_paintingProperties); HighlightPattern *myPattern = new HighlightPattern(m_paintingProperties);
// parse under Element // parse under Element
myPattern->parseRules(_child, _level); myPattern->parseRules(_child, _level, forceMaximize);
// add element in the list // add element in the list
_mListPatern.push_back(std::unique_ptr<HighlightPattern>(myPattern)); _mListPatern.push_back(std::unique_ptr<HighlightPattern>(myPattern));
} }
@ -95,7 +96,7 @@ void appl::Highlight::init(const std::string& _xmlFilename, const std::string& _
APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" ); APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" );
continue; continue;
} }
parseRules(passChild, m_listHighlightPass2, level2++); parseRules(passChild, m_listHighlightPass2, level2++, true);
} }
} else { } else {
APPL_ERROR("(l "<< child->getPos() << ") node not suported : \""<< child->getValue() << "\" must be [ext,pass1,pass2]" ); APPL_ERROR("(l "<< child->getPos() << ") node not suported : \""<< child->getValue() << "\" must be [ext,pass1,pass2]" );

View File

@ -63,7 +63,8 @@ namespace appl {
private: private:
void parseRules(exml::Element* _child, void parseRules(exml::Element* _child,
std::vector<std::unique_ptr<HighlightPattern>> &_mListPatern, std::vector<std::unique_ptr<HighlightPattern>> &_mListPatern,
int32_t _level); int32_t _level,
bool forceMaximize=false);
std::string m_styleName; //!< curent style name (like "c++" or "c" or "script Bash") std::string m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
std::vector<std::string> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" std::vector<std::string> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
std::vector<std::unique_ptr<HighlightPattern>> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer) std::vector<std::unique_ptr<HighlightPattern>> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer)

View File

@ -26,11 +26,12 @@ appl::HighlightPattern::~HighlightPattern() {
} }
void appl::HighlightPattern::setPatern(std::string& _regExp) { void appl::HighlightPattern::setPatern(std::string& _regExp, bool forceMaximize) {
if (m_regExp == nullptr) { if (m_regExp == nullptr) {
return; return;
} }
m_regExp->compile(_regExp); m_regExp->compile(_regExp);
m_regExp->setMaximize(forceMaximize);
} }
std::string appl::HighlightPattern::getPaternString() { std::string appl::HighlightPattern::getPaternString() {
return m_regExp->getRegExDecorated(); return m_regExp->getRegExDecorated();
@ -48,12 +49,13 @@ void appl::HighlightPattern::display() {
APPL_INFO(" == > regExp '" << m_regExp->getRegExp() << "'"); APPL_INFO(" == > regExp '" << m_regExp->getRegExp() << "'");
} }
void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) { void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level, bool forceMaximize) {
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
/* /*
<rule name="my preprocesseur"> <rule name="my preprocesseur">
<color>preprocesseur</color> <color>preprocesseur</color>
<regex>#</regex> <regex>#</regex>
<max>false</max>
</rule> </rule>
*/ */
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
@ -75,13 +77,17 @@ void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) {
setColorGlyph(myEdnData); setColorGlyph(myEdnData);
} }
} }
xChild = _child->getNamed("max");
if (nullptr != xChild) {
forceMaximize = etk::string_to_bool(xChild->getText());
}
xChild = _child->getNamed("regex"); xChild = _child->getNamed("regex");
if (nullptr != xChild) { if (nullptr != xChild) {
std::string myData = xChild->getText(); std::string myData = xChild->getText();
if (myData.size() != 0) { if (myData.size() != 0) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); //APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
std::string myEdnData = myData; std::string myEdnData = myData;
setPatern(myEdnData); setPatern(myEdnData, forceMaximize);
} }
} }
} }

View File

@ -46,7 +46,7 @@ namespace appl {
private: private:
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, bool forceMaximize=false);
std::string getPaternString(); std::string getPaternString();
private: private:
std::string m_colorName; //!< Current color name std::string m_colorName; //!< Current color name
@ -84,7 +84,7 @@ namespace appl {
appl::HighlightInfo& _resultat, appl::HighlightInfo& _resultat,
etk::Buffer& _buffer); etk::Buffer& _buffer);
void parseRules(exml::Element* _child, int32_t _level); void parseRules(exml::Element* _child, int32_t _level, bool forceMaximize=false);
}; };
}; };