[DEV] better regex ==> need to update alge to recognise data

This commit is contained in:
Edouard DUPIN 2014-10-07 21:42:07 +02:00
parent 78887e64ed
commit 7952872980
17 changed files with 246 additions and 64 deletions

View File

@ -4,19 +4,19 @@
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="first line">
<color>commentDoxygen</color>
<regex>#!(\\[\\\n]|.)*?$</regex>
<regex>#!(.|\\[\\\n])*?$</regex>
</rule>
<rule name="comment line">
<color>comment</color>
<regex>#(\\[\\\n]|.)*?$</regex>
<regex>#(.|\\[\\\n])*?$</regex>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*?"</regex>
<regex>"(.|\\[\\"])*?"</regex>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<regex>'(\\[\\']|.)*?'</regex>
<regex>'(.|\\[\\'])*?'</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -16,11 +16,11 @@
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*?$</regex>
<regex>"(.|\\[\\"])*?$</regex>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<regex>\b'(\\[\\']|.)*?$</regex>
<regex>\b'(.|\\[\\'])*?$</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -28,7 +28,7 @@
</rule>
<rule name="my preprocesseur">
<color>preprocesseur</color>
<regex>#(\\[\\\n]|.)*</regex>
<regex>#(.|\\[\\\n])*</regex>
</rule>
<rule name="my comment doxygen">
<color>commentDoxygen</color>
@ -44,11 +44,11 @@
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*"</regex>
<regex>"(.|\\[\\"])*"</regex>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<regex>'((\\[\\'])|.){1,2}'</regex>
<regex>'\\?.'</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
@ -70,7 +70,7 @@
</rule>
<rule name="my storage keyword">
<color>storageKeyword</color>
<regex>\b(inline|const|class|virtual|private|public|protected|friend|const|extern|auto|register|static|unsigned|signed|volatile|char|double|float|int|long|short|void|typedef|struct|union|enum)\b</regex>
<regex>\b(inline|const|class|namespace|virtual|private|public|protected|friend|const|extern|auto|register|static|unsigned|signed|volatile|char|double|float|int|long|short|void|typedef|struct|union|enum)\b</regex>
</rule>
<rule name="my common Define">
<color>commonDefine</color>
@ -90,11 +90,11 @@
</rule>
<rule name="CPP member">
<color>memberClass</color>
<regex>\b(m_[A-Za-z_0-9]*)\b</regex>
<regex>\bm_\w+\b</regex>
</rule>
<rule name="function input">
<color>inputFunction</color>
<regex>\b(_[A-Za-z_0-9]*)\b</regex>
<regex>\b_\w+\b</regex>
<max>false</max>
</rule>
<rule name="Function name">

View File

@ -9,15 +9,15 @@
</rule>
<rule name="my todo comment">
<color>SYNTAX_ERROR</color>
<regex>#[ \t]TODO[ \t]*:(\\[\\\n]|.)*?$</regex>
<regex>#[ \t]TODO[ \t]*:(.|\\[\\\n])*?$</regex>
</rule>
<rule name="my comment">
<color>comment</color>
<regex>#(\\[\\\n]|.)*?$</regex>
<regex>#(.|\\[\\\n])*?$</regex>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*?$</regex>
<regex>"(.|\\[\\"])*?$</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -15,23 +15,23 @@
</rule>
<rule name="my if 0">
<color>preprocesseur</color>
<regex>#[ \t]*if 0(\\[\\\n]|.)*#(endif|else)</regex>
<regex>#[ \t]*if 0(.|\\[\\\n])*#(endif|else)</regex>
</rule>
<rule name="my preprocesseur">
<color>preprocesseur</color>
<regex>#(\\[\\\n]|.)*$</regex>
<regex>#(.|\\[\\\n])*$</regex>
</rule>
<rule name="my comment doxygen">
<color>commentDoxygen</color>
<regex>//!(\\[\\\n]|.)*$</regex>
<regex>//!(.|\\[\\\n])*$</regex>
</rule>
<rule name="my todo comment">
<color>SYNTAX_ERROR</color>
<regex>//[ \t]*TODO[ \t]*:(\\[\\\n]|.)*$</regex>
<regex>//[ \t]*TODO[ \t]*:(.|\\[\\\n])*$</regex>
</rule>
<rule name="my comment">
<color>comment</color>
<regex>//(\\[\\\n]|.)*$</regex>
<regex>//(.|\\[\\\n])*$</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -4,15 +4,15 @@
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my preprocesseur">
<color>preprocesseur</color>
<regex>#(\\[\\\n]|.)*?$</regex>
<regex>#(.|\\[\\\n])*?$</regex>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*?$</regex>
<regex>"(.|\\[\\"])*?$</regex>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<regex>'(\\[\\']|.)*?$</regex>
<regex>'(.|\\[\\'])*?$</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -12,23 +12,23 @@
</rule>
<rule name="my comment doxygen">
<color>commentDoxygen</color>
<regex>//!(\\[\\\n]|.)*?$</regex>
<regex>//!(.|\\[\\\n])*?$</regex>
</rule>
<rule name="my todo comment">
<color>SYNTAX_ERROR</color>
<regex>//[ \t]*TODO[ \t]*:(\\[\\\n]|.)*?$</regex>
<regex>//[ \t]*TODO[ \t]*:(.|\\[\\\n])*?$</regex>
</rule>
<rule name="my comment">
<color>comment</color>
<regex>//(\\[\\\n]|.)*?$</regex>
<regex>//(.|\\[\\\n])*?$</regex>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*?"</regex>
<regex>"(.|\\[\\"])*?"</regex>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<regex>'(\\[\\']|.)*?'</regex>
<regex>'(.|\\[\\'])*?'</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -4,7 +4,7 @@
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*?"</regex>
<regex>"(.|\\[\\"])*?"</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -8,19 +8,19 @@
</rule>
<rule name="my todo comment">
<color>SYNTAX_ERROR</color>
<regex>\-\-[ \t]*TODO[ \t]*:(\\[\\\n]|.)*?$</regex>
<regex>\-\-[ \t]*TODO[ \t]*:(.|\\[\\\n])*?$</regex>
</rule>
<rule name="my comment">
<color>comment</color>
<regex>\-\-(\\[\\\n]|.)*?$</regex>
<regex>\-\-(.|\\[\\\n])*?$</regex>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*?"</regex>
<regex>"(.|\\[\\"])*?"</regex>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<regex>'(\\[\\']|.)*?'</regex>
<regex>'(.|\\[\\'])*?'</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -6,15 +6,15 @@
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my preprocesseur">
<color>preprocesseur</color>
<regex>#(\\[\\\n]|.)*?$</regex>
<regex>#(.|\\[\\\n])*?$</regex>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*?"</regex>
<regex>"(.|\\[\\"])*?"</regex>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<regex>'(\\[\\']|.)*?'</regex>
<regex>'(.|\\[\\'])*?'</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -5,11 +5,11 @@
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment doxygen">
<color>commentDoxygen</color>
<regex>%%(\\[\\\n]|.)*?$</regex>
<regex>%%(.|\\[\\\n])*?$</regex>
</rule>
<rule name="my comment">
<color>comment</color>
<regex>%(\\[\\\n]|.)*?$</regex>
<regex>%(.|\\[\\\n])*?$</regex>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
@ -21,7 +21,7 @@
</rule>
<rule name="global inclusion">
<color>preprocesseur</color>
<regex>global( |\t)+(\\[\\\n]|.)*?$</regex>
<regex>global( |\t)+(.|\\[\\\n])*?$</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -11,23 +11,23 @@
</rule>
<rule name="my todo comment">
<color>SYNTAX_ERROR</color>
<regex>//[ \t]*TODO[ \t]*:(\\[\\\n]|.)*?$</regex>
<regex>//[ \t]*TODO[ \t]*:(.|\\[\\\n])*?$</regex>
</rule>
<rule name="my comment inline">
<color>comment</color>
<regex>#(\\[\\\n]|.)*?$</regex>
<regex>#(.|\\[\\\n])*?$</regex>
</rule>
<rule name="my comment">
<color>comment</color>
<regex>//(\\[\\\n]|.)*?$</regex>
<regex>//(.|\\[\\\n])*?$</regex>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*?"</regex>
<regex>"(.|\\[\\"])*?"</regex>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<regex>'(\\[\\']|.)*?'</regex>
<regex>'(.|\\[\\'])*?'</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -12,15 +12,15 @@
</rule>
<rule name="my comment doxygen">
<color>commentDoxygen</color>
<regex>##(\\[\\\n]|.)*?$</regex>
<regex>##(.|\\[\\\n])*?$</regex>
</rule>
<rule name="my comment">
<color>comment</color>
<regex>#(\\[\\\n]|.)*?$</regex>
<regex>#(.|\\[\\\n])*?$</regex>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*?"</regex>
<regex>"(.|\\[\\"])*?"</regex>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>

