MediaWiki REL1_32
ExprParser Class Reference

Public Member Functions

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

Public Attributes

 $maxStackSize = 100
 
 $names
 
 $precedence
 
 $words
 

Detailed Description

Definition at line 65 of file ExprParser.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
string$expr
Exceptions
ExprError
Returns
string

Definition at line 179 of file ExprParser.php.

References $matches, 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, and EXPR_WHITE_CLASS.

◆ doOperation()

Member Data Documentation

◆ $maxStackSize

ExprParser::$maxStackSize = 100

Definition at line 66 of file ExprParser.php.

◆ $names

ExprParser::$names

Definition at line 107 of file ExprParser.php.

◆ $precedence

ExprParser::$precedence

Definition at line 68 of file ExprParser.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,
]
const EXPR_COSINE
const EXPR_AND
const EXPR_TANGENS
const EXPR_EXP
const EXPR_ARCSINE
const EXPR_EXPONENT
const EXPR_PI
const EXPR_DIVIDE
const EXPR_ARCCOS
const EXPR_OR
const EXPR_ARCTAN
const EXPR_FLOOR
const EXPR_SQRT
const EXPR_LN
const EXPR_SINE
const EXPR_FMOD
const EXPR_TRUNC
const EXPR_ABS
const EXPR_NOT
const EXPR_MOD
const EXPR_ROUND
const EXPR_CEIL

Definition at line 144 of file ExprParser.php.


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