NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
parser_functions.cpp File Reference
#include "parser_functions.hpp"
#include "../../kernel.hpp"
Include dependency graph for parser_functions.cpp:

Go to the source code of this file.

Functions

size_t findVariableInExpression (const std::string &sExpr, const std::string &sVarName, size_t nPosStart)
 This function searches for the selected variable in the passed string and returns the position of the first occurence or string::npos, if nothing was found. More...
 
void convertVectorToExpression (string &sLine, const Settings &_option)
 This function replaces vector expressions with their corresponding multi- expression equation. More...
 
string addMissingVectorComponent (const string &sVectorComponent, const string &sLeft, const string &sRight, bool bAddStrings)
 This function determines the value of missing vector components (i.e. a vector contains not enough elements compared to the others used in the current expression) by applying a simple heuristic to the expression. It will either insert "1", "0" or an empty string in string expressions. More...
 
unsigned int getPositionOfFirstDelimiter (const string &sLine)
 This function returns the position of the first delimiter in the passed string, but it jumps over parentheses and braces. More...
 
string promptForUserInput (const string &__sCommand)
 This function is invoked, if a prompt operator ("??") was found in a string. More...
 
mu::value_typegetPointerToVariable (const string &sVarName, Parser &_parser)
 This function returns the pointer to the passed variable. More...
 
int integralFactorial (int nNumber)
 This function returns the factorial of the passed integral value. More...
 
string evaluateTargetOptionInCommand (string &sCmd, const string &sDefaultTarget, Indices &_idx, Parser &_parser, MemoryManager &_data, const Settings &_option)
 This function evaluates the "target=TABLE()" expression and creates the target table, if needed. More...
 
bool evaluateIndices (const string &sCache, Indices &_idx, MemoryManager &_data)
 This function will evaluate the passed indices, so that they match the dimensions of the passed cache, if they are defined as open ended. More...
 
static void readAndParseLegacyIntervals (string &sExpr, const string &sLegacyIntervalIdentifier, Parser &_parser, vector< double > &vInterval, size_t nMinSize, bool bEraseInterval)
 This static function handles a single legacy interval. It's a helper for readAndParseIntervals(). More...
 
vector< double > readAndParseIntervals (string &sExpr, Parser &_parser, MemoryManager &_data, FunctionDefinitionManager &_functions, const Settings &_option, bool bEraseInterval)
 This function will read the interval syntax in commands and return their values in a single vector. More...
 

Variables

mu::value_type vAns
 
mglGraph _fontData
 

Function Documentation

◆ addMissingVectorComponent()

string addMissingVectorComponent ( const string &  sVectorComponent,
const string &  sLeft,
const string &  sRight,
bool  bAddStrings 
)

This function determines the value of missing vector components (i.e. a vector contains not enough elements compared to the others used in the current expression) by applying a simple heuristic to the expression. It will either insert "1", "0" or an empty string in string expressions.

Parameters
sVectorComponentconst string&
sLeftconst string&
sRightconst string&
bAddStringsbool
Returns
string

Definition at line 300 of file parser_functions.cpp.

Referenced by convertVectorToExpression(), and evalMatOp().

◆ convertVectorToExpression()

void convertVectorToExpression ( string &  sLine,
const Settings _option 
)

This function replaces vector expressions with their corresponding multi- expression equation.

Parameters
sLinestring&
_optionconst Settings&
Returns
void

It is used quite extensively, however, it might not be necessary everywhere, because the parser can cope with the vector syntax now.

Definition at line 82 of file parser_functions.cpp.

References addMissingVectorComponent(), containsStrings(), convertVectorToExpression(), getMatchingParenthesis(), getNextArgument(), SyntaxError::INCOMPLETE_VECTOR_SYNTAX, SyntaxError::invalid_position, isMultiValue(), isToStringArg(), and parser_CheckMultArgFunc().

Referenced by NumeRe::StringFuncHandler::argumentParser(), convertVectorToExpression(), Plot::create2dDrawing(), Plot::create3dDrawing(), evalPoints(), evaluateFittingParams(), Plot::fillData(), CommandLineParser::getExprAsMathExpression(), NumeRe::StringParser::numToString(), and NumeRe::StringParser::storeStringResults().

Here is the call graph for this function:

◆ evaluateIndices()

bool evaluateIndices ( const string &  sCache,
Indices _idx,
MemoryManager _data 
)

This function will evaluate the passed indices, so that they match the dimensions of the passed cache, if they are defined as open ended.

Parameters
sCacheconst string&
_idxIndices&
_dataDatafile&
Returns
bool

Definition at line 625 of file parser_functions.cpp.

References Indices::col, MemoryManager::getCols(), MemoryManager::getLines(), VectorIndex::isOpenEnd(), isValidIndexSet(), Indices::row, and VectorIndex::setRange().

Referenced by evalMatOp(), and evaluateFittingParams().

Here is the call graph for this function:

◆ evaluateTargetOptionInCommand()

string evaluateTargetOptionInCommand ( string &  sCmd,
const string &  sDefaultTarget,
Indices _idx,
Parser _parser,
MemoryManager _data,
const Settings _option 
)

This function evaluates the "target=TABLE()" expression and creates the target table, if needed.

Parameters
sCmdstring&
sDefaultTargetconst string&
_idxIndices&
_parserParser&
_dataDatafile&
_optionconst Settings&
Returns
string

If this option is not found, the function will create a default target cache.

Definition at line 566 of file parser_functions.cpp.

References MemoryManager::addTable(), VectorIndex::back(), Indices::col, findParameter(), VectorIndex::front(), getArgAtPos(), MemoryManager::getCols(), getIndices(), SyntaxError::INVALID_INDEX, SyntaxError::invalid_position, MemoryManager::isTable(), isValidIndexSet(), VectorIndex::OPEN_END, Indices::row, and VectorIndex::to_string().

Referenced by CommandLineParser::getTargetTable(), plugin_histogram(), plugin_random(), and plugin_statistics().

Here is the call graph for this function:

◆ findVariableInExpression()

size_t findVariableInExpression ( const std::string &  sExpr,
const std::string &  sVarName,
size_t  nPosStart 
)

This function searches for the selected variable in the passed string and returns the position of the first occurence or string::npos, if nothing was found.

Parameters
sExprconst std::string&
sVarNameconst std::string&
nPosStartsize_t
Returns
size_t

Definition at line 42 of file parser_functions.cpp.

References isInQuotes().

Referenced by CodeAnalyzer::analysePreDefs(), Interval::contains(), Plot::createSubPlotSet(), findExtrema(), findZeroes(), SymDefManager::resolveSymbols(), and taylor().

Here is the call graph for this function:

◆ getPointerToVariable()

mu::value_type * getPointerToVariable ( const string &  sVarName,
Parser _parser 
)

This function returns the pointer to the passed variable.

Parameters
sVarNameconst string&
_parserParser&
Returns
double*

Definition at line 511 of file parser_functions.cpp.

References mu::ParserBase::GetVar().

Referenced by differentiate(), evalPoints(), findExtrema(), findZeroes(), FlowCtrl::prepareLocalVarsAndReplace(), NumeRe::StringParser::storeStringResults(), and taylor().

Here is the call graph for this function:

◆ getPositionOfFirstDelimiter()

unsigned int getPositionOfFirstDelimiter ( const string &  sLine)

This function returns the position of the first delimiter in the passed string, but it jumps over parentheses and braces.

Parameters
sLineconst string&
Returns
unsigned int

Definition at line 396 of file parser_functions.cpp.

References getMatchingParenthesis().

Referenced by NumeRe::StringParser::numToString().

Here is the call graph for this function:

◆ integralFactorial()

int integralFactorial ( int  nNumber)

This function returns the factorial of the passed integral value.

Parameters
nNumberint
Returns
int

Definition at line 535 of file parser_functions.cpp.

Referenced by taylor().

◆ promptForUserInput()

string promptForUserInput ( const string &  __sCommand)

This function is invoked, if a prompt operator ("??") was found in a string.

Parameters
__sCommandconst string&
Returns
string

It will ask the user to provide the needed value during the execution.

Definition at line 429 of file parser_functions.cpp.

References NumeReKernel::getline(), NumeReKernel::printPreFmt(), and StripSpaces().

Referenced by FlowCtrl::calc(), cmd_print(), FlowCtrl::compile(), Plot::createSubPlotSet(), CommandLineParser::getExprAsDataObject(), CommandLineParser::getExprAsMathExpression(), NumeReKernel::MainLoop(), CommandLineParser::parseExprAsString(), and Procedure::ProcCalc().

Here is the call graph for this function:

◆ readAndParseIntervals()

vector< double > readAndParseIntervals ( string &  sExpr,
Parser _parser,
MemoryManager _data,
FunctionDefinitionManager _functions,
const Settings _option,
bool  bEraseInterval 
)

This function will read the interval syntax in commands and return their values in a single vector.

Parameters
sExprstring&
_parserParser&
_dataDatafile&
_functionsDefine&
_optionconst Settings&
bEraseIntervalbool
Returns
vector<double>

Definition at line 706 of file parser_functions.cpp.

References FunctionDefinitionManager::call(), MemoryManager::containsTablesOrClusters(), mu::ParserBase::Eval(), findParameter(), SyntaxError::FUNCTION_ERROR, getAllArguments(), getAllIndices(), getDataElements(), getMatchingParenthesis(), SyntaxError::invalid_position, isInQuotes(), isNotEmptyExpression(), readAndParseLegacyIntervals(), and mu::ParserBase::SetExpr().

Referenced by evaluateFittingParams(), evaluateParameterValues(), and Odesolver::solve().

Here is the call graph for this function:

◆ readAndParseLegacyIntervals()

static void readAndParseLegacyIntervals ( string &  sExpr,
const string &  sLegacyIntervalIdentifier,
Parser _parser,
vector< double > &  vInterval,
size_t  nMinSize,
bool  bEraseInterval 
)
static

This static function handles a single legacy interval. It's a helper for readAndParseIntervals().

Parameters
sExprstring&
sLegacyIntervalIdentifierconst string&
_parserParser&6
vIntervalvector<double>&
nMinSizesize_t
bEraseIntervalbool
Returns
void

Definition at line 657 of file parser_functions.cpp.

References mu::ParserBase::Eval(), findParameter(), getAllIndices(), getArgAtPos(), isNotEmptyExpression(), and mu::ParserBase::SetExpr().

Referenced by readAndParseIntervals().

Here is the call graph for this function:

Variable Documentation

◆ _fontData

mglGraph _fontData
extern

Definition at line 40 of file kernel.cpp.

◆ vAns