Version: 6.3.1
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes

INTERP_KERNEL.ExprParser Class Reference

#include <InterpKernelExprParser.hxx>

Public Member Functions

 ExprParser (const char *expr, ExprParser *father=0)
 ExprParser (const char *expr, int lgth, ExprParser *father=0)
 For NOT null terminated strings coming from FORTRAN.
 ~ExprParser ()
void parse () throw (INTERP_KERNEL::Exception)
bool isParsingSuccessfull () const
double evaluate () const throw (INTERP_KERNEL::Exception)
DecompositionInUnitBase evaluateUnit () const throw (INTERP_KERNEL::Exception)
void prepareExprEvaluation (const std::vector< std::string > &vars) const throw (INTERP_KERNEL::Exception)
void evaluateExpr (int szOfOutParam, const double *inParam, double *outParam) const throw (INTERP_KERNEL::Exception)
void prepareExprEvaluationVec () const throw (INTERP_KERNEL::Exception)
void getSetOfVars (std::set< std::string > &vars) const
void getTrueSetOfVars (std::set< std::string > &vars) const
char * compileX86 () const
char * compileX86_64 () const
void compileX86LowLev (std::vector< std::string > &ass) const
void compileX86_64LowLev (std::vector< std::string > &ass) const
int getStackSizeToPlayX86 (const ExprParser *asker) const

Static Public Member Functions

static std::string buildStringFromFortran (const char *expr, int lgth)
static std::string deleteWhiteSpaces (const std::string &expr)

Private Member Functions

ValueevaluateLowLev (Value *valGen) const throw (INTERP_KERNEL::Exception)
void prepareExprEvaluationVecLowLev () const throw (INTERP_KERNEL::Exception)
bool tryToInterpALeaf () throw (INTERP_KERNEL::Exception)
void parseUnaryFunc () throw (INTERP_KERNEL::Exception)
void parseForCmp () throw (INTERP_KERNEL::Exception)
void parseForAddMin () throw (INTERP_KERNEL::Exception)
void parseForMulDiv () throw (INTERP_KERNEL::Exception)
void parseForPow () throw (INTERP_KERNEL::Exception)
void parseDeeper () throw (INTERP_KERNEL::Exception)
bool simplify () throw (INTERP_KERNEL::Exception)
void releaseFunctions ()
void checkBracketsParity () const throw (INTERP_KERNEL::Exception)
void fillValuesInExpr (std::vector< double > &valuesInExpr) throw (INTERP_KERNEL::Exception)
void replaceValues (const std::vector< double > &valuesInExpr) throw (INTERP_KERNEL::Exception)

Static Private Member Functions

static double ReplaceAndTraduce (std::string &expr, int id, std::size_t bg, std::size_t end, int &delta) throw (INTERP_KERNEL::Exception)
static std::size_t FindCorrespondingOpenBracket (const std::string &expr, std::size_t posOfCloseBracket)
static void LocateError (std::ostream &stringToDisp, const std::string &srcOfErr, int posOfErr)

Private Attributes

ExprParser_father
bool _is_parsed
LeafExpr_leaf
bool _is_parsing_ok
std::string _expr
std::list< ExprParser_sub_expr
std::list< Function * > _func_btw_sub_expr

Static Private Attributes

static const int MAX_X86_FP_ST = 8
static const char WHITE_SPACES [] = " \n"
static const char EXPR_PARSE_ERR_MSG [] = "Invalid expression detected : "

Constructor & Destructor Documentation

ExprParser::ExprParser ( const char *  expr,
ExprParser father = 0 
)
ExprParser::ExprParser ( const char *  expr,
int  lgth,
ExprParser father = 0 
)
ExprParser::~ExprParser ( )

Member Function Documentation

void ExprParser::parse ( ) throw (INTERP_KERNEL::Exception)
bool INTERP_KERNEL.ExprParser.isParsingSuccessfull ( ) const
double ExprParser::evaluate ( ) const throw (INTERP_KERNEL::Exception)
DecompositionInUnitBase ExprParser::evaluateUnit ( ) const throw (INTERP_KERNEL::Exception)
void ExprParser::prepareExprEvaluation ( const std::vector< std::string > &  vars) const throw (INTERP_KERNEL::Exception)
void ExprParser::evaluateExpr ( int  szOfOutParam,
const double inParam,
double outParam 
) const throw (INTERP_KERNEL::Exception)
void ExprParser::prepareExprEvaluationVec ( ) const throw (INTERP_KERNEL::Exception)
void ExprParser::getSetOfVars ( std::set< std::string > &  vars) const
void ExprParser::getTrueSetOfVars ( std::set< std::string > &  vars) const
char * ExprParser::compileX86 ( ) const
char * ExprParser::compileX86_64 ( ) const
void ExprParser::compileX86LowLev ( std::vector< std::string > &  ass) const
void ExprParser::compileX86_64LowLev ( std::vector< std::string > &  ass) const
int ExprParser::getStackSizeToPlayX86 ( const ExprParser asker) const
std::string ExprParser::buildStringFromFortran ( const char *  expr,
int  lgth 
) [static]
std::string ExprParser::deleteWhiteSpaces ( const std::string &  expr) [static]
Value * ExprParser::evaluateLowLev ( Value valGen) const throw (INTERP_KERNEL::Exception) [private]

References testMEDMEM.ret.

void ExprParser::prepareExprEvaluationVecLowLev ( ) const throw (INTERP_KERNEL::Exception) [private]
bool ExprParser::tryToInterpALeaf ( ) throw (INTERP_KERNEL::Exception) [private]

This method has the responsability to see if this->_expr is interpretable without any recursion.

Returns:
true if no recursion needed, false if this->_expr is too complex to be interpreted at this level.
Exceptions:
exceptionif this->_expr is simple enough to try to interprate this and this expression contains an error.

References INTERP_KERNEL.ExprParser._expr, INTERP_KERNEL.ExprParser._func_btw_sub_expr, INTERP_KERNEL.ExprParser._is_parsing_ok, INTERP_KERNEL.ExprParser._leaf, INTERP_KERNEL.LeafExpr.buildInstanceFrom(), and INTERP_KERNEL.FunctionsFactory.buildUnaryFuncFromString().

void ExprParser::parseUnaryFunc ( ) throw (INTERP_KERNEL::Exception) [private]

This method has the responsability to see if this->_expr can be seen as a unary function of something. Something defined as the contain of highest level barckets. Typically '(3*x+2)' and 'cos(4*l+p*n)' will be intercepted by this method whereas '3*x+2' not...etc..

References INTERP_KERNEL.ExprParser._expr, INTERP_KERNEL.ExprParser._func_btw_sub_expr, INTERP_KERNEL.ExprParser._is_parsing_ok, INTERP_KERNEL.ExprParser._sub_expr, INTERP_KERNEL.FunctionsFactory.buildFuncFromString(), INTERP_KERNEL.ExprParser.ExprParser(), and INTERP_KERNEL.ExprParser.FindCorrespondingOpenBracket().

void ExprParser::parseForCmp ( ) throw (INTERP_KERNEL::Exception) [private]
void ExprParser::parseForAddMin ( ) throw (INTERP_KERNEL::Exception) [private]
void ExprParser::parseForMulDiv ( ) throw (INTERP_KERNEL::Exception) [private]
void ExprParser::parseForPow ( ) throw (INTERP_KERNEL::Exception) [private]
void ExprParser::parseDeeper ( ) throw (INTERP_KERNEL::Exception) [private]
bool ExprParser::simplify ( ) throw (INTERP_KERNEL::Exception) [private]

This method parse this->_expr at the current level. This method first try to see if this->_expr is a leaf, if not it try a unary function of something (see INTERP_KERNEL.ExprParser.parseUnaryFunc method) If true is returned, no deeper parsing needed, if false is returned for a full parsing of this->_expr INTERP_KERNEL.ExprParser.parseDeeper call needed.

References INTERP_KERNEL.ExprParser._expr, INTERP_KERNEL.ExprParser._is_parsing_ok, INTERP_KERNEL.ExprParser.EXPR_PARSE_ERR_MSG, INTERP_KERNEL.ExprParser.LocateError(), INTERP_KERNEL.ExprParser.parseForAddMin(), INTERP_KERNEL.ExprParser.parseForCmp(), INTERP_KERNEL.ExprParser.parseForMulDiv(), INTERP_KERNEL.ExprParser.parseForPow(), INTERP_KERNEL.ExprParser.parseUnaryFunc(), and INTERP_KERNEL.ExprParser.tryToInterpALeaf().

void ExprParser::releaseFunctions ( ) [private]
void ExprParser::checkBracketsParity ( ) const throw (INTERP_KERNEL::Exception) [private]
void ExprParser::fillValuesInExpr ( std::vector< double > &  valuesInExpr) throw (INTERP_KERNEL::Exception) [private]

This method makes the assumption that _expr has no white space. This method scans _expr finding in greedy mode the following pattern : {0..9}+{.}?{0..9}*{{eE}{-}?{0..9}+}?

void ExprParser::replaceValues ( const std::vector< double > &  valuesInExpr) throw (INTERP_KERNEL::Exception) [private]
double ExprParser::ReplaceAndTraduce ( std::string &  expr,
int  id,
std::size_t  bg,
std::size_t  end,
int delta 
) throw (INTERP_KERNEL::Exception) [static, private]

This method substitutes part in [bg,end) in expr by the content of (str(id)) and returns the double value representation in expr[bg,end). If double representation is invalid an exception is thrown. This method returns a delta that is the delta to operate to pos in expr after substitution.

References med_test1.end, testRenumbering.id, MSG, and testMEDMEM.ret.

std::size_t ExprParser::FindCorrespondingOpenBracket ( const std::string &  expr,
std::size_t  posOfCloseBracket 
) [static, private]
void ExprParser::LocateError ( std::ostream &  stringToDisp,
const std::string &  srcOfErr,
int  posOfErr 
) [static, private]

Field Documentation

std::string INTERP_KERNEL.ExprParser._expr [private]
const int INTERP_KERNEL.ExprParser.MAX_X86_FP_ST = 8 [static, private]
const char ExprParser::WHITE_SPACES = " \n" [static, private]
const char ExprParser::EXPR_PARSE_ERR_MSG = "Invalid expression detected : " [static, private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS