OOFEM
2.4
OOFEM.org - Object Oriented Finite Element Solver
|
Class for evaluating mathematical expressions in strings. More...
#include <parser.h>
Classes | |
struct | name |
Public Member Functions | |
Parser () | |
~Parser () | |
double | eval (const char *string, int &err) |
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, HEAVISIDE_FUNC, PLUS ='+', MINUS ='-', MUL ='*', DIV ='/', POW ='^', BOOL_EQ, BOOL_LE, BOOL_LT, BOOL_GE, BOOL_GT, PRINT =';', ASSIGN ='=', LP ='(', RP =')' } |
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 () |
Private Attributes | |
int | no_of_errors |
Token_value | curr_tok |
name * | table [Parser_TBLSZ] |
double | number_value |
char | string_value [Parser_CMD_LENGTH] |
const char * | parsedLine |
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 57 of file parser.h.
References Parser_TBLSZ.
|
private |
Definition at line 203 of file parser.C.
References curr_tok, expr(), get_token(), LP, OOFEM_ERROR, and RP.
Referenced by prim().
|
private |
double oofem::Parser::eval | ( | const char * | string, |
int & | err | ||
) |
Definition at line 378 of file parser.C.
References curr_tok, END, expr(), no_of_errors, and parsedLine.
Referenced by oofem::UserDefinedTemperatureField::computeValueAt(), oofem::ScalarFunction::eval(), oofem::CalculatorFunction::evaluate(), oofem::CalculatorFunction::evaluateAccelerationAtTime(), oofem::CalculatorFunction::evaluateAtTime(), and oofem::CalculatorFunction::evaluateVelocityAtTime().
|
private |
|
private |
Definition at line 228 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, M_PI, NAME, NUMBER, number_value, OOFEM_ERROR, parsedLine, Parser_CMD_LENGTH, PRINT, SIN_FUNC, SQRT_FUNC, string_value, and TAN_FUNC.
|
inlineprivate |
|
private |
Definition at line 344 of file parser.C.
References oofem::Parser::name::next, OOFEM_ERROR, Parser_TBLSZ, oofem::Parser::name::string, table, and oofem::Parser::name::value.
Referenced by prim().
|
private |
Definition at line 109 of file parser.C.
References ACOS_FUNC, agr(), ASIN_FUNC, ASSIGN, ATAN_FUNC, COS_FUNC, curr_tok, EXP_FUNC, expr(), get_token(), HEAVISIDE_FUNC, insert(), look(), LP, MINUS, NAME, NUMBER, number_value, OOFEM_ERROR, RP, SIN_FUNC, SQRT_FUNC, string_value, TAN_FUNC, and oofem::Parser::name::value.
Referenced by term().
void oofem::Parser::reset | ( | ) |
Definition at line 391 of file parser.C.
References oofem::Parser::name::next, Parser_TBLSZ, oofem::Parser::name::string, and table.
|
private |
|
private |
|
private |
|
private |
Definition at line 87 of file parser.h.
Referenced by get_token(), and prim().
|
private |
Definition at line 89 of file parser.h.
Referenced by eval(), and get_token().
|
private |
Definition at line 88 of file parser.h.
Referenced by get_token(), and prim().
|
private |