Helper class for converting rules to reverse polish notation (RPN).
More...
|
static | convert ( $rule) |
| Convert a rule to RPN.
|
|
|
| $rule |
|
| $pos |
|
| $end |
|
| $operators = [] |
|
| $operands = [] |
|
|
| __construct (string $rule) |
| Private constructor.
|
|
| nextToken () |
| Fetch the next token from the input string.
|
|
| doOperation (Operator $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.
|
|
| newNumber (string $text, int $pos) |
| Create a numerical expression object.
|
|
| newOperator (string $type, int $pos, int $length) |
| Create a binary operator.
|
|
| error (string $message) |
| Throw an error.
|
|
Helper class for converting rules to reverse polish notation (RPN).
◆ __construct()
CLDRPluralRuleParser\Converter::__construct |
( |
string | $rule | ) |
|
|
protected |
Private constructor.
- Parameters
-
◆ convert()
static CLDRPluralRuleParser\Converter::convert |
( |
| $rule | ) |
|
|
static |
Convert a rule to RPN.
This is the only public entry point.
- Parameters
-
string | $rule | The rule to convert |
- Returns
- string The RPN representation of the rule
◆ doOperation()
CLDRPluralRuleParser\Converter::doOperation |
( |
Operator | $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.
- Parameters
-
◆ error()
CLDRPluralRuleParser\Converter::error |
( |
string | $message | ) |
|
|
protected |
Throw an error.
- Parameters
-
- Exceptions
-
- Returns
- never
◆ newNumber()
CLDRPluralRuleParser\Converter::newNumber |
( |
string | $text, |
|
|
int | $pos ) |
|
protected |
Create a numerical expression object.
- Parameters
-
- Returns
- Expression The numerical expression
◆ newOperator()
CLDRPluralRuleParser\Converter::newOperator |
( |
string | $type, |
|
|
int | $pos, |
|
|
int | $length ) |
|
protected |
Create a binary operator.
- Parameters
-
string | $type | |
int | $pos | |
int | $length | |
- Returns
- Operator The operator
◆ nextToken()
CLDRPluralRuleParser\Converter::nextToken |
( |
| ) |
|
|
protected |
Fetch the next token from the input string.
- Returns
- Fragment|false The next token
The documentation for this class was generated from the following file: