52 #ifndef O2SCL_SHUNTING_YARD_H 53 #define O2SCL_SHUNTING_YARD_H 124 static std::map<std::string, int> buildOpPrecedence();
128 static bool isvariablechar(
char c);
135 static double calculate(
const char* expr,
136 std::map<std::string, double>* vars = 0,
144 static double calculate(TokenQueue_t RPN,
145 std::map<std::string, double>* vars = 0);
152 static void cleanRPN(TokenQueue_t& rpn);
156 static TokenQueue_t toRPN(
const char* expr,
157 std::map<std::string, double>* vars,
159 std::map<std::string, int> opPrec=opPrecedence);
179 std::map<std::string, double> *vars=0,
181 std::map<std::string, int> opPrec=opPrecedence);
186 void compile(
const char* expr,
187 std::map<std::string, double> *vars=0,
189 std::map<std::string, int> opPrec=opPrecedence);
194 double eval(std::map<std::string, double> *vars=0);
200 std::string RPN_to_string();
tokType
Token list for o2scl::calculator.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
Token(T t, tokType typex)
Create a token of type type with value t.
Token class for o2scl::calculator.
T val
The actual value stored.
Token base data type for o2scl::calculator.
tokType type
The token type.
static std::map< std::string, int > opPrecedence
A map denoting operator precedence.
TokenQueue_t RPN
The current expression in RPN.
Evaluate a mathematical expression in a string.
std::queue< TokenBase * > TokenQueue_t
A typedef for a queue of tokens for o2scl::calculator.
calculator()
Create an empty calculator object.