BashSpark
Loading...
Searching...
No Matches
bs::math_parser Struct Reference

Structure to help class command_math parse it's parameters. More...

Classes

struct  depth_guard
 Manages depth of a math_parser instance during its lifetime. More...
 
struct  expvar
 Structure to hold variable information in sequence functions. More...
 

Public Member Functions

 math_parser (const std::span< const std::string > &vTokens) noexcept
 
std::int64_t do_toplevel (std::size_t &nPos, const expvar &nX)
 Evaluate a full expression (top-level entry point).
 
void increase_depth ()
 Increases the current recursion/evaluation depth. Ensures that the depth does not exceed MAX_DEPTH.
 
void decrease_depth ()
 Decreases the current recursion/evaluation depth. Will not decrement below zero.
 

Static Public Attributes

static constexpr std::size_t MAX_DEPTH = 512
 Maximum depth of the shell parser.
 
static std::map< std::string_view, math_operatorOPERATORS
 Map containing operator expressions and codes.
 

Detailed Description

Structure to help class command_math parse it's parameters.

Constructor & Destructor Documentation

◆ math_parser()

bs::math_parser::math_parser ( const std::span< const std::string > &  vTokens)
inlineexplicitnoexcept

Contstructs a math_parser

Parameters
vTokensTokens to parse

Member Function Documentation

◆ do_toplevel()

std::int64_t bs::math_parser::do_toplevel ( std::size_t &  nPos,
const expvar nX 
)

Evaluate a full expression (top-level entry point).

Parameters
nPosToken positon
nXVariable map
Returns
Operation result

◆ increase_depth()

void bs::math_parser::increase_depth ( )
inline

Increases the current recursion/evaluation depth. Ensures that the depth does not exceed MAX_DEPTH.

Exceptions
math_errorIf increasing the depth would exceed MAX_DEPTH.

Member Data Documentation

◆ OPERATORS

std::map< std::string_view, math_operator > bs::math_parser::OPERATORS
static
Initial value:
= {
{"\u00F7", math_operator::MO_DIV},
}
@ MO_ABS
Absolute value.
@ MO_MINUS
Subtraction.
@ MO_SUM
Summation.
@ MO_PRODUCT
Product.
@ MO_SIGN
Unary sign (+/-)
@ MO_OPEN_PARENTHESIS
'(' token
@ MO_FUNC_ARG_SEP
Function argument separator (e.g., comma)
@ MO_DIV
Division.
@ MO_PLUS
Addition.
@ MO_FACTORIAL
Factorial.
@ MO_MULT
Multiplication.
@ MO_CLOSE_PARENTHESIS
')' token

Map containing operator expressions and codes.


The documentation for this struct was generated from the following file: