MediaWiki  1.30.0
ExprParser Class Reference

Public Member Functions

 doExpression ( $expr)
 Evaluate a mathematical expression. More...
 
 doOperation ( $op, &$stack)
 

Public Attributes

 $maxStackSize = 100
 
 $names
 
 $precedence
 
 $words
 

Detailed Description

Definition at line 69 of file Expr.php.

Member Function Documentation

◆ doExpression()

ExprParser::doExpression (   $expr)

Evaluate a mathematical expression.

The algorithm here is based on the infix to RPN algorithm given in http://montcs.bloomu.edu/~bobmon/Information/RPN/infix2rpn.shtml It's essentially the same as Dijkstra's shunting yard algorithm.

Parameters
$exprstring
Exceptions
ExprError
Returns
string

Definition at line 183 of file Expr.php.

References $matches, $name, captcha-old\count, doOperation(), EXPR_ABS, EXPR_ARCCOS, EXPR_ARCSINE, EXPR_ARCTAN, EXPR_CEIL, EXPR_COSINE, EXPR_DIVIDE, EXPR_EQUALITY, EXPR_EXP, EXPR_EXPONENT, EXPR_FLOOR, EXPR_GREATER, EXPR_GREATEREQ, EXPR_LESS, EXPR_LESSEQ, EXPR_LN, EXPR_MINUS, EXPR_NEGATIVE, EXPR_NOT, EXPR_NOTEQ, EXPR_NUMBER_CLASS, EXPR_OPEN, EXPR_PI, EXPR_PLUS, EXPR_POSITIVE, EXPR_POW, EXPR_SINE, EXPR_SQRT, EXPR_TANGENS, EXPR_TIMES, EXPR_TRUNC, EXPR_WHITE_CLASS, and captcha-old\words.

◆ doOperation()

Member Data Documentation

◆ $maxStackSize

ExprParser::$maxStackSize = 100

Definition at line 70 of file Expr.php.

◆ $names

ExprParser::$names

Definition at line 111 of file Expr.php.

◆ $precedence

ExprParser::$precedence

Definition at line 72 of file Expr.php.

◆ $words

ExprParser::$words
Initial value:
= [
'mod' => EXPR_MOD,
'fmod' => EXPR_FMOD,
'and' => EXPR_AND,
'or' => EXPR_OR,
'not' => EXPR_NOT,
'round' => EXPR_ROUND,
'div' => EXPR_DIVIDE,
'e' => EXPR_EXPONENT,
'sin' => EXPR_SINE,
'cos' => EXPR_COSINE,
'tan' => EXPR_TANGENS,
'asin' => EXPR_ARCSINE,
'acos' => EXPR_ARCCOS,
'atan' => EXPR_ARCTAN,
'exp' => EXPR_EXP,
'ln' => EXPR_LN,
'abs' => EXPR_ABS,
'trunc' => EXPR_TRUNC,
'floor' => EXPR_FLOOR,
'ceil' => EXPR_CEIL,
'pi' => EXPR_PI,
'sqrt' => EXPR_SQRT,
]

Definition at line 148 of file Expr.php.


The documentation for this class was generated from the following file:
EXPR_TRUNC
const EXPR_TRUNC
Definition: Expr.php:46
EXPR_ARCCOS
const EXPR_ARCCOS
Definition: Expr.php:40
EXPR_OR
const EXPR_OR
Definition: Expr.php:26
EXPR_NOT
const EXPR_NOT
Definition: Expr.php:27
EXPR_EXP
const EXPR_EXP
Definition: Expr.php:42
EXPR_SQRT
const EXPR_SQRT
Definition: Expr.php:51
EXPR_ROUND
const EXPR_ROUND
Definition: Expr.php:34
EXPR_DIVIDE
const EXPR_DIVIDE
Definition: Expr.php:21
EXPR_TANGENS
const EXPR_TANGENS
Definition: Expr.php:38
EXPR_FLOOR
const EXPR_FLOOR
Definition: Expr.php:45
EXPR_ARCTAN
const EXPR_ARCTAN
Definition: Expr.php:41
EXPR_COSINE
const EXPR_COSINE
Definition: Expr.php:37
EXPR_SINE
const EXPR_SINE
Definition: Expr.php:36
EXPR_ARCSINE
const EXPR_ARCSINE
Definition: Expr.php:39
EXPR_FMOD
const EXPR_FMOD
Definition: Expr.php:50
EXPR_MOD
const EXPR_MOD
Definition: Expr.php:22
EXPR_LN
const EXPR_LN
Definition: Expr.php:43
EXPR_CEIL
const EXPR_CEIL
Definition: Expr.php:47
EXPR_ABS
const EXPR_ABS
Definition: Expr.php:44
EXPR_EXPONENT
const EXPR_EXPONENT
Definition: Expr.php:35
EXPR_PI
const EXPR_PI
Definition: Expr.php:49
EXPR_AND
const EXPR_AND
Definition: Expr.php:25