11#include <framework/utilities/Utils.h>
87 [[noreturn]]
void raiseError(
const std::runtime_error& e);
153 throw std::runtime_error(
"empty string");
155 throw std::runtime_error(
"could not parse, stack size not 1, probably a bug, please report");
159 [](
double d) ->
VariableType {
return VariableConstructor()(d); }
161 }
catch (std::runtime_error& e) {
181 [op](
auto a,
auto b) ->
OutputToken {
return VariableConstructor()(op, a, b); },
190 [](
const std::string & s) ->
OutputToken {
return VariableConstructor()(s); },
EOperator checkForOperator(char next)
Check if the next character is a operator.
void flushPendingOperators()
Flush all pending operators at the end of processing.
void addOperator(EOperator op)
Add an operator to the internal state, convert them to reverse polish notation using the shunting yar...
void processString(const std::string &formula)
Process the given formula and store the final state.
static double applyOperator(EOperator op, double a, double b)
Apply operator on two values.
static void assertOperatorUsable(size_t stacksize)
Make sure we have enough operands to use an operator.
void raiseError(const std::runtime_error &e)
Format the given runtime_error with context information and rethrow a new one.
void flushCurrentVariable()
Flush the currently parsed variable name and add it to the state either as variable or number.
static char operatorToChar(EOperator op) noexcept
Convert operator code to character.
static ENumberStatus checkNumber(ENumberStatus current, char next)
Check if a string literal with a given number status continues to be a valid number if next is append...
Abstract base class for different kinds of events.
Helper struct for the C++17 std::visit overload pattern to allow simple use of variants.