CLDR Plural Rule Parser
Parses CLDR plural rules
Loading...
Searching...
No Matches
CLDRPluralRuleParser\Converter Class Reference

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

 $rule
 
 $pos
 
 $end
 
 $operators = []
 
 $operands = []
 

Protected Member Functions

 __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.
 

Detailed Description

Helper class for converting rules to reverse polish notation (RPN).

Constructor & Destructor Documentation

◆ __construct()

CLDRPluralRuleParser\Converter::__construct ( string  $rule)
protected

Private constructor.

Parameters
string$rule

Member Function Documentation

◆ convert()

static CLDRPluralRuleParser\Converter::convert (   $rule)
static

Convert a rule to RPN.

This is the only public entry point.

Parameters
string$ruleThe 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
Operator$op

◆ error()

CLDRPluralRuleParser\Converter::error ( string  $message)
protected

Throw an error.

Parameters
string$message
Exceptions
Error
Returns
never

◆ newNumber()

CLDRPluralRuleParser\Converter::newNumber ( string  $text,
int  $pos 
)
protected

Create a numerical expression object.

Parameters
string$text
int$pos
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: