3 * @author Niklas Laxström, Tim Starling
8 namespace CLDRPluralRuleParser\Converter;
10 use CLDRPluralRuleParser\Error;
11 use CLDRPluralRuleParser\Converter;
14 * Helper for Converter.
15 * The base class for operators and expressions, describing a region of the input string.
18 public $parser, $pos, $length, $end;
20 function __construct( Converter $parser, $pos, $length ) {
21 $this->parser = $parser;
23 $this->length = $length;
24 $this->end = $pos + $length;
27 public function error( $message ) {
28 $text = $this->getText();
29 throw new Error( "$message at position " . ( $this->pos + 1 ) . ": \"$text\"" );
32 public function getText() {
33 return substr( $this->parser->rule, $this->pos, $this->length );