BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Public Member Functions | Protected Member Functions
BeeeOn::SimpleCalc Class Reference

#include <SimpleCalc.h>

Public Member Functions

double evaluate (const std::string &input) const
 

Protected Member Functions

double parseTerm (std::string::const_iterator &at, std::string::const_iterator end) const
 
char parseOpOrEOF (std::string::const_iterator &at, std::string::const_iterator end) const
 
void skipWhitespace (std::string::const_iterator &at, std::string::const_iterator end) const
 
void apply (double &result, char op, double tmp) const
 
bool isWhitespace (const char c) const
 
bool isOperator (const char c) const
 
bool isTerm (const char c) const
 

Detailed Description

Very simple evaluator of math expressions. It performs operations with left-associativity. Thus, there is no operator precedence applicated. Examples:

y = 2 + 5 * 1 - 3 / 2 * 5 -> 7 * 1 - 3 / 2 * 5 -> 7 - 3 / 2 * 5 -> 4 / 2 * 5 -> 2 * 5 -> 10


The documentation for this class was generated from the following files: