NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
syntax.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2017 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19
20
21
22#ifndef SYNTAX_HPP
23#define SYNTAX_HPP
24
25#include <string>
26#include <vector>
27#include <map>
28#include <fstream>
29
35{
36 std::string startWord;
37 std::string endWord;
38 std::string middleWord1;
39 std::string middleWord2;
40};
41
42
43
55{
56 private:
57 std::vector<std::string> vNSCRCommands;
58 std::vector<std::string> vNPRCCommands;
59 std::vector<std::string> vOptions;
60 std::vector<std::string> vFunctions;
61 std::vector<std::string> vMethods;
62 std::vector<std::string> vMethodsArgs;
63 std::vector<std::string> vConstants;
64 std::vector<std::string> vSpecialValues;
65 std::vector<std::string> vOperators;
66 std::vector<std::string> vDocKeyWords;
67 std::vector<SyntaxBlockDefinition> vBlockDefs;
68 std::vector<std::string> vMatlabKeyWords;
69 std::vector<std::string> vMatlabFunctions;
70 std::vector<std::string> vCppKeyWords;
71 std::vector<std::string> vCppFunctions;
72 std::vector<std::string> vTeXKeyWords;
73
74 std::vector<std::string> vProcedureTree;
75
76 std::string sSingleOperators;
77 std::map<std::string, std::pair<std::string, int>> mAutoCompList;
78 std::map<std::string, int> mAutoCompListMATLAB;
79 std::map<std::string, int> mAutoCompListCPP;
80 std::map<std::string, int> mAutoCompListTeX;
81
82 std::string sPath;
83
84 std::string constructString(const std::vector<std::string>& vVector) const;
85 std::vector<std::string> splitString(std::string sString);
86 std::vector<SyntaxBlockDefinition> splitDefs(std::string sDefString);
87 bool matchItem(const std::vector<std::string>& vVector, const std::string& sString);
88 public:
90 {
106 };
107
108 NumeReSyntax();
109 NumeReSyntax(const std::string& _sPath);
110 NumeReSyntax(const std::string& _sPath, const std::vector<std::string>& vPlugins);
111
112 void loadSyntax(const std::string& _sPath = "");
113 void addPlugins(const std::vector<std::string>& vPlugins);
114 void setProcedureTree(const std::vector<std::string>& vTree);
115 std::string getCommands() const
117 std::string getNPRCCommands() const
119 std::string getOptions() const
120 {return constructString(vOptions);}
121 std::string getFunctions() const
122 {return constructString(vFunctions);}
123 std::string getMethods() const
125 std::string getConstants() const
126 {return constructString(vConstants);}
127 std::string getSpecial() const
129 std::string getOperators() const
130 {return constructString(vOperators);}
131 std::string getDocKeyWords() const
133 std::string getBlockDefs() const;
134 std::string getMatlab() const
136 std::string getMatlabFunctions() const
138 std::string getCpp() const
140 std::string getCppFunctions() const
142 std::string getAutoCompList(std::string sFirstChars, bool useSmartSense = false);
143 std::string getAutoCompListMATLAB(std::string sFirstChars);
144 std::string getAutoCompListCPP(std::string sFirstChars);
145 std::string getAutoCompListTeX(std::string sFirstChars);
146 std::string getProcAutoCompList(std::string sFirstChars, std::string sBaseNameSpace, std::string sSelectedNameSpace);
147 std::string getNameSpaceAutoCompList(std::string sFirstChars);
148
149 std::string highlightLine(const std::string& sCommandLine);
150 std::string highlightError(const std::string& sCommandLine);
151 std::string highlightWarning(const std::string& sCommandLine);
152
153 std::vector<SyntaxBlockDefinition> getFullBlockDefs() const
154 {return vBlockDefs;}
155
156};
157#endif // SYNTAX_HPP
158
This class contains all needed keywords to highlight their occurences correspondingly....
Definition: syntax.hpp:55
std::map< std::string, int > mAutoCompListCPP
Definition: syntax.hpp:79
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...
Definition: syntax.cpp:165
std::vector< std::string > vProcedureTree
Definition: syntax.hpp:74
std::string getNPRCCommands() const
Definition: syntax.hpp:117
std::string getConstants() const
Definition: syntax.hpp:125
std::string sSingleOperators
Definition: syntax.hpp:76
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.
Definition: syntax.cpp:340
void loadSyntax(const std::string &_sPath="")
Member function for loading the syntax element definitions.
Definition: syntax.cpp:89
std::vector< std::string > vCppFunctions
Definition: syntax.hpp:71
void setProcedureTree(const std::vector< std::string > &vTree)
Set the procedure tree (used for autocompleting).
Definition: syntax.cpp:182
std::vector< SyntaxBlockDefinition > vBlockDefs
Definition: syntax.hpp:67
std::string getAutoCompListCPP(std::string sFirstChars)
The same as above but specialized for C++ Commands.
Definition: syntax.cpp:802
std::vector< SyntaxBlockDefinition > splitDefs(std::string sDefString)
Converts a block def string into actual syntax block definitions.
Definition: syntax.cpp:300
std::vector< std::string > splitString(std::string sString)
This function splits the passed string up into single string tokens.
Definition: syntax.cpp:256
std::string highlightLine(const std::string &sCommandLine)
This function applies the highlighting colors to the command line (only used in the terminal).
Definition: syntax.cpp:363
std::string getOperators() const
Definition: syntax.hpp:129
std::vector< std::string > vOptions
Definition: syntax.hpp:59
std::vector< std::string > vMethods
Definition: syntax.hpp:61
std::string getMethods() const
Definition: syntax.hpp:123
std::string getDocKeyWords() const
Definition: syntax.hpp:131
std::vector< std::string > vFunctions
Definition: syntax.hpp:60
std::vector< std::string > vOperators
Definition: syntax.hpp:65
@ SYNTAX_OPTION
Definition: syntax.hpp:92
@ SYNTAX_FUNCTION
Definition: syntax.hpp:93
@ SYNTAX_METHODS
Definition: syntax.hpp:102
@ SYNTAX_STRING
Definition: syntax.hpp:96
@ SYNTAX_PROCEDURE
Definition: syntax.hpp:99
@ SYNTAX_COMMENT
Definition: syntax.hpp:103
@ SYNTAX_CONSTANT
Definition: syntax.hpp:94
@ SYNTAX_NPRC_COMMAND
Definition: syntax.hpp:101
@ SYNTAX_COMMAND
Definition: syntax.hpp:91
@ SYNTAX_SPECIALVAL
Definition: syntax.hpp:95
@ SYNTAX_OPERATOR
Definition: syntax.hpp:98
@ SYNTAX_CLUSTER
Definition: syntax.hpp:104
std::string getAutoCompListMATLAB(std::string sFirstChars)
The same as above but specialized for MATLAB commands.
Definition: syntax.cpp:764
std::vector< std::string > vDocKeyWords
Definition: syntax.hpp:66
std::string getNameSpaceAutoCompList(std::string sFirstChars)
This function returns the autocompletion list for the namespaces.
Definition: syntax.cpp:974
NumeReSyntax()
Default constructor.
Definition: syntax.cpp:27
std::vector< std::string > vConstants
Definition: syntax.hpp:63
std::string getCommands() const
Definition: syntax.hpp:115
std::vector< std::string > vNSCRCommands
Definition: syntax.hpp:57
std::map< std::string, std::pair< std::string, int > > mAutoCompList
Definition: syntax.hpp:77
std::string getCpp() const
Definition: syntax.hpp:138
std::string getAutoCompListTeX(std::string sFirstChars)
The same as above but specialized for LaTeX Commands.
Definition: syntax.cpp:840
std::vector< std::string > vMethodsArgs
Definition: syntax.hpp:62
std::string getBlockDefs() const
Returns all block definitions as a folding string for the lexers.
Definition: syntax.cpp:210
std::string constructString(const std::vector< std::string > &vVector) const
This member function concatenates the passed vector elements to a whitespace- separated single string...
Definition: syntax.cpp:234
std::string getSpecial() const
Definition: syntax.hpp:127
std::string getAutoCompList(std::string sFirstChars, bool useSmartSense=false)
This function returns the autocompletion list for the editor.
Definition: syntax.cpp:670
std::string getMatlab() const
Definition: syntax.hpp:134
std::vector< SyntaxBlockDefinition > getFullBlockDefs() const
Definition: syntax.hpp:153
std::map< std::string, int > mAutoCompListTeX
Definition: syntax.hpp:80
std::string getCppFunctions() const
Definition: syntax.hpp:140
std::vector< std::string > vMatlabKeyWords
Definition: syntax.hpp:68
std::string highlightError(const std::string &sCommandLine)
Highlight an error message. We simply use the color of the operators (which is red as default).
Definition: syntax.cpp:636
std::vector< std::string > vMatlabFunctions
Definition: syntax.hpp:69
std::vector< std::string > vTeXKeyWords
Definition: syntax.hpp:72
std::vector< std::string > vSpecialValues
Definition: syntax.hpp:64
std::string getMatlabFunctions() const
Definition: syntax.hpp:136
std::string sPath
Definition: syntax.hpp:82
std::string highlightWarning(const std::string &sCommandLine)
Highlight a warning message. We simply use the color of numbers (which is orange as default).
Definition: syntax.cpp:653
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...
Definition: syntax.cpp:878
std::vector< std::string > vCppKeyWords
Definition: syntax.hpp:70
std::string getFunctions() const
Definition: syntax.hpp:121
std::vector< std::string > vNPRCCommands
Definition: syntax.hpp:58
std::map< std::string, int > mAutoCompListMATLAB
Definition: syntax.hpp:78
std::string getOptions() const
Definition: syntax.hpp:119
A simple structure to define a syntax block for folding, etc.
Definition: syntax.hpp:35
std::string middleWord2
Definition: syntax.hpp:39
std::string endWord
Definition: syntax.hpp:37
std::string middleWord1
Definition: syntax.hpp:38
std::string startWord
Definition: syntax.hpp:36