[DEV] correct some parsing, add js and set back part of ctags

This commit is contained in:
Edouard DUPIN 2017-09-05 21:12:12 +02:00
parent 735bfbc9e9
commit 24616dac9c
9 changed files with 180 additions and 34 deletions

View File

@ -57,7 +57,7 @@
</rule>
<rule name="simple quote text">
<color>doubleQuoteText</color>
<regex>&apos;(\\(&apos;|n|t|v|b|r|f|a|\\|\?|0|o[0-7]{2}|x[0-9a-fA-F]{2}|u[0-9]{4}|U[0-9]{8})|[^\n])&apos;</regex>
<regex>&apos;(\\(n|t|v|b|r|f|a|\\|\?|&apos;|0|o[0-7]{2}|x[0-9a-fA-F]{2}|u[0-9]{4}|U[0-9]{8})|[^\n])&apos;</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="JavaScript">
<ext>(js)</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="doxygen multiline">
<color>commentDoxygen</color>
<regex>
<start>/\*(\*|!)</start>
<stop>\*/</stop>
</regex>
<sub>doxyparse</sub>
</rule>
<rule name="comment multiline">
<color>comment</color>
<regex>
<start>/\*</start>
<stop>\*/</stop>
</regex>
<sub>TODO</sub>
</rule>
<rule name="comment multiline ERROR">
<color>SYNTAX_ERROR</color>
<regex>
<start>/\*</start>
</regex>
</rule>
<rule name="inline doxygen">
<color>commentDoxygen</color>
<regex>//!.*$</regex>
<sub>doxyparse</sub>
</rule>
<rule name="inline comment">
<color>comment</color>
<regex>//.*$</regex>
<sub>TODO</sub>
</rule>
<rule name="double quote text">
<color>doubleQuoteText</color>
<regex>&quot;(\\(n|t|v|b|r|f|a|\\|\?|&quot;|0|o[0-7]{2}|x[0-9a-fA-F]{2}|u[0-9]{4}|U[0-9]{8})|.)*&quot;</regex>
</rule>
<rule name="simple quote text">
<color>doubleQuoteText</color>
<regex>&apos;(\\(n|t|v|b|r|f|a|\\|\?|&apos;|0|o[0-7]{2}|x[0-9a-fA-F]{2}|u[0-9]{4}|U[0-9]{8})|.)*&apos;</regex>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="my keyword">
<color>keyword</color>
<regex>\{|\}|\[|\]</regex>
</rule>
<rule name="separator">
<color>error</color>
<regex>:|,</regex>
</rule>
<rule name="numeric constant">
<color>number</color>
<regex>\@((0(x|X)[0-9a-fA-F]*)|(\d+\.?\d*|\.\d+)((e|E)(\+|\-)?\d+)?)(L|l|UL|ul|u|U|F|f)?\@</regex>
</rule>
<rule name="my boolean">
<color>boolean</color>
<regex>\@true|false\@</regex>
</rule>
<rule name="my keyword">
<color>keyword</color>
<regex>\@let|var|function|typeof|alert\@</regex>
</rule>
<rule name="BIG LETTER">
<color>macro</color>
<regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex>
</rule>
<rule name="function input">
<color>inputFunction</color>
<regex>\@_\w+\@</regex>
</rule>
<rule name="Function name">
<color>functionName</color>
<regex>\@((\w|_)+[ \t]*\()</regex>
</rule>
<rule name="lambda">
<color>boolean</color>
<regex>=&gt;</regex>
</rule>
<rule name="condition">
<color>boolean</color>
<regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}</regex>
</rule>
<rule name="simple operator">
<color>preprocesseur</color>
<regex>=|\+|-|&amp;|\|</regex>
</rule>
<rule name="simpleQuteTextError">
<color>SYNTAX_ERROR</color>
<regex>&apos;|&quot;</regex>
</rule>
</pass2>
<pass name="doxyparse">
<rule name="knownkey">
<color>doxygen-key-known</color>
<regex>(\@|\\)[\t ]*(addindex|addtogroup|anchor|arg|attention|author|authors|a|brief|bug|b|callgraph|category|cite|class|code|cond|copybrief|copydetails|copydoc|copyright|date|def|defgroup|deprecated|details|diafile|dir|docbookonly|dontinclude|dot|dotfile|else|elseif|em|endcode|endcond|enddocbookonly|enddot|endhtmlonly|endif|endinternal|endlatexonly|endlink|endmanonly|endmsc|endparblock|endrtfonly|endsecreflist|endverbatim|enduml|endxmlonly|enum|example|exception|extends|e|file|fn|headerfile|hidecallergraph|hidecallgraph|hideinitializer|htmlinclude|htmlonly|idlexcept|ifnot|if|image|implements|includelineno|include|ingroup|internal|invariant|interface|latexinclude|latexonly|line|link|license|li|mainpage|manonly|memberof|msc|mscfile|name|namespace|nosubgrouping|note|n|overload|package|page|paragraph|param|parblock|par|post|pre|private|privatesection|property|protected|protectedsection|protocol|public|publicsection|pure|p|refitem|ref|related|relates|relatedalso|relatesalso|remark|remarks|result|return|returns|retval|rtfonly|sa|secreflist|section|see|short|showinitializer|since|skip|skipline|snippet|startuml|struct|subpage|subsection|subsubsection|tableofcontents|test|throw|throws|todo|tparam|typedef|union|until|var|verbatim|verbinclude|version|vhdlflow|warning|weakgroup|xmlonly|xrefitem)</regex>
</rule>
<rule name="key">
<color>doxygen-key</color>
<regex>(\@|\\)[\t ]*\w+</regex>
</rule>
<rule name="in-out">
<color>doxygen-in-out</color>
<regex>\[(in|in,out|out)\]</regex>
</rule>
<rule name="function input">
<color>inputFunction</color>
<regex>\@_\w+\@</regex>
</rule>
</pass>
<pass name="TODO">
<rule name="function input">
<color>SYNTAX_ERROR</color>
<regex>TODO[ \t]*:.*$</regex>
</rule>
</pass>
</EdnLang>

