|
MediaWiki
REL1_20
|
Helper class for converting rules to reverse polish notation (RPN). More...
Static Public Member Functions | |
| static | convert ($rule) |
| Convert a rule to RPN. | |
Public Attributes | |
| $end | |
| $operands = array() | |
| $operators = array() | |
| $pos | |
| $rule | |
| const | NUMBER_CLASS = '0123456789' |
| Same for digits. | |
| const | WHITESPACE_CLASS = " \t\r\n" |
| A character list defining whitespace, for use in strspn() etc. | |
| const | WORD_REGEX = '/[a-zA-Z]+/A' |
| An anchored regular expression which matches a word at the current offset. | |
Static Public Attributes | |
| static | $precedence |
| Precedence levels. | |
Protected Member Functions | |
| __construct ($rule) | |
| Private constructor. | |
| doConvert () | |
| Do the operation. | |
| doOperation ($op) | |
| For the binary operator $op, pop its operands off the stack and push a fragment with rpn and type members describing the result of that operation. | |
| error ($message) | |
| Throw an error. | |
| newNumber ($text, $pos) | |
| Create a numerical expression object. | |
| newOperator ($type, $pos, $length) | |
| Create a binary operator. | |
| nextToken () | |
| Fetch the next token from the input string. | |
Helper class for converting rules to reverse polish notation (RPN).
Definition at line 210 of file CLDRPluralRuleEvaluator.php.
| CLDRPluralRuleConverter::__construct | ( | $ | rule | ) | [protected] |
| static CLDRPluralRuleConverter::convert | ( | $ | rule | ) | [static] |
Convert a rule to RPN.
This is the only public entry point.
Definition at line 253 of file CLDRPluralRuleEvaluator.php.
References $rule.
Referenced by CLDRPluralRuleEvaluator\compile().
| CLDRPluralRuleConverter::doConvert | ( | ) | [protected] |
Do the operation.
Definition at line 270 of file CLDRPluralRuleEvaluator.php.
References $value, doOperation(), error(), and nextToken().
| CLDRPluralRuleConverter::doOperation | ( | $ | op | ) | [protected] |
For the binary operator $op, pop its operands off the stack and push a fragment with rpn and type members describing the result of that operation.
Definition at line 413 of file CLDRPluralRuleEvaluator.php.
References $result.
Referenced by doConvert().
| CLDRPluralRuleConverter::error | ( | $ | message | ) | [protected] |
Throw an error.
Definition at line 440 of file CLDRPluralRuleEvaluator.php.
Referenced by doConvert(), and nextToken().
| CLDRPluralRuleConverter::newNumber | ( | $ | text, |
| $ | pos | ||
| ) | [protected] |
Create a numerical expression object.
Definition at line 426 of file CLDRPluralRuleEvaluator.php.
References $pos.
Referenced by nextToken().
| CLDRPluralRuleConverter::newOperator | ( | $ | type, |
| $ | pos, | ||
| $ | length | ||
| ) | [protected] |
Create a binary operator.
Definition at line 433 of file CLDRPluralRuleEvaluator.php.
References $pos.
Referenced by nextToken().
| CLDRPluralRuleConverter::nextToken | ( | ) | [protected] |
Fetch the next token from the input string.
Return it as a CLDRPluralRuleConverter_Fragment object.
Definition at line 328 of file CLDRPluralRuleEvaluator.php.
References error(), newNumber(), and newOperator().
Referenced by doConvert().
| CLDRPluralRuleConverter::$end |
Definition at line 211 of file CLDRPluralRuleEvaluator.php.
| CLDRPluralRuleConverter::$operands = array() |
Definition at line 213 of file CLDRPluralRuleEvaluator.php.
| CLDRPluralRuleConverter::$operators = array() |
Definition at line 212 of file CLDRPluralRuleEvaluator.php.
| CLDRPluralRuleConverter::$pos |
Definition at line 211 of file CLDRPluralRuleEvaluator.php.
Referenced by newNumber(), and newOperator().
CLDRPluralRuleConverter::$precedence [static] |
array(
'or' => 2,
'and' => 3,
'is' => 4,
'is-not' => 4,
'in' => 4,
'not-in' => 4,
'within' => 4,
'not-within' => 4,
'mod' => 5,
',' => 6,
'..' => 7,
)
Precedence levels.
Note that there's no need to worry about associativity for the level 4 operators, since they return boolean and don't accept boolean inputs.
Definition at line 220 of file CLDRPluralRuleEvaluator.php.
| CLDRPluralRuleConverter::$rule |
Definition at line 211 of file CLDRPluralRuleEvaluator.php.
Referenced by __construct(), and convert().
| const CLDRPluralRuleConverter::NUMBER_CLASS = '0123456789' |
Same for digits.
Note that the grammar given in UTS #35 doesn't allow negative numbers or decimals.
Definition at line 243 of file CLDRPluralRuleEvaluator.php.
| const CLDRPluralRuleConverter::WHITESPACE_CLASS = " \t\r\n" |
A character list defining whitespace, for use in strspn() etc.
Definition at line 237 of file CLDRPluralRuleEvaluator.php.
| const CLDRPluralRuleConverter::WORD_REGEX = '/[a-zA-Z]+/A' |
An anchored regular expression which matches a word at the current offset.
Definition at line 248 of file CLDRPluralRuleEvaluator.php.