[DEV] Update the parsing of many languages (pyton, cmake) is now good

This commit is contained in:
Edouard DUPIN 2014-10-09 21:23:19 +02:00
parent 67a08dd775
commit a201439665
24 changed files with 170 additions and 91 deletions

View File

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Assembleur">
<ext>*.s</ext>
<ext>*.S</ext>
<ext>*.asm</ext>
<ext>.*\.(s|S|asm)</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline doxygen">
<color>commentDoxygen</color>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Bash script">
<ext>*.sh</ext>
<ext>.*\.sh</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="first line">
<color>commentDoxygen</color>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Boulou log">
<ext>*.boo</ext>
<ext>.*\.boo</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="comment ##">
<color>SYNTAX_ERROR</color>
@ -24,7 +24,6 @@
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="pourcentage OK">
<color>TestResultOK</color>
<regex>100%</regex>

View File

@ -1,14 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="C/C++">
<ext>*.c</ext>
<ext>*.cpp</ext>
<ext>*.cxx</ext>
<ext>*.cc</ext>
<ext>*.h</ext>
<ext>*.hpp</ext>
<ext>*.hxx</ext>
<ext>*.m</ext>
<ext>*.mm</ext>
<ext>.*\.(c|cpp|cxx|cc|h|hpp|hxx|m|mm)</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="doxygen multiline">
<color>commentDoxygen</color>
@ -28,7 +20,7 @@
</rule>
<rule name="#if 0">
<color>preprocesseur</color>
<regex>#[ \t]*if 0(.|\r|\n)*?(#endif|else)</regex>
<regex>#[ \t]*if 0(.|\r|\n)*?#(endif|else)</regex>
</rule>
<rule name="#if 0 ERROR">
<color>SYNTAX_ERROR</color>

View File

@ -1,23 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="C/C++">
<EdnLang version="0.1" lang="cmake">
<ext>CMakeLists.txt</ext>
<ext>CMakeCache.txt</ext>
<pass1>
<rule name="my comment doxygen">
<color>commentDoxygen</color>
<regex>##.*?$</regex>
<regex>##.*</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>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
@ -27,7 +27,7 @@
</rule>
<rule name="my function keyword">
<color>systemFunction</color>
<regex>\b(set|include_directories|add_definitions|add_library|include_directories|target_link_libraries|project|include|check_include_file|enable_testing|option|cmake_minimum_required|add_definitions|check_include_file|configure_file|include_directories|add_custom_command|add_executable|add_test)\b</regex>
<regex>\b(set|include_directories|add_definitions|add_library|include_directories|target_link_libraries|project|include|check_include_file|enable_testing|option|cmake_minimum_required|add_definitions|check_include_file|configure_file|include_directories|add_custom_command|add_executable|add_test|find_package|pkg_check_modules|set_target_properties|source_group)\b</regex>
</rule>
<rule name="Variable">
<color>inputFunction</color>
@ -45,5 +45,9 @@
<color>functionName</color>
<regex>\b(\w|_)+[ \t]*\(</regex>
</rule>
<rule name="files path">
<color>memberClass</color>
<regex>[\w-]*(\.|/)\w*</regex>
</rule>
</pass2>
</EdnLang>

View File

@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Glsl">
<ext>*.glsl</ext>
<ext>*.vert</ext>
<ext>*.frag</ext>
<ext>*.prog</ext>
<ext>.*\.(glsl|vert|frag|prog)</ext>
<pass1>
<rule name="my comment multiline doxygen">
<color>commentDoxygen</color>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Kernel conf file">
<ext>*.in</ext>
<ext>.*\.in</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my preprocesseur">
<color>preprocesseur</color>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Java">
<ext>*.java</ext>
<ext>.*\.java</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline doxygen">
<color>commentDoxygen</color>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Json">
<ext>*.json</ext>
<ext>.*\.json</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="doubleQuteText">
<color>doubleQuoteText</color>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Lua">
<ext>*.lua</ext>
<ext>.*\.lua</ext>
<pass1>
<rule name="Comment multiline">
<color>comment</color>

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Makefiles">
<ext>Makefile</ext>
<ext>*.mk</ext>
<ext>*.global</ext>
<ext>.*\.(mk|global)</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my preprocesseur">
<color>preprocesseur</color>
@ -32,7 +31,7 @@
</rule>
<rule name="condition">
<color>boolean</color>
<regex>:=|?=|!=|=</regex>
<regex>:=|\?=|!=|=</regex>
</rule>
</pass2>
</EdnLang>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Matlab">
<ext>*.m</ext>
<ext>*.M</ext>
<ext>.*\.(m|M)</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment doxygen">
<color>commentDoxygen</color>
@ -35,7 +34,7 @@
</rule>
<rule name="Function name">
<color>functionName</color>
<regex>\b((\w|_)+[ \t]*\(</regex>
<regex>\b(\w|_)+[ \t]*\(</regex>
</rule>
<rule name="condition">
<color>boolean</color>

View File

@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Php: pretty home page">
<ext>*.php</ext>
<ext>*.php3</ext>
<ext>*.php4</ext>
<ext>*.phtml</ext>
<ext>.*\.(php|php3|php4|phtml)</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline">
<color>comment</color>
@ -57,7 +54,7 @@
</rule>
<rule name="Function name">
<color>functionName</color>
<regex>\b((\w|_)+[ \t]*\(</regex>
<regex>\b\w+[ \t]*\(</regex>
</rule>
<rule name="condition">
<color>boolean</color>

View File

@ -1,22 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Python">
<ext>*.py</ext>
<ext>.*\.py</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline">
<color>comment</color>
<regex>""".*?"""</regex>
<regex>"""(.|\r|\n)*?"""</regex>
</rule>
<rule name="my comment multiline">
<color>comment</color>
<regex>'''.*?'''</regex>
<regex>'''(.|\r|\n)*?'''</regex>
</rule>
<rule name="comment multiline Error">
<color>SYNTAX_ERROR</color>
<regex>("""|''')(.|\n|\r)*</regex>
</rule>
<rule name="my comment doxygen">
<color>commentDoxygen</color>
<regex>##(.|\\[\\\n])*?$</regex>
<regex>##.*</regex>
</rule>
<rule name="my comment">
<color>comment</color>
<regex>#(.|\\[\\\n])*?$</regex>
<regex>#.*</regex>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
@ -64,11 +68,9 @@
<color>boolean</color>
<regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}</regex>
</rule>
<!-- With all elementes : -->
<rule name="BIG LETTER">
<color>macro</color>
<regex>([A-Z]|_){4,500}</regex>
<elemSubColor id="1">doxElem</elemSubColor>
<rule name="simpleQuteTextError">
<color>SYNTAX_ERROR</color>
<regex>'|"</regex>
</rule>
</pass2>
</EdnLang>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.2" lang="XML">
<ext>*.xml</ext>
<ext>*.svg</ext>
<ext>.*\.(xml|svg)</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="Comment">
<color>comment</color>

View File

@ -691,7 +691,7 @@ void appl::Buffer::removeSelection() {
void appl::Buffer::tryFindHighlightType() {
etk::FSNode file(m_fileName);
std::string type = appl::highlightManager::getTypeExtention(file.fileGetExtention());
std::string type = appl::highlightManager::getTypeFile(file.getNameFile());
if (type.size() == 0) {
return;
}

View File

@ -390,31 +390,13 @@ void MainWindows::displayProperty() {
} else {
#ifdef SDGSDFGSDFGSDFGSDFGSTERGDHFGHFDS
std::string menuDescription = "<title>Properties</title>\n";
menuDescription += "<group>\n";
menuDescription += " <title>Editor</title>\n";
menuDescription += " <menu>\n";
menuDescription += " <title>Editor Interface</title>\n";
menuDescription += " <short-title>Editor</short-title>\n";
menuDescription += " <widget>appl-text-viewer</widget>\n";
menuDescription += " </menu>\n";
menuDescription += "<group title='Editor'>\n";
menuDescription += " <menu title='Editor Interface' short-title='Editor' widget='appl-text-viewer'>\n";
menuDescription += "</group>\n";
menuDescription += "<group>\n";
menuDescription += " <title>Gui</title>\n";
menuDescription += " <menu>\n";
menuDescription += " <title>Font selection</title>\n";
menuDescription += " <short-title>Font</short-title>\n";
menuDescription += " <widget></widget>\n";
menuDescription += " </menu>\n";
menuDescription += " <menu>\n";
menuDescription += " <title>Color selection</title>\n";
menuDescription += " <short-title>Color</short-title>\n";
menuDescription += " <widget></widget>\n";
menuDescription += " </menu>\n";
menuDescription += " <menu>\n";
menuDescription += " <title>Theme selection</title>\n";
menuDescription += " <short-title>Theme</short-title>\n";
menuDescription += " <widget></widget>\n";
menuDescription += " </menu>\n";
menuDescription += "<group title='Gui'>\n";
menuDescription += " <menu title='Font selection' short-title='Font' widget=''>\n";
menuDescription += " <menu title='Color selection' short-title='Color' widget=''>\n";
menuDescription += " <menu title='Theme selection' short-title='Theme' widget=''>\n";
menuDescription += "</group>\n";
tmpWidget->setMenu(menuDescription);

View File

@ -114,13 +114,28 @@ appl::Highlight::~Highlight() {
m_listExtentions.clear();
}
bool appl::Highlight::hasExtention(const std::string& _ext) {
bool appl::Highlight::isCompatible(const std::string& _name) {
for (auto &it : m_listExtentions) {
APPL_VERBOSE(" check : " << it << "=?=" << _ext);
if ( it == "*." + _ext
|| it == _ext) {
return true;
APPL_VERBOSE(" check : " << it << "=?=" << _name);
std::regex expression;
try {
expression.assign(it, std::regex_constants::optimize | std::regex_constants::ECMAScript);
} catch (std::regex_error e) {
APPL_ERROR("can not parse regex : '" << e.what() << "' for : " << it);
continue;
}
std::smatch resultMatch;
std::regex_search(_name.begin(), _name.end(), resultMatch, expression, std::regex_constants::match_continuous);
if (resultMatch.size() <= 0) {
continue;
}
if (resultMatch[0].first != _name.begin()) {
continue;
}
if (resultMatch[0].second != _name.end()) {
continue;
}
return true;
}
return false;
}

View File

@ -48,7 +48,7 @@ namespace appl {
return m_typeName;
}
public:
bool hasExtention(const std::string& _ext);
bool isCompatible(const std::string& _name);
bool fileNameCompatible(const std::string& _fileName);
void display();
void parse(int64_t _start,

View File

@ -70,19 +70,19 @@ void appl::highlightManager::unInit() {
hlList.clear();
}
std::string appl::highlightManager::getTypeExtention(const std::string& _extention) {
if (_extention.size() == 0) {
std::string appl::highlightManager::getTypeFile(const std::string& _fileName) {
if (_fileName.size() == 0) {
return "";
}
APPL_DEBUG("Try to find type for extention : '" << _extention << "' in " << s_list().size() << " types");
APPL_DEBUG("Try to find type for extention : '" << _fileName << "' in " << s_list().size() << " types");
std::vector<std::shared_ptr<Highlight>>& hlList = s_list();
for (auto &it : hlList) {
if (it == nullptr) {
continue;
}
APPL_DEBUG(" check : " << it->getTypeName());
if (it->hasExtention(_extention) == true) {
APPL_DEBUG("Find type for extention : " << _extention
if (it->isCompatible(_fileName) == true) {
APPL_DEBUG("Find type for extention : " << _fileName
<< " type : " << it->getTypeName());
return it->getTypeName();
}

View File

@ -27,10 +27,10 @@ namespace appl {
void unInit();
/**
* @brief Un-Init the Highlight manager
* @param[in] extention of the file
* @param[in] _fileName name of the file
* @return type of highlight
*/
std::string getTypeExtention(const std::string& _extention);
std::string getTypeFile(const std::string& _fileName);
/**
* @brief Get filename with type.
* @param[in] _type Type name of the highlight.

View File

52
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,52 @@
set(GAMEPLAY_SRC
src/AbsoluteLayout.cpp
src/AbsoluteLayout.h
src/BoundingBox.h
src/Transform.h
src/Vector2.cpp
src/Vector2.h
src/lua/lua_ThemeUVs.h
src/lua/lua_Touch.cpp
src/lua/lua_Touch.h
src/lua/lua_TouchTouchEvent.cpp
src/lua/lua_TouchTouchEvent
)
include_directories(
src
../external-deps/lua/include
../external-deps/bullet/include
../external-deps/png/include
../external-deps/zlib/include
../external-deps/oggvorbis/include
../external-deps/openal/include
../external-deps/glew/include
)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
include_directories(${GTK2_INCLUDE_DIRS})
add_definitions(${GTK2_CFLAGS_OTHER})
add_definitions(-D__linux__)
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-lstdc++)
add_library(gameplay STATIC
${GAMEPLAY_SRC}
${GAMEPLAY_LUA}
)
set_target_properties(gameplay PROPERTIES
OUTPUT_NAME "gameplay"
CLEAN_DIRECT_OUTPUT 1
VERSION ${GAMEPLAY_VERSION}
)
source_group(lua FILES ${GAMEPLAY_LUA})
source_group(res FILES ${GAMEPLAY_RES} ${GAMEPLAY_RES} ${GAMEPLAY_RES_SHADERS} ${GAMEPLAY_RES_UI})
source_group(src FILES ${GAMEPLAY_SRC})

View File

@ -0,0 +1,44 @@
#!/usr/bin/python
import lutinModule as module
import lutinTools as tools
def get_desc():
return "gameplay : video game engine (based on bullet lib)"
"""
multline comment
"""
'''
multline comment
'''
def create(target):
myModule = module.Module(__file__, 'gameplay', 'LIBRARY')
# add the file to compile:
myModule.add_src_file([
'ege/debug.cpp',
'ege/AudioElement.cpp',
'ege/AudioEngine.cpp',
'ege/Camera.cpp'
])
# myModule.copy_folder('data/ParticuleMesh.*','')
# name of the dependency
myModule.add_module_depend(['etk', 'ewol', 'bullet'])
myModule.compile_flags_CC([
'-Wno-write-strings',
'-Wall'])
myModule.add_export_path(tools.get_current_path(__file__))
# add the currrent module at the
return myModule
"""
multline comment error ...