The transformation specifications look like:
CF = CF... : Map from one char to one or more chars (map)
CF - CF = CF... : Map range of chars to one or more chars (replace)
CF - CF +- xx : Transpose several chars by value xx (transpose)
CF - CF % yy +- xx : Transpose several chars by value xx, yy denotes skip value
yy equal to 1 is the same as 'transpose' (transpose-modulo)
TI[,TI...] :
CF = Character Format
TI = Transform Identifier
Character formats:
U+xxxx : Unicode value in hexadecimal
xx: Ascii value in hexadecimal
remove : Remove character from result, can only be used in destination
keep : Keep character as it is, can only be used in destination
"xxxx" : Multiple characters as a string, can only be used in destination, \\ means \ and \" means "
/** * Loads rules. * * @return array */ protected function getRules() { if ($this->compiledRules === null) { $rules = array(); foreach ($this->ruleFiles as $file) { $rules = array_merge($rules, $this->parser->parse($file)); } $this->compiledRules = $this->compiler->compile($rules); } return $this->compiledRules; }
/** * @dataProvider getTestFiles */ public function testParse($file) { $parser = new Persistence\TransformationProcessor\DefinitionBased\Parser(); $fixture = (include $file . '.result'); $this->assertEquals($fixture, $parser->parse($file)); }
public function testCompileModuloTranspose() { $parser = new Persistence\TransformationProcessor\DefinitionBased\Parser(self::getInstallationDir()); $compiler = new Persistence\TransformationProcessor\PcreCompiler(new Persistence\Utf8Converter()); $rules = $compiler->compile($parser->parseString("transpose_modulo_test:\n" . "U+00e0 - U+00e6 % 02 - 01")); $this->assertSame('ßááããååçè', $this->applyTransformations($rules, 'àáâãäåæçè')); }