SofaDoc

SofaDoc Map Usage

inc/expression.php

Contains the swExpression class to evaluate expressions, the swExpressionError class and functions to convert numbers to text
File also popluates the global $swExpressionFunctions array (only once for performance)

Classes

swExpression

Provides a class evaluate algebraic expressions
Expressions are tokenized, then compiled to an RPN array.
Compiled expressions can be evaluated provided a value dictionary.
The expression class also initates the native functions in $swExpressionFunctions using swFunctions
This is done late because configuration.php can add functions.
$source
$tokens() numbers 0..9, strings $hex, functions @(id, operators, names, (, ), ","
$rpn()
$stack() value stack during exections
$expectedreturn number of results an expression is expected to return (can be more than 1)

Methods

__construct()
tokenize($s)
compile($s)
evaluate($values=()
unitTest()

Properties

$source
$tokens
$rpn
$stack
$expectedreturn
$globals

swExpressionError extends

Stub class

Methods

Properties


swExpressionFunctionBoundary Stub class

Methods

Properties

Functions

swConvertText12($d)

Converts a number of a string with 12 digit precision

swConvertText15($d)

Converts a number of a string with 15 digit precision

swTrimTrailingZeroes($nbr)

Removes trailing zeros in fraction of a number
1000 returns 1000
105.32 returns 105.32
105.3200 returns 15.32

Used elements

Classes

XpNative, swExpression, swExpressionError, swExpressionFunctionBoundary

Functions

swConvertText12, swTrimTrailingZeroes, swUnescape

Globals

$err, $exp, $swExpressionFunctions, $swExpressionOperators, $swFunctions

Variables

$aggregatorfirstrun, $args, $comps, $cond, $currentindex, $currentlabel, $dummy, $found, $foundhigher, $globals, $jump, $localdict, $negationpossible, $operatorstack, $opfound, $opprec, $optop, $result, $results, $state, $tests, $values

Short variables: $a, $acc, $arg, $c, $ch, $d, $e, $e2, $f, $fl, $fn, $i, $j, $k, $l, $nbr, $op, $op2, $opi, $rv, $rvi, $s, $t, $tc, $te, $v

Features

array, class, exception, math, mb, str, string, variable

Others

s