32 vMethods.push_back(
"NO_SYNTAX_ELEMENTS");
34 vOptions.push_back(
"NO_SYNTAX_ELEMENTS");
91 if (_sPath.length() && !
sPath.length())
94 std::ifstream file_in;
98 file_in.open(
sPath +
"lang\\syntaxelements.nlng");
104 while (!file_in.eof())
107 std::getline(file_in, sLine);
113 if (sLine.front() ==
'#')
119 if (sLine.substr(0, 13) ==
"NSCR_COMMANDS")
121 else if (sLine.substr(0, 13) ==
"NPRC_COMMANDS")
123 else if (sLine.substr(0, 9) ==
"FUNCTIONS")
125 else if (sLine.substr(0, 11) ==
"METHODSARGS")
127 else if (sLine.substr(0, 7) ==
"METHODS")
129 else if (sLine.substr(0, 7) ==
"OPTIONS")
131 else if (sLine.substr(0, 9) ==
"CONSTANTS")
133 else if (sLine.substr(0, 11) ==
"SPECIALVALS")
135 else if (sLine.substr(0, 9) ==
"OPERATORS")
137 else if (sLine.substr(0, 11) ==
"DOCKEYWORDS")
139 else if (sLine.substr(0, 9) ==
"BLOCKDEFS")
141 else if (sLine.substr(0, 14) ==
"MATLABKEYWORDS")
143 else if (sLine.substr(0, 15) ==
"MATLABFUNCTIONS")
145 else if (sLine.substr(0, 11) ==
"CPPKEYWORDS")
147 else if (sLine.substr(0, 12) ==
"CPPFUNCTIONS")
149 else if (sLine.substr(0, 11) ==
"TEXKEYWORDS")
213 std::string endWords;
217 sReturn += def.startWord +
" ";
218 endWords += def.endWord +
" ";
221 return sReturn +
";" + endWords;
236 std::string sReturn =
"";
239 for (
size_t i = 0; i < vVector.size(); i++)
241 sReturn += vVector[i] +
" ";
258 std::vector<std::string> vReturn;
261 while (sString.length())
264 while (sString.front() ==
' ')
268 if (sString.find(
' ') != std::string::npos)
271 vReturn.push_back(sString.substr(0,sString.find(
' ')));
274 sString.erase(0,sString.find(
' ')+1);
277 if (!vReturn.back().length())
283 vReturn.push_back(sString);
302 std::vector<SyntaxBlockDefinition> vDefs;
306 for (
size_t i = 0; i < defs.size(); i++)
308 std::vector<std::string> words =
splitString(defs[i]);
311 if (words.size() < 2)
316 definition.
endWord = words.back();
318 if (words.size() > 2)
321 if (words.size() > 3)
324 vDefs.push_back(definition);
342 for (
size_t i = 0; i < vVector.size(); i++)
345 if (vVector[i] == sString)
366 if (!sCommandLine.length())
371 if (sCommandLine.front() == (
char)15)
375 if (sCommandLine.substr(0, 3) ==
"|!>")
382 colors.assign(sCommandLine.length(),
'0'+
SYNTAX_STD);
387 if (sCommandLine.substr(0,3) !=
"|<-"
388 && sCommandLine.substr(0,5) !=
"|-\?\?>"
389 && (sCommandLine.substr(0,2) !=
"||" || sCommandLine.substr(0,4) ==
"||->")
390 && sCommandLine.substr(0,4) !=
"|FOR"
391 && sCommandLine.substr(0,5) !=
"|ELSE"
392 && sCommandLine.substr(0,5) !=
"|ELIF"
393 && sCommandLine.substr(0,5) !=
"|PROC"
394 && sCommandLine.substr(0,5) !=
"|COMP"
395 && sCommandLine.substr(0,3) !=
"|IF"
396 && sCommandLine.substr(0,4) !=
"|TRY"
397 && sCommandLine.substr(0,5) !=
"|CTCH"
398 && sCommandLine.substr(0,4) !=
"|WHL")
402 if (sCommandLine.find(
'"') != std::string::npos)
409 for (
size_t k = sCommandLine.find(
'"'); k < sCommandLine.length(); k++)
411 if (c == c_normal && sCommandLine[k] ==
'"' && (!k || sCommandLine[k-1] !=
'\\'))
420 if (c == c_string && sCommandLine[k] ==
'"' && k > sCommandLine.find(
'"') && sCommandLine[k-1] !=
'\\')
428 if (sCommandLine.find(
'$') != std::string::npos)
435 for (
size_t k = sCommandLine.find(
'$'); k < sCommandLine.length(); k++)
437 if (sCommandLine[k] ==
'(' || sCommandLine[k] ==
' ')
439 else if (sCommandLine[k] ==
'$')
450 for (
unsigned int i = 0; i < sCommandLine.length(); i++)
453 if (!i && sCommandLine.substr(0,3) ==
"|<-")
455 else if (!i && (sCommandLine.substr(0,5) ==
"|-\?\?>"
456 || sCommandLine.substr(0,4) ==
"|FOR"
457 || sCommandLine.substr(0,5) ==
"|ELSE"
458 || sCommandLine.substr(0,5) ==
"|ELIF"
459 || sCommandLine.substr(0,4) ==
"|WHL"
460 || sCommandLine.substr(0,3) ==
"|IF"
461 || sCommandLine.substr(0,4) ==
"|TRY"
462 || sCommandLine.substr(0,5) ==
"|CTCH"
463 || sCommandLine.substr(0,5) ==
"|PROC"
464 || sCommandLine.substr(0,5) ==
"|COMP"))
465 i += sCommandLine.find(
'>')+1;
466 else if (!i && sCommandLine.substr(0,4) ==
"||<-")
468 else if (!i && sCommandLine.substr(0,3) ==
"|| ")
472 if (sCommandLine[i] ==
' ')
476 if (sCommandLine[i] >=
'0' && sCommandLine[i] <=
'9')
478 unsigned int nLen = 0;
481 while (i+nLen < sCommandLine.length()
483 && ((sCommandLine[i+nLen] >=
'0' && sCommandLine[i+nLen] <=
'9')
484 || sCommandLine[i+nLen] ==
'.'
485 || sCommandLine[i+nLen] ==
'e'
486 || sCommandLine[i+nLen] ==
'E'
487 || sCommandLine[i+nLen] ==
'i'
488 || ((sCommandLine[i+nLen] ==
'-' || sCommandLine[i+nLen] ==
'+')
489 && (sCommandLine[i+nLen-1] ==
'e' || sCommandLine[i+nLen-1] ==
'E'))
503 if (sCommandLine.substr(i, 2) ==
"##")
505 size_t len = sCommandLine.find(
"\\n", i+2);
507 if (len == std::string::npos)
509 len = colors.length() - i;
523 if (sCommandLine.substr(i, 2) ==
"#*")
525 size_t len = sCommandLine.find(
"*#", i+2);
527 if (len == std::string::npos)
529 len = colors.length() - i;
542 unsigned int nLen = 0;
545 while (i+nLen < sCommandLine.length()
547 && sCommandLine[i+nLen] !=
' '
548 && sCommandLine[i+nLen] !=
'\''
570 else if (i+nLen <= sCommandLine.length()
571 && sCommandLine.find(
'.', i) < i+nLen)
574 size_t nPos = sCommandLine.find(
'.', i)+1;
576 for (
size_t n = nPos; n < i+nLen; n++)
578 if (sCommandLine[n] ==
'.')
595 else if (i+nLen < sCommandLine.length()
596 && sCommandLine[i+nLen] ==
'('
672 std::string sAutoCompList;
686 for (
size_t i = 0; i <
vFunctions.size(); i++)
690 for (
size_t i = 0; i <
vMethods.size(); i++)
698 for (
size_t i = 0; i <
vOptions.size(); i++)
702 for (
size_t i = 0; i <
vConstants.size(); i++)
718 for (
size_t i = 0; i <
vOperators.size(); i++)
726 bool selectMethods = useSmartSense && sFirstChars.front() ==
'.';
729 sFirstChars.erase(0, 1);
734 if ((iter->first).front() == sFirstChars.front())
744 if (sFirstChars == (iter->first).substr(0, sFirstChars.length()))
745 sAutoCompList += iter->second.first +
" ";
747 else if ((iter->first).front() > sFirstChars.front())
752 return sAutoCompList;
766 std::string sAutoCompList;
781 if ((iter->first).front() == sFirstChars.front())
783 if (sFirstChars == (iter->first).substr(0,sFirstChars.length()))
784 sAutoCompList += (iter->first).substr((iter->first).find(
'|')+1) +
"?" +
toString((
int)(iter->second)) +
" ";
786 else if ((iter->first).front() > sFirstChars.front())
790 return sAutoCompList;
804 std::string sAutoCompList;
819 if ((iter->first).front() == sFirstChars.front())
821 if (sFirstChars == (iter->first).substr(0,sFirstChars.length()))
822 sAutoCompList += (iter->first).substr((iter->first).find(
'|')+1) +
"?" +
toString((
int)(iter->second)) +
" ";
824 else if ((iter->first).front() > sFirstChars.front())
828 return sAutoCompList;
842 std::string sAutoCompList;
854 if ((iter->first).front() == sFirstChars.front())
856 if (sFirstChars == (iter->first).substr(0,sFirstChars.length()))
857 sAutoCompList += (iter->first).substr((iter->first).find(
'|')+1) +
"?" +
toString((
int)(iter->second)) +
" ";
859 else if ((iter->first).front() > sFirstChars.front())
863 return sAutoCompList;
883 std::string sProcName;
884 static std::string sStandardNamespaces[] = {
"main~",
"this~",
"thisfile~"};
887 if (sSelectedNameSpace.length())
889 if (sSelectedNameSpace.back() !=
'~')
890 sProcName = sSelectedNameSpace +
"~" + sFirstChars;
892 sProcName = sSelectedNameSpace + sFirstChars;
894 else if (sBaseNameSpace.length())
896 if (sBaseNameSpace.back() !=
'~')
897 sProcName = sBaseNameSpace +
"~" + sFirstChars;
899 sProcName = sBaseNameSpace + sFirstChars;
902 sProcName = sFirstChars;
907 std::string sAutoCompList =
" ";
910 if (!sSelectedNameSpace.length())
912 for (
size_t i = 0; i < 3; i++)
914 if (sStandardNamespaces[i].substr(0, sFirstChars.length()) == sFirstChars)
928 if (sSelectedNameSpace.length())
932 if (sToken.find(
'~', sFirstChars.length()) != std::string::npos)
934 sToken.erase(sToken.find(
'~', sFirstChars.length())+1);
940 else if (
vProcedureTree[i].find(
'~', sProcName.length()) != std::string::npos)
946 if (!sSelectedNameSpace.length())
949 sToken.erase(0, sBaseNameSpace.length());
951 if (sToken.front() ==
'~')
956 if (sAutoCompList.find(
" " + sToken) == std::string::npos)
957 sAutoCompList += sToken;
962 return sAutoCompList.substr(1);
979 std::string sProcName;
980 static std::string sStandardNamespaces[] = {
"main~",
"this~",
"thisfile~"};
981 sProcName = sFirstChars;
982 std::string sAutoCompList =
" ";
985 for (
size_t i = 0; i < 3; i++)
987 if (sStandardNamespaces[i].substr(0, sFirstChars.length()) == sFirstChars)
998 if (
vProcedureTree[i].find(
'~', sProcName.length()) != std::string::npos)
1001 if (sAutoCompList.find(
" " + sToken) == std::string::npos)
1002 sAutoCompList += sToken;
1007 return sAutoCompList.substr(1);
std::string toLowerCase(const std::string &)
Converts uppercase to lowercase letters.
This class extends the std::vector for endlessness.
This class contains all needed keywords to highlight their occurences correspondingly....
std::map< std::string, int > mAutoCompListCPP
void addPlugins(const std::vector< std::string > &vPlugins)
Add the plugin definitions to the command strings. Will reload the standard settings in advance to re...
std::vector< std::string > vProcedureTree
std::string sSingleOperators
bool matchItem(const std::vector< std::string > &vVector, const std::string &sString)
This function searches for a match of the passed string in the passed vector.
void loadSyntax(const std::string &_sPath="")
Member function for loading the syntax element definitions.
std::vector< std::string > vCppFunctions
void setProcedureTree(const std::vector< std::string > &vTree)
Set the procedure tree (used for autocompleting).
std::vector< SyntaxBlockDefinition > vBlockDefs
std::string getAutoCompListCPP(std::string sFirstChars)
The same as above but specialized for C++ Commands.
std::vector< SyntaxBlockDefinition > splitDefs(std::string sDefString)
Converts a block def string into actual syntax block definitions.
std::vector< std::string > splitString(std::string sString)
This function splits the passed string up into single string tokens.
std::string highlightLine(const std::string &sCommandLine)
This function applies the highlighting colors to the command line (only used in the terminal).
std::vector< std::string > vOptions
std::vector< std::string > vMethods
std::vector< std::string > vFunctions
std::vector< std::string > vOperators
std::string getAutoCompListMATLAB(std::string sFirstChars)
The same as above but specialized for MATLAB commands.
std::vector< std::string > vDocKeyWords
std::string getNameSpaceAutoCompList(std::string sFirstChars)
This function returns the autocompletion list for the namespaces.
NumeReSyntax()
Default constructor.
std::vector< std::string > vConstants
std::vector< std::string > vNSCRCommands
std::map< std::string, std::pair< std::string, int > > mAutoCompList
std::string getAutoCompListTeX(std::string sFirstChars)
The same as above but specialized for LaTeX Commands.
std::vector< std::string > vMethodsArgs
std::string getBlockDefs() const
Returns all block definitions as a folding string for the lexers.
std::string constructString(const std::vector< std::string > &vVector) const
This member function concatenates the passed vector elements to a whitespace- separated single string...
std::string getAutoCompList(std::string sFirstChars, bool useSmartSense=false)
This function returns the autocompletion list for the editor.
std::map< std::string, int > mAutoCompListTeX
std::vector< std::string > vMatlabKeyWords
std::string highlightError(const std::string &sCommandLine)
Highlight an error message. We simply use the color of the operators (which is red as default).
std::vector< std::string > vMatlabFunctions
std::vector< std::string > vTeXKeyWords
std::vector< std::string > vSpecialValues
std::string highlightWarning(const std::string &sCommandLine)
Highlight a warning message. We simply use the color of numbers (which is orange as default).
std::string getProcAutoCompList(std::string sFirstChars, std::string sBaseNameSpace, std::string sSelectedNameSpace)
This function will return the autocompletion list for the procedures based upon the provided procedur...
std::vector< std::string > vCppKeyWords
std::vector< std::string > vNPRCCommands
std::map< std::string, int > mAutoCompListMATLAB
A simple structure to define a syntax block for folding, etc.
std::string toString(int)
Converts an integer to a string without the Settings bloat.