/** * @param $prefix * @param $rules * @return mixed * @throws \Hoa\Compiler\Exception * @throws \Hoa\Regex\Exception */ public function generate($prefix, $rules) { $grammar = new Read('hoa://Library/Regex/Grammar.pp'); $compiler = Llk::load($grammar); $ast = $compiler->parse($prefix . $rules); $generator = new Isotropic(new Random()); return $generator->visit($ast); }
/** * Sample one new value. * * @param \Hoa\Math\Sampler $sampler Sampler. * @return mixed */ protected function _sample(Math\Sampler $sampler) { if (null === self::$_visitor) { self::$_visitor = new HoaRegex\Visitor\Isotropic($sampler); } return self::$_visitor->visit($this->_ast); }