52 #ifndef O2SCL_SHUNTING_YARD_H 53 #define O2SCL_SHUNTING_YARD_H 117 static std::map<std::string, int> buildOpPrecedence();
121 static bool isvariablechar(
char c);
128 static double calculate(
const char* expr,
129 std::map<std::string, double>* vars = 0,
137 static double calculate(TokenQueue_t RPN,
138 std::map<std::string, double>* vars = 0);
145 static void cleanRPN(TokenQueue_t& rpn);
149 static TokenQueue_t toRPN(
const char* expr,
150 std::map<std::string, double>* vars,
152 std::map<std::string, int> opPrec=opPrecedence);
172 std::map<std::string, double> *vars=0,
174 std::map<std::string, int> opPrec=opPrecedence);
179 void compile(
const char* expr,
180 std::map<std::string, double> *vars=0,
182 std::map<std::string, int> opPrec=opPrecedence);
187 double eval(std::map<std::string, double> *vars=0);
193 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 class for o2scl::calculator.
T val
The actual value stored.
Token(T t, tokType type)
Create a token of type type with value t.
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.