20#include "../utils/tools.hpp"
21#include "../symdef.hpp"
39 std::string sProcCommandLine;
40 std::string sCurrentCommand;
41 std::string sCurrentLineCache;
42 std::string sProcPlotCompose;
45 std::unique_ptr<Includer> _includer;
48 int includeOffset = 0;
53 if (_includer && _includer->is_open())
56 currentLine = -includeOffset;
57 sProcCommandLine = _includer->getNextLine();
73 if (!sProcCommandLine.length())
78 _includer.reset(
new Includer(sProcCommandLine, sFolderPath));
84 if (sProcCommandLine.length() > 2)
86 if (sProcCommandLine.substr(sProcCommandLine.length() - 2, 2) ==
"\\\\")
90 sCurrentLineCache += sProcCommandLine.substr(0, sProcCommandLine.length() - 2);
97 if (sCurrentLineCache.length())
99 sProcCommandLine = sCurrentLineCache + sProcCommandLine;
100 sCurrentLineCache.clear();
109 _symdefs.
createSymbol(sProcCommandLine.substr(sCurrentCommand.length()));
122 if ((sCurrentCommand ==
"compose"
123 || sCurrentCommand ==
"endcompose"
124 || sProcPlotCompose.length())
125 && sCurrentCommand !=
"quit")
127 if (!sProcPlotCompose.length() && sCurrentCommand ==
"compose")
130 sProcPlotCompose =
"plotcompose ";
134 sProcPlotCompose +=
"-multiplot=" +
getArgAtPos(sProcCommandLine,
findParameter(sProcCommandLine,
"multiplot",
'=') + 9) +
" <<COMPOSE>> ";
139 else if (sCurrentCommand ==
"abort")
142 sProcPlotCompose.clear();
145 else if (sCurrentCommand !=
"endcompose")
150 if (sCommand.substr(0, 4) ==
"plot"
151 || sCommand.substr(0, 7) ==
"subplot"
152 || sCommand.substr(0, 5) ==
"graph"
153 || sCommand.substr(0, 4) ==
"grad"
154 || sCommand.substr(0, 4) ==
"draw"
155 || sCommand.substr(0, 4) ==
"dens"
156 || sCommand.substr(0, 4) ==
"vect"
157 || sCommand.substr(0, 4) ==
"cont"
158 || sCommand.substr(0, 4) ==
"surf"
159 || sCommand.substr(0, 4) ==
"mesh")
160 sProcPlotCompose += sProcCommandLine +
" <<COMPOSE>> ";
168 sProcCommandLine = sProcPlotCompose;
169 sProcPlotCompose.clear();
174 if (sCurrentCommand ==
"install"
175 || sCurrentCommand ==
"script")
177 "@ " +
toString(
abs(currentLine)+1) +
": " + sProcCommandLine, sCurrentCommand);
180 if (sProcCommandLine.find(
'(') != std::string::npos || sProcCommandLine.find(
'{') != std::string::npos)
184 sProcCommandLine.insert(0,
"@ " +
toString(
abs(currentLine)+1) +
": ");
186 for (
size_t j = 0; j < sProcCommandLine.length(); j++)
188 if ((sProcCommandLine[j] ==
'(' || sProcCommandLine[j] ==
'{' || sProcCommandLine[j] ==
'[')
198 if (sCurrentCommand ==
"procedure")
201 std::string sArgumentList;
204 if (sProcCommandLine.rfind(
"::") != std::string::npos)
206 std::string sFlags = sProcCommandLine.substr(sProcCommandLine.rfind(
"::"));
208 if (sFlags.find(
"private") != std::string::npos)
211 if (sFlags.find(
"explicit") != std::string::npos)
214 if (sFlags.find(
"inline") != std::string::npos)
217 if (sFlags.find(
"mask") != std::string::npos || sFlags.find(
"silent") != std::string::npos)
220 if (sFlags.find(
"event") != std::string::npos)
223 if (sFlags.find(
"template") != std::string::npos)
226 if (sFlags.find(
"macro") != std::string::npos)
229 if (sFlags.find(
"test") != std::string::npos)
234 if (sProcCommandLine.find(
'$') != std::string::npos
235 && sProcCommandLine.find(
'(', sProcCommandLine.find(
'$')) != std::string::npos)
237 std::string sProcName = sProcCommandLine.substr(sProcCommandLine.find(
'$'));
238 sProcName.erase(sProcName.find(
'('));
244 if (
findCommand(sArgumentList,
"var").sString ==
"var")
246 "@" +
toString(
abs(currentLine)+1) +
": " + sProcCommandLine,
"var",
"var");
248 if (
findCommand(sArgumentList,
"str").sString ==
"str")
250 "@" +
toString(
abs(currentLine)+1) +
": " + sProcCommandLine,
"str",
"str");
252 if (
findCommand(sArgumentList,
"tab").sString ==
"tab")
254 "@" +
toString(
abs(currentLine)+1) +
": " + sProcCommandLine,
"tab",
"tab");
256 if (
findCommand(sArgumentList,
"cst").sString ==
"cst")
258 "@" +
toString(
abs(currentLine)+1) +
": " + sProcCommandLine,
"cst",
"cst");
260 sArgumentList = sProcCommandLine.substr(sProcCommandLine.find(
'(')+1);
261 sArgumentList =
" " + sArgumentList.erase(sArgumentList.rfind(
')')) +
" ";
273 else if (sCurrentCommand ==
"endprocedure")
312 while (sProcCommandLine.find(
"<this>") != std::string::npos)
313 sProcCommandLine.replace(sProcCommandLine.find(
"<this>"), 6, sFolderPath);
316 if (sCurrentCommand ==
"global")
318 sProcCommandLine = sProcCommandLine.substr(
findCommand(sProcCommandLine).nPos + 6);
323 for (
size_t i = 0; i < sProcCommandLine.length(); i++)
325 if (sProcCommandLine[i] ==
'\t')
326 sProcCommandLine[i] =
' ';
330 if (sCurrentCommand !=
"define"
331 && sCurrentCommand !=
"ifndefined"
332 && sCurrentCommand !=
"redefine"
333 && sCurrentCommand !=
"ifndef"
334 && sCurrentCommand !=
"redef"
335 && sCurrentCommand !=
"lclfunc")
337 while (sProcCommandLine.find(
":=") != std::string::npos)
338 sProcCommandLine.erase(sProcCommandLine.find(
":="), 1);
371 std::pair<int, ProcedureCommandLine> currentLine;
399 std::pair<int, ProcedureCommandLine> currentLine;
This class handles the dependencies of the current procedure file (passed as pointer to a ProcedureEl...
This class represents a file, which can be included into other files using the @ syntax.
static bool is_including_syntax(const std::string &sLine)
Static member function which determines, whether the passed line is actually a including syntax.
Dependencies * m_dependencies
ProcedureElement(const StyledTextFile &procedureContents, const std::string &sFolderPath)
Procedure element constructor. This class is always heap allocated.
~ProcedureElement()
Destructor. Cleares the dependency list.
std::pair< int, ProcedureCommandLine > getCurrentLine(int currentLine)
This function returns the selected line of the stored file. This member function will be used in comb...
std::map< std::string, int > mProcedureList
void cleanCurrentLine(std::string &sProcCommandLine, const std::string &sCurrentCommand, const std::string &sFilePath)
This member function does the hard work on cleaning the current procedure command line....
bool isLastLine(int currentline)
This member function determines, whether the current line is the last line of the stored procedure fi...
void setByteCode(int _nByteCode, int nCurrentLine)
This member function can be used to store the created byte code in the current procedure command line...
Dependencies * getDependencies()
This member function returns the first-level dependencies of the current procedure file....
int gotoProcedure(const std::string &sProcedureName)
This member function returns the line of the stored file, where the desired procedure may be found or...
std::pair< int, ProcedureCommandLine > getFirstLine()
This function returns the first line of the stored file.
std::pair< int, ProcedureCommandLine > getNextLine(int currentline)
This member function returns the line after the current selected line. This is probably not the same ...
std::vector< std::pair< int, ProcedureCommandLine > > mProcedureContents
This class represents a text file in memory (e.g. a code file). This class will try to lex the loaded...
std::string getStrippedLine(size_t line) const
Returns the selected line (without the line termination characters and without any comments).
int getLinesCount() const
Returns the number of lines in the current loaded file.
This class handles the file-static constants, which are more or less macros similar to #define in C/C...
void resolveSymbols(std::string &sCommandLine) const
Resolve all file-static constant declarations in the current line.
void createSymbol(const std::string &sCommandLine)
Create one or more new file-static constant declarations for the current file.
Common exception class for all exceptions thrown in NumeRe.
unsigned int getMatchingParenthesis(const StringView &)
Returns the position of the closing parenthesis.
CONSTCD11 std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
int findParameter(const std::string &sCmd, const std::string &sParam, const char cFollowing)
This function searches the passed parameter in the passed command string. If something is found,...
std::string toString(int)
Converts an integer to a string without the Settings bloat.