diff options
Diffstat (limited to 'languages/utils/CLDRPluralRuleConverterFragment.php')
-rw-r--r-- | languages/utils/CLDRPluralRuleConverterFragment.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/languages/utils/CLDRPluralRuleConverterFragment.php b/languages/utils/CLDRPluralRuleConverterFragment.php new file mode 100644 index 00000000..df299cbd --- /dev/null +++ b/languages/utils/CLDRPluralRuleConverterFragment.php @@ -0,0 +1,34 @@ +<?php +/** + * @author Niklas Laxström, Tim Starling + * + * @copyright Copyright © 2010-2012, Niklas Laxström + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + * + * @file + * @since 1.20 + */ + +/** + * Helper for CLDRPluralRuleConverter. + * The base class for operators and expressions, describing a region of the input string. + */ +class CLDRPluralRuleConverterFragment { + public $parser, $pos, $length, $end; + + function __construct( $parser, $pos, $length ) { + $this->parser = $parser; + $this->pos = $pos; + $this->length = $length; + $this->end = $pos + $length; + } + + public function error( $message ) { + $text = $this->getText(); + throw new CLDRPluralRuleError( "$message at position " . ( $this->pos + 1 ) . ": \"$text\"" ); + } + + public function getText() { + return substr( $this->parser->rule, $this->pos, $this->length ); + } +} |