Operators

Operator definitions, grouping, and built-in operations.

class OperatorAdd : public snt::exs::OperatorBase
#include <arithmetic.h>

Binary and unary addition operator.

Public Functions

OperatorAdd(std::string s = "+")

Construct an addition operator with the supplied symbol.

virtual void operate_unary(TokenListBase *tokens) override

Apply the unary operator to the token list.

Parameters:

tokens – Token list being processed.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorAnd : public snt::exs::OperatorBase
#include <logical.h>

Logical AND operator.

Public Functions

OperatorAnd(std::string s = "&&")

Construct a logical AND operator.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorBase
#include <operator_base.h>

Base interface for an EXS operator.

Subclassed by snt::exs::OperatorGroup< 1 >, snt::exs::OperatorGroup< 2 >, snt::exs::OperatorAdd, snt::exs::OperatorAnd, snt::exs::OperatorDivide, snt::exs::OperatorEqual, snt::exs::OperatorGreater, snt::exs::OperatorGreaterEqual, snt::exs::OperatorGroup< N >, snt::exs::OperatorLess, snt::exs::OperatorLessEqual, snt::exs::OperatorModulo, snt::exs::OperatorMultiply, snt::exs::OperatorNot, snt::exs::OperatorNotEqual, snt::exs::OperatorOr, snt::exs::OperatorPower, snt::exs::OperatorSubtract, snt::exs::OperatorTernary

Public Functions

inline OperatorBase(std::string n, std::string s, int t)

Create an operator with a name, symbol, and precedence.

Parameters:
  • n – Operator or object name.

  • s – Operator symbol or source string.

  • t – Operator type or precedence.

virtual ~OperatorBase() = default
virtual bool check(Expression &expr)

Check whether the expression supports this operator.

Parameters:

expr – Expression being parsed.

virtual void parse(Expression &expr)

Parse the supplied expression.

Parameters:

expr – Expression being parsed.

virtual void operate_unary(TokenListBase *tokens)

Apply the unary operator to the token list.

Parameters:

tokens – Token list being processed.

virtual void operate_binary(TokenListBase *tokens)

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

virtual void operate_ternary(TokenListBase *tokens)

Apply the ternary operator to the token list.

Parameters:

tokens – Token list being processed.

virtual void operate_group(TokenListBase *tokens)

Apply the grouped operator to the token list.

Parameters:

tokens – Token list being processed.

virtual void operate_unary(TokenListBase *tokens, BaseSettings *settings)

Apply the unary operator to the token list.

Parameters:
  • tokens – Token list being processed.

  • settings – Operator or parser settings.

virtual void operate_binary(TokenListBase *tokens, BaseSettings *settings)

Apply the binary operator to the token list.

Parameters:
  • tokens – Token list being processed.

  • settings – Operator or parser settings.

virtual void operate_ternary(TokenListBase *tokens, BaseSettings *settings)

Apply the ternary operator to the token list.

Parameters:
  • tokens – Token list being processed.

  • settings – Operator or parser settings.

virtual void operate_group(TokenListBase *tokens, BaseSettings *settings)

Apply the grouped operator to the token list.

Parameters:
  • tokens – Token list being processed.

  • settings – Operator or parser settings.

inline virtual void print()

Public Members

std::string name
std::string symbol
int type
std::vector<std::string> groups
class OperatorCondition : public snt::exs::OperatorTernary
#include <control.h>

Ternary conditional operator.

Public Functions

OperatorCondition()

Construct a conditional operator.

virtual void operate_ternary(TokenListBase *tokens) override

Apply the ternary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorCosinus : public snt::exs::OperatorGroup<1>
#include <trigonometry.h>

Cosine function operator.

Public Functions

OperatorCosinus(const OperatorGroupSybols &s = {"cos", "(", ")", ","})
virtual void operate_group(TokenListBase *tokens) override
class OperatorCubicRoot : public snt::exs::OperatorGroup<1>
#include <exponential.h>

Cube-root function operator.

Public Functions

OperatorCubicRoot(const OperatorGroupSybols &s = {"cbrt", "(", ")", ","})
virtual void operate_group(TokenListBase *tokens) override
class OperatorDivide : public snt::exs::OperatorBase
#include <arithmetic.h>

Division operator.

Public Functions

OperatorDivide(std::string s = "/")

Construct a division operator with the supplied symbol.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorEqual : public snt::exs::OperatorBase
#include <comparison.h>

Equality comparison operator.

Public Functions

OperatorEqual(std::string s = "==")

Construct an equality operator.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorExponent : public snt::exs::OperatorGroup<1>
#include <exponential.h>

Exponential function operator.

Public Functions

OperatorExponent(const OperatorGroupSybols &s = {"exp", "(", ")", ","})
virtual void operate_group(TokenListBase *tokens) override
class OperatorGreater : public snt::exs::OperatorBase
#include <comparison.h>

Greater-than comparison operator.

Public Functions

OperatorGreater(std::string s = ">")

Construct a greater-than operator.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorGreaterEqual : public snt::exs::OperatorBase
#include <comparison.h>

Greater-than-or-equal comparison operator.

Public Functions

OperatorGreaterEqual(std::string s = ">=")

Construct a greater-than-or-equal operator.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

template<int N = 0>
class OperatorGroup : public snt::exs::OperatorBase
#include <operator_group.h>

Group operator class

Template Parameters:

N – Number of group members. Zero means unlimited number

Public Functions

inline OperatorGroup(const std::string &n, const OperatorGroupSybols &s, const int t)

Create an operator for grouped function arguments.

Parameters:
  • n – Operator or object name.

  • s – Delimiters and separator used for grouped arguments.

  • t – Operator precedence/type identifier.

inline virtual void parse(Expression &expr) override

Parse the supplied expression.

Parameters:

expr – Expression being parsed.

inline virtual void operate_group(TokenListBase *tokens) override

Apply the grouped operator to the token list.

Parameters:

tokens – Token list being processed.

inline virtual void operate_group(TokenListBase *tokens, BaseSettings *settings) override

Apply the grouped operator to the token list.

Parameters:
  • tokens – Token list being processed.

  • settings – Operator or parser settings.

Public Members

size_t num_groups
OperatorGroupSybols symbols
struct OperatorGroupSybols
#include <operator_group.h>

Public Members

std::string prefix
std::string open
std::string close
std::string separator
class OperatorLess : public snt::exs::OperatorBase
#include <comparison.h>

Less-than comparison operator.

Public Functions

OperatorLess(std::string s = "<")

Construct a less-than operator.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorLessEqual : public snt::exs::OperatorBase
#include <comparison.h>

Less-than-or-equal comparison operator.

Public Functions

OperatorLessEqual(std::string s = "<=")

Construct a less-than-or-equal operator.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorList
#include <operator_list.h>

Registry of operators used by an EXS solver.

Public Functions

OperatorBase *select(int otype)

Select an operator implementation by type.

Parameters:

otype – Operator category to select.

void append(int t, std::shared_ptr<OperatorBase> o)

Append an item to the collection.

Parameters:
  • t – Operator type identifier used as the registry key.

  • o – Operator implementation to register; ownership is shared.

Public Members

OperatorListType operators
std::vector<int> order
class OperatorLogarithm : public snt::exs::OperatorGroup<1>
#include <exponential.h>

Natural logarithm operator.

Public Functions

OperatorLogarithm(const OperatorGroupSybols &s = {"log", "(", ")", ","})
virtual void operate_group(TokenListBase *tokens) override
class OperatorLogarithm10 : public snt::exs::OperatorGroup<1>
#include <exponential.h>

Base-ten logarithm operator.

Public Functions

OperatorLogarithm10(const OperatorGroupSybols &s = {"log10", "(", ")", ","})
virtual void operate_group(TokenListBase *tokens) override
class OperatorLogarithmBase : public snt::exs::OperatorGroup<2>
#include <exponential.h>

Arbitrary-base logarithm operator.

Public Functions

OperatorLogarithmBase(const OperatorGroupSybols &s = {"logb", "(", ")", ","})
virtual void operate_group(TokenListBase *tokens) override
class OperatorModulo : public snt::exs::OperatorBase
#include <arithmetic.h>

Remainder operator.

Public Functions

OperatorModulo(std::string s = "%")

Construct a remainder operator with the supplied symbol.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorMultiply : public snt::exs::OperatorBase
#include <arithmetic.h>

Multiplication operator.

Public Functions

OperatorMultiply(std::string s = "*")

Construct a multiplication operator with the supplied symbol.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorNot : public snt::exs::OperatorBase
#include <logical.h>

Logical NOT operator.

Public Functions

OperatorNot(std::string s = "!")

Construct a logical NOT operator.

virtual void operate_unary(TokenListBase *tokens) override

Apply the unary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorNotEqual : public snt::exs::OperatorBase
#include <comparison.h>

Inequality comparison operator.

Public Functions

OperatorNotEqual(std::string s = "!=")

Construct an inequality operator.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorOr : public snt::exs::OperatorBase
#include <logical.h>

Logical OR operator.

Public Functions

OperatorOr(std::string s = "||")

Construct a logical OR operator.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorParentheses : public snt::exs::OperatorGroup<1>
#include <control.h>

Parenthesized expression grouping operator.

Public Functions

OperatorParentheses(const OperatorGroupSybols &s = {"", "(", ")", ","})

Construct a parenthesis grouping operator.

class OperatorPower : public snt::exs::OperatorBase
#include <exponential.h>

Binary power operator.

Public Functions

OperatorPower(std::string s = "**")
virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorPowerBase : public snt::exs::OperatorGroup<2>
#include <exponential.h>

Arbitrary-base power function operator.

Public Functions

OperatorPowerBase(const OperatorGroupSybols &s = {"powb", "(", ")", ","})
virtual void operate_group(TokenListBase *tokens) override
class OperatorSinus : public snt::exs::OperatorGroup<1>
#include <trigonometry.h>

Sine function operator.

Public Functions

OperatorSinus(const OperatorGroupSybols &s = {"sin", "(", ")", ","})
virtual void operate_group(TokenListBase *tokens) override
class OperatorSquareRoot : public snt::exs::OperatorGroup<1>
#include <exponential.h>

Square-root function operator.

Public Functions

OperatorSquareRoot(const OperatorGroupSybols &s = {"sqrt", "(", ")", ","})
virtual void operate_group(TokenListBase *tokens) override
class OperatorSubtract : public snt::exs::OperatorBase
#include <arithmetic.h>

Binary and unary subtraction operator.

Public Functions

OperatorSubtract(std::string s = "-")

Construct a subtraction operator with the supplied symbol.

virtual void operate_unary(TokenListBase *tokens) override

Apply the unary operator to the token list.

Parameters:

tokens – Token list being processed.

virtual void operate_binary(TokenListBase *tokens) override

Apply the binary operator to the token list.

Parameters:

tokens – Token list being processed.

class OperatorTangens : public snt::exs::OperatorGroup<1>
#include <trigonometry.h>

Tangent function operator.

Public Functions

OperatorTangens(const OperatorGroupSybols &s = {"tan", "(", ")", ","})
virtual void operate_group(TokenListBase *tokens) override
class OperatorTernary : public snt::exs::OperatorBase
#include <operator_ternary.h>

EXS operator with three input branches, such as a conditional.

Subclassed by snt::exs::OperatorCondition

Public Functions

inline OperatorTernary(std::string n, std::string s, std::string so, int t)

Create a ternary operator.

Parameters:
  • n – Operator or object name.

  • s – Operator symbol or source string.

  • so – Secondary operator symbol.

  • t – Operator type or precedence.

virtual void parse(Expression &expr) override

Parse the supplied expression.

Parameters:

expr – Expression being parsed.

Public Members

std::string symbol_other