View File

@ -5,33 +5,31 @@
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="Comment">
<color>comment</color>
<regex><![CDATA[<!\-\-.*?\-\->]]></regex>
<regex><![CDATA[<!\-\-(.|\r|\n)*?\-\->]]></regex>
<!--<regex>&lt;!\-\-.*\-\-&gt;</regex>-->
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*?"</regex>
<regex>"(.|\r|\n|\\\\|\\")*?"</regex>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<regex>\b'.*?('|\n)</regex>
<regex>\b'(.|\r|\n)*?('|\n)</regex>
</rule>
<rule name="NormalData">
<color>macro</color>
<regex><![CDATA[<!\[CDATA\[(.|\r|\n)*?\]\]>]]></regex>
</rule>
</pass1>
<pass2>
<rule name="special Balise">
<color>error</color>
<regex>&lt;\?\w*|\?&gt;</regex>
<regex><![CDATA[<\?\w*|\?>]]></regex>
<!--<regex>&lt;\?\w*|\?&gt;</regex>-->
</rule>
<!--
<rule name="normale Balise2">
<color>functionName</color>
<regex><![CDATA[(</[0-9a-zA-Z_]+|<[0-9a-zA-Z_]+)(/>|>)]]></regex>
</rule>
-->
<rule name="normale Balise">
<color>functionName</color>
<!--<regex>&lt;/[0-9a-zA-Z_]+|&lt;[0-9a-zA-Z_]+|/&gt;|&gt;</regex>-->
<regex><![CDATA[(</[0-9a-zA-Z_]+|<[0-9a-zA-Z_]+)\b]]></regex>
<regex><![CDATA[(</[0-9a-zA-Z_]+|<[0-9a-zA-Z_]+)(/>|>)?]]></regex>
</rule>
</pass2>
</EdnLang>

View File

@ -30,13 +30,14 @@ appl::HighlightPattern::~HighlightPattern() {
void appl::HighlightPattern::setPatern(const std::string& _regExp, bool forceMaximize) {
m_regexValue = _regExp;
APPL_DEBUG("parse regex='" << _regExp << "'");
try {
m_regExp.assign(_regExp, std::regex_constants::optimize | std::regex_constants::ECMAScript);
//m_regExp.assign(_regExp, std::regex_constants::optimize | std::regex_constants::extended);
m_hasParsingError = false;
} catch (std::regex_error e) {
m_hasParsingError = true;
APPL_ERROR("can not parse regExp : '" << e.what() << "' for : " << _regExp);
APPL_ERROR("can not parse regex : '" << e.what() << "' for : " << _regExp);
}
//m_regExp.setMaximize(forceMaximize);
}
@ -54,7 +55,7 @@ void appl::HighlightPattern::display() {
APPL_INFO("patern : '" << m_paternName << "' level=" << m_level );
APPL_INFO(" == > colorName '" << m_colorName << "'");
//APPL_INFO(" == > regExp '" << m_regExp.getRegExp() << "'");
APPL_INFO(" == > regExp '" << m_regexValue << "'");
APPL_INFO(" == > regex '" << m_regexValue << "'");
}
void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level, bool forceMaximize) {
@ -126,8 +127,27 @@ enum resultFind appl::HighlightPattern::find(int32_t _start,
*/
std::smatch resultMatch;
std::regex_constants::match_flag_type flags = std::regex_constants::match_continuous;
//APPL_DEBUG("find data at : start=" << _start << " stop=" << _stop << " regex='" << m_regexValue << "'");
std::regex_search(_buffer.begin() + _start, _buffer.begin() + _stop, resultMatch, m_regExp, std::regex_constants::match_continuous);
if ((int64_t)_stop <= (int64_t)_buffer.size()) {
char val = _buffer[_stop];
if ( val != '\n'
&& val != '\r') {
//after last char ==> not end of line ($ would not work))
flags |= std::regex_constants::match_not_eol;
}
if (!( ('a' <= val && val <= 'z')
|| ('A' <= val && val <= 'Z')
|| ('0' <= val && val <= '9')
|| val == '_')) {
flags |= std::regex_constants::match_not_eow;
}
}
if (_start>0) {
flags |= std::regex_constants::match_prev_avail;
}
std::regex_search(_buffer.begin() + _start, _buffer.begin() + _stop, resultMatch, m_regExp, flags);
if (resultMatch.size() > 0) {
_resultat.start = std::distance(_buffer.begin(), resultMatch[0].first);;
_resultat.stop = std::distance(_buffer.begin(), resultMatch[0].second);

View File

@ -0,0 +1,164 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_WIDGET_H__
#define __EWOL_WIDGET_H__
#include <ewol/object/Object.h>
#include <ewol/Dimension.h>
'dfgd\'fg'
'e' sdfsdf '\e'
"dqf\"gsdfg" // \\ \n "
// TODO : sqdkfjsdldkqfj
example_param
=_param
_
_s
_3RTDRsdfqsd
m_
m_d6
namespace ewol {
class Widget;
namespace widget {
class Manager;
class Windows;
};
};
#include <etk/types.h>
#include <vector>
#include <etk/math/Vector2D.h>
#include <ewol/debug.h>
#include <ewol/context/clipBoard.h>
#include <ewol/key/key.h>
#include <ewol/context/cursor.h>
#include <ewol/event/Input.h>
#include <ewol/event/Entry.h>
#include <ewol/event/Time.h>
#define ULTIMATE_MAX_SIZE (99999999)
namespace ewol {
#if 0
/**
* @not-in-doc
*/
#endif
class DrawProperty{
/*
/--> m_windowsSize
*--------------------------------------------------*
| g |
| |
| m_size |
| / |
| o-------------------o |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| o-------------------o |
| / |
| m_origin |
| |
*--------------------------------------------------*
/
(0,0)
*/
public :
ivec2 m_windowsSize; //!< Windows compleate size
ivec2 m_origin; //!< Windows clipping upper widget (can not be <0)
ivec2 m_size; //!< Windows clipping upper widget (can not be <0 and >m_windowsSize)
void limit(const vec2& _origin, const vec2& _size);
};
std::ostream& operator <<(std::ostream& _os, const ewol::DrawProperty& _obj);
/**
* @brief Gravity of the widget property
* @not-in-doc
*/
enum gravity {
gravityCenter=0x00, //!< gravity is in certer
gravityTopLeft=0x05,
gravityTop=0x01,
gravityTopRight=0x03,
gravityRight=0x02,
gravityButtomRight=0x06,
gravityButtom=0x04,
gravityButtomLeft=0x0C,
gravityLeft=0x08,
};
std::ostream& operator <<(std::ostream& _os, const enum ewol::gravity _obj);
std::string gravityToString(const enum ewol::gravity _obj);
enum ewol::gravity stringToGravity(const std::string& _obj);
/**
* @not-in-doc
*/
class EventShortCut {
public:
bool broadcastEvent; //!< if it is true, then the message is sent to all the system
const char* generateEventId; //!< Local generated event
std::string eventData; //!< data link with the event
ewol::key::Special specialKey; //!< special board key
char32_t unicodeValue; //!< 0 if not used
enum ewol::key::keyboard keyboardMoveValue; //!< ewol::EVENT_KB_MOVE_TYPE_NONE if not used
EventShortCut(void) {
broadcastEvent = false;
generateEventId = NULL;
eventData = "";
unicodeValue = 0;
keyboardMoveValue = ewol::key::keyboardUnknow;
};
~EventShortCut(void) { };
};
/**
* @brief Widget class is the main widget interface, it hase some generic properties:
* :** known his parent
* :** Can be display at a special position with a special scale
* :** Can get focus
* :** Receive Event (keyboard / mouse / ...)
*
*/
class Widget : public ewol::Object {
public:
// Config list of properties
static const char* const configFill;
static const char* const configExpand;
static const char* const configHide;
static const char* const configFocus;
static const char* const configMinSize;
static const char* const configMaxSize;
static const char* const configGravity;
public:
/**
* @brief Constructor of the widget classes
* @return (no execption generated (not managed in embended platform))
*/
Widget(void);
/**
* @brief Destructor of the widget classes
*/
virtual ~Widget(void) {
vec2 plop = vec2(15.2, 56.6f);
}
};
};
#endif

View File

@ -1,6 +1,6 @@
<?declaration attr="plop"/>
<?declaration attr="plop"?>
<node>
<node2 attribute="data string">
<node2 attribute="da\"ta string">
<emptyNode/>
<!-- comment -->
direct data