Go to the documentation of this file.
52 #ifndef O2SCL_SHUNTING_YARD_H
53 #define O2SCL_SHUNTING_YARD_H
140 static double calculate(
const char* expr,
141 std::map<std::string, double>* vars = 0,
148 std::map<std::string, double>* vars,
149 bool debug,
double &result);
157 std::map<std::string, double>* vars = 0);
164 std::map<std::string, double>* vars,
177 std::map<std::string, double>* vars,
185 std::map<std::string, double>* vars,
187 std::map<std::string, int> opPrec,
208 std::map<std::string, double> *vars=0,
217 std::map<std::string, double> *vars=0,
226 std::map<std::string, double> *vars=0,
233 double eval(std::map<std::string, double> *vars=0);
238 int eval_nothrow(std::map<std::string, double> *vars,
double &result);
std::string RPN_to_string()
Convert the RPN expression to a string.
calculator()
Create an empty calculator object.
int compile_nothrow(const char *expr, std::map< std::string, double > *vars=0, bool debug=false, std::map< std::string, int > opPrec=opPrecedence)
Compile expression expr using variables specified in vars and return an integer to indicate success o...
int eval_nothrow(std::map< std::string, double > *vars, double &result)
Evalate the previously compiled expression using variables specified in vars.
TokenQueue_t RPN
The current expression in RPN.
T val
The actual value stored.
static bool isvariablechar(char c)
Return true if is a variable.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
static int toRPN_nothrow(const char *expr, std::map< std::string, double > *vars, bool debug, std::map< std::string, int > opPrec, TokenQueue_t &queue2)
Convert the expression in expr to RPN and return an integer to indicate success or failure.
static void cleanRPN(TokenQueue_t &rpn)
Empty and free memory associated with rpn.
static std::map< std::string, int > opPrecedence
A map denoting operator precedence.
Token class for o2scl::calculator.
static double calculate(const char *expr, std::map< std::string, double > *vars=0, bool debug=false)
Compile and evaluate expr using definitions in vars.
Token(T t, tokType typex)
Create a token of type type with value t.
void compile(const char *expr, std::map< std::string, double > *vars=0, bool debug=false, std::map< std::string, int > opPrec=opPrecedence)
Compile expression expr using variables specified in vars and return an integer to indicate success o...
Evaluate a mathematical expression in a string.
std::queue< TokenBase * > TokenQueue_t
A typedef for a queue of tokens for o2scl::calculator.
tokType
Token list for o2scl::calculator.
static TokenQueue_t toRPN(const char *expr, std::map< std::string, double > *vars, bool debug=false, std::map< std::string, int > opPrec=opPrecedence)
Convert the expression in expr to RPN.
static std::map< std::string, int > buildOpPrecedence()
Build the operator precedence map.
double eval(std::map< std::string, double > *vars=0)
Evalate the previously compiled expression using variables specified in vars.
Token base data type for o2scl::calculator.
tokType type
The token type.
static int calculate_nothrow(const char *expr, std::map< std::string, double > *vars, bool debug, double &result)
Compile and evaluate expr using definitions in vars and return an integer to indicate success or fail...
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).