View File

@ -50,7 +50,7 @@
</rule>
<rule name="my keyword">
<color>inputFunction</color>
<regex>\$_[a-zA-Z_][a-zA-Z0-9_]*\b</regex>
<regex>\$_[a-zA-Z_][a-zA-Z0-9_]*\@</regex>
</rule>
<rule name="my keyword">
<color>keyword</color>
@ -78,7 +78,7 @@
</rule>
<rule name="BIG LETTER">
<color>macro</color>
<regex>\b([A-Z_][A-Z_0-9]{3,500})\b</regex>
<regex>\@([A-Z_][A-Z_0-9]{3,500})\@</regex>
</rule>
<rule name="Function name">
<color>functionName</color>

View File

@ -93,6 +93,7 @@ def configure(target, my_module):
my_module.copy_path('data/languages/glsl/*.xml','languages/glsl/')
my_module.copy_path('data/languages/in/*.xml','languages/in/')
my_module.copy_path('data/languages/java/*.xml','languages/java/')
my_module.copy_path('data/languages/js/*.xml','languages/js/')
my_module.copy_path('data/languages/json/*.xml','languages/json/')
my_module.copy_path('data/languages/lua/*.xml','languages/lua/')
my_module.copy_path('data/languages/makefile/*.xml','languages/makefile/')

View File

@ -13,7 +13,7 @@ appl::HighlightPattern::HighlightPattern(const ememory::SharedPtr<appl::GlyphPai
m_hasParsingError(true),
m_regexValue(),
m_hasEndRegEx(false),
m_regExp(),
m_regex(),
m_colorName(""),
m_level(0) {
parseRules(_child, _level);
@ -25,7 +25,7 @@ appl::HighlightPattern::HighlightPattern() :
m_hasParsingError(true),
m_regexValue(),
m_hasEndRegEx(false),
m_regExp(),
m_regex(),
m_colorName(""),
m_level(0) {
@ -35,24 +35,24 @@ appl::HighlightPattern::~HighlightPattern() {
}
void appl::HighlightPattern::setPatern(const etk::String& _regExp, const etk::String& _regExpStop, bool _hasEndRegEx) {
m_regexValue[0] = _regExp;
m_regexValue[1] = _regExpStop;
void appl::HighlightPattern::setPatern(const etk::String& _regex, const etk::String& _regexStop, bool _hasEndRegEx) {
m_regexValue[0] = _regex;
m_regexValue[1] = _regexStop;
m_hasEndRegEx = _hasEndRegEx;
APPL_DEBUG("parse regex='" << _regExp << "' -> '" << _regExpStop << "'");
APPL_DEBUG("parse regex='" << _regex << "' -> '" << _regexStop << "'");
m_hasParsingError = false;
if (_regExp != "") {
m_regExp[0].compile(_regExp);
if (m_regExp[0].getStatus() == false) {
if (_regex != "") {
m_regex[0].compile(_regex);
if (m_regex[0].getStatus() == false) {
m_hasParsingError = true;
APPL_ERROR("can not parse regex for : " << _regExp);
APPL_ERROR("can not parse regex for : " << _regex);
}
}
if (_regExpStop != "") {
m_regExp[1].compile(_regExpStop);
if (m_regExp[1].getStatus() == false) {
if (_regexStop != "") {
m_regex[1].compile(_regexStop);
if (m_regex[1].getStatus() == false) {
m_hasParsingError = true;
APPL_ERROR("can not parse regex for : " << _regExpStop);
APPL_ERROR("can not parse regex for : " << _regexStop);
}
}
}
@ -153,9 +153,9 @@ bool appl::HighlightPattern::find(int32_t _start,
return false;
}
// when we have only one element:
if (m_regExp[0].processOneElement(_buffer, _start, _stop) == true) {
_resultat.start = m_regExp[0].start();
_resultat.stop = m_regExp[0].stop();
if (m_regex[0].processOneElement(_buffer, _start, _stop) == true) {
_resultat.start = m_regex[0].start();
_resultat.stop = m_regex[0].stop();
//APPL_DEBUG("find data at : start=" << _resultat.start << " stop=" << _resultat.stop << " data='" <<etk::String(_buffer, _resultat.start, _resultat.stop-_resultat.start) << "'" );
//APPL_DEBUG("find data at : start=" << _resultat.start << " stop=" << _resultat.stop );
if (m_hasEndRegEx == true) {
@ -166,8 +166,8 @@ bool appl::HighlightPattern::find(int32_t _start,
}
_start = _resultat.stop;
while (_start < _stop) {
if (m_regExp[1].processOneElement(_buffer, _start, _stop) == true) {
_resultat.stop = m_regExp[1].stop();
if (m_regex[1].processOneElement(_buffer, _start, _stop) == true) {
_resultat.stop = m_regex[1].stop();
return true;
}
_start++;

View File

@ -45,9 +45,9 @@ namespace appl {
bool m_hasParsingError;
etk::String m_regexValue[2];
bool m_hasEndRegEx;
etk::RegEx<etk::Buffer> m_regExp[2]; //!< Start of Regular expression
etk::RegEx<etk::Buffer> m_regex[2]; //!< Start of Regular expression
public:
void setPatern(const etk::String& _regExp, const etk::String& _regExpStop="", bool _hasEndRegEx=false);
void setPatern(const etk::String& _regex, const etk::String& _regexStop="", bool _hasEndRegEx=false);
etk::Pair<etk::String,etk::String> getPaternString();
private:
etk::String m_colorName; //!< Current color name

View File

@ -10,6 +10,12 @@
#include <ewol/context/Context.hpp>
#include <appl/Gui/TagFileSelection.hpp>
static etk::String g_staticCtagsFileName;
void appl::setCtagsFileName(const etk::String& _file) {
g_staticCtagsFileName = _file;
}
appl::TextPluginCtags::TextPluginCtags() :
m_tagFolderBase(""),
m_tagFilename(""),
@ -18,6 +24,10 @@ appl::TextPluginCtags::TextPluginCtags() :
// load buffer manager:
m_bufferManager = appl::BufferManager::create();
addObjectType("appl::TextPluginCtags");
if (g_staticCtagsFileName != "") {
m_tagFilename = g_staticCtagsFileName;
loadTagFile();
}
}
appl::TextPluginCtags::~TextPluginCtags() {
@ -25,7 +35,6 @@ appl::TextPluginCtags::~TextPluginCtags() {
}
void appl::TextPluginCtags::onPluginEnable(appl::TextViewer& _textDrawer) {
// add event :
_textDrawer.ext_shortCutAdd("ctrl+d", "appl::TextPluginCtags::JumpDestination");
_textDrawer.ext_shortCutAdd("ctrl+shift+d", "appl::TextPluginCtags::JumpBack");
_textDrawer.ext_shortCutAdd("ctrl+alt+d", "appl::TextPluginCtags::OpenCtagsFile");
@ -83,7 +92,11 @@ void appl::TextPluginCtags::jumpFile(const etk::String& _filename, int64_t _line
// save the current file in the history
// TODO : registerHistory();
if (m_bufferManager != nullptr) {
m_bufferManager->open(_filename);
etk::String plop = _filename;
while (plop[0] == '/') {
plop.erase(0);
}
m_bufferManager->open(plop);
}
//sendMultiCast(appl::MsgSelectGotoLineSelect, etk::toString(_lineId));
APPL_TODO("request jup at line ...");

View File

@ -13,8 +13,10 @@
// create ctags file : "ctags-exuberant --fields=n -R"
// --fields=n add the line number needed for this software version ..
// ctags --recurse -f tags --fields=n -h ".h.hpp" --tag-relative=yes framework/atria-soft/
namespace appl {
void setCtagsFileName(const etk::String& _file);
class TextPluginCtags : public appl::TextViewerPlugin {
private:
// Global plugin data (not specific on buffer :

View File

@ -24,6 +24,7 @@
#include <appl/Gui/Search.hpp>
#include <appl/ctags/readtags.hpp>
#include <appl/globalMsg.hpp>
#include <appl/TextPluginCtags.hpp>
class MainApplication : public ewol::context::Application {
private:
@ -36,7 +37,7 @@ class MainApplication : public ewol::context::Application {
etk::String tmpppp = _context.getCmd().get(iii);
if ( tmpppp == "-h"
|| tmpppp == "--help") {
APPL_INFO(" -t c-flags-file-name" );
APPL_INFO(" --ctags=xxx c-flags-file-name" );
APPL_INFO(" -h/--help display this help" );
exit(0);
}
@ -97,17 +98,13 @@ class MainApplication : public ewol::context::Application {
// add files
APPL_INFO("show list of files : ");
bool ctagDetected = false;
for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) {
etk::String tmpppp = _context.getCmd().get(iii);
if (tmpppp == "-t") {
ctagDetected = true;
} else if (ctagDetected == true) {
if (tmpppp.startWith("--ctags=") == true) {
etk::FSNode file(tmpppp);
etk::String name = file.getName();
etk::String name = tmpppp.extract(8);
APPL_INFO("Load ctag file : \"" << name << "\"" );
ctagDetected = false;
//_context.getEObjectManager().multiCast().anonymousSend(ednMsgCtagsLoadFile, name);
appl::setCtagsFileName(name);
} else if ( tmpppp == "-h"
|| tmpppp == "--help") {
// nothing to do ...
@ -166,6 +163,18 @@ int main(int _argc, const char *_argv[]) {
APPL_ERROR(" base signature = " << typeid(etk::String).name());
APPL_CRITICAL(" END ");
*/
// this is really bad ...
for( int32_t iii=0 ; iii<_argc; iii++) {
etk::String tmpppp = _argv[iii];
if (tmpppp.startWith("--ctags=") == true) {
etk::FSNode file(tmpppp);
etk::String name = tmpppp.extract(8);
APPL_INFO("Load ctag file : \"" << name << "\"" );
appl::setCtagsFileName(name);
}
}
// second possibility
return ewol::run(ETK_NEW(MainApplication), _argc, _argv);
}