|
OOFEM 3.0
|
#include <parser.h>
Classes | |
| struct | name |
Public Member Functions | |
| Parser () | |
| ~Parser () | |
| double | eval (const char *string, int &err) |
| void | eval (const char *string, FloatArray &answer, const char *name, int &err) |
| void | setVariableValue (const char *name, int indx, double value) |
| void | reset () |
Private Types | |
| enum | Token_value { NAME , NUMBER , END , SQRT_FUNC , SIN_FUNC , COS_FUNC , TAN_FUNC , ATAN_FUNC , ASIN_FUNC , ACOS_FUNC , EXP_FUNC , INT_FUNC , HEAVISIDE_FUNC , HEAVISIDE_FUNC1 , PLUS ='+' , MINUS ='-' , MUL ='*' , DIV ='/' , MOD ='' , POW ='^' , BOOL_EQ , BOOL_LE , BOOL_LT , BOOL_GE , BOOL_GT , PRINT =';' , ASSIGN ='=' , LP ='(' , RP =')' , LB ='[' , RB =']' } |
Private Member Functions | |
| name * | look (const char *p, int ins=0) |
| name * | insert (const char *s) |
| void | error (const char *s) |
| double | expr (bool get) |
| double | term (bool get) |
| double | prim (bool get) |
| double | agr (bool get) |
| Token_value | get_token () |
| double | getVariableValue (const char *name, int indx) |
Private Attributes | |
| int | no_of_errors |
| Token_value | curr_tok |
| name * | table [Parser_TBLSZ] |
| double | number_value =0.0 |
| char | string_value [Parser_CMD_LENGTH] ="" |
| const char * | parsedLine = nullptr |
Class for evaluating mathematical expressions in strings. Strings should be in MATLAB syntax. The parser understands variable names with values set by "x=expression;" The following binary operators are recognized: < > == + - * / and the following functions: sqrt, sin, cos, tan, atan, asin, acos, exp, as well as parentheses ( )
Example string: x=3;y=7;sqrt(x*(x/y+3))
|
private |
|
inline |
Definition at line 58 of file parser.h.
References curr_tok, no_of_errors, Parser_TBLSZ, PRINT, and table.
|
private |
Definition at line 238 of file parser.C.
References curr_tok, expr(), get_token(), LP, OOFEM_ERROR, and RP.
|
private |
References agr(), expr(), get_token(), getVariableValue(), prim(), and term().
| void oofem::Parser::eval | ( | const char * | string, |
| FloatArray & | answer, | ||
| const char * | name, | ||
| int & | err ) |
Definition at line 433 of file parser.C.
References oofem::Parser::name::arrayValue, oofem::FloatArray::at(), curr_tok, oofem::Parser::name::doubleValue, END, expr(), look(), no_of_errors, parsedLine, oofem::FloatArray::resize(), and oofem::Parser::name::size.
| double oofem::Parser::eval | ( | const char * | string, |
| int & | err ) |
Definition at line 419 of file parser.C.
References curr_tok, END, expr(), no_of_errors, and parsedLine.
Referenced by oofem::ScalarFunction::eval(), oofem::CalculatorFunction::evaluate(), oofem::CalculatorFunction::evaluateAccelerationAtTime(), oofem::ExpressionField::evaluateAt(), oofem::CalculatorFunction::evaluateAtTime(), and oofem::CalculatorFunction::evaluateVelocityAtTime().
|
private |
|
private |
Definition at line 261 of file parser.C.
References ACOS_FUNC, ASIN_FUNC, ASSIGN, ATAN_FUNC, BOOL_EQ, BOOL_GE, BOOL_GT, BOOL_LE, BOOL_LT, COS_FUNC, curr_tok, END, EXP_FUNC, HEAVISIDE_FUNC, HEAVISIDE_FUNC1, INT_FUNC, M_PI, NAME, NUMBER, number_value, OOFEM_ERROR, parsedLine, Parser_CMD_LENGTH, PRINT, SIN_FUNC, SQRT_FUNC, string_value, and TAN_FUNC.
|
private |
Definition at line 494 of file parser.C.
References oofem::Parser::name::arrayValue, oofem::FloatArray::at(), oofem::Parser::name::doubleValue, look(), OOFEM_ERROR, and oofem::Parser::name::size.
|
inlineprivate |
|
private |
Definition at line 383 of file parser.C.
References oofem::Parser::name::arrayValue, oofem::FloatArray::clear(), oofem::Parser::name::doubleValue, oofem::Parser::name::next, OOFEM_ERROR, Parser_TBLSZ, oofem::Parser::name::size, oofem::Parser::name::string, and table.
Referenced by eval(), getVariableValue(), insert(), prim(), and setVariableValue().
|
private |
Definition at line 113 of file parser.C.
References ACOS_FUNC, agr(), ASIN_FUNC, ASSIGN, ATAN_FUNC, COS_FUNC, curr_tok, EXP_FUNC, expr(), get_token(), getVariableValue(), HEAVISIDE_FUNC, HEAVISIDE_FUNC1, INT_FUNC, LB, look(), LP, MINUS, NAME, NUMBER, number_value, OOFEM_ERROR, prim(), RB, RP, setVariableValue(), SIN_FUNC, SQRT_FUNC, string_value, and TAN_FUNC.
| void oofem::Parser::reset | ( | ) |
Definition at line 453 of file parser.C.
References oofem::Parser::name::next, Parser_TBLSZ, oofem::Parser::name::string, and table.
Referenced by ~Parser().
| void oofem::Parser::setVariableValue | ( | const char * | name, |
| int | indx, | ||
| double | value ) |
Definition at line 470 of file parser.C.
References oofem::Parser::name::arrayValue, oofem::FloatArray::at(), oofem::Parser::name::doubleValue, look(), OOFEM_ERROR, oofem::FloatArray::resize(), and oofem::Parser::name::size.
Referenced by oofem::ExpressionField::evaluateAt(), and prim().
|
private |
|
private |
|
private |
|
private |
Definition at line 95 of file parser.h.
Referenced by get_token(), and prim().
|
private |
Definition at line 97 of file parser.h.
Referenced by eval(), eval(), and get_token().
|
private |
Definition at line 96 of file parser.h.
Referenced by get_token(), and prim().
|
private |