/** * Create a parser for arithmitic expressions * * @return Hoa\Compiler\Llk\Parser */ protected function getParser() { if (!isset(static::$parser)) { static::$parser = Hoa\Compiler\Llk\Llk::load(new Hoa\File\Read('hoa://Library/Math/Arithmetic.pp')); } return static::$parser; }
public static function getParser() { if (static::$parser === null) { static::$parser = new VersionParser(); } return static::$parser; }
/** * Load Markdown and get it setup. * * @return void */ public static function _init() { if (!class_exists('Michelf\\MarkdownExtra')) { throw new Exception('The Markdown composer library isn\'t installed. Make sure it\'s in your "composer.json", then run "composer update" to install it!'); } static::$parser = new \Michelf\MarkdownExtra(); }
/** * Load Markdown and get it setup. * * @return void */ public static function _init() { if (!class_exists('MarkdownExtra_Parser', false)) { include COREPATH . 'vendor' . DS . 'markdown' . DS . 'markdown.php'; } static::$parser = new MarkdownExtra_Parser(); }
/** * Parses PHP Markdown syntax. * * @param string $string Markdown syntax string. * * @return string String after having been parsed as PHP Markdown. * * @throws exception If invalid types are passed through arguments list. */ public function parse($string) { $this->check_arg_types('string', func_get_args()); if (!isset(static::$parser)) { static::$parser = new externals\markdown_x(); } return static::$parser->transform($string); }
/** * Load annotation parser * * @param ParserInterface $parser * @return ParserInterface */ public static function parser(ParserInterface $parser = null) { if ($parser) { static::$parser = $parser; } elseif (!static::$parser) { static::$parser = new Annotation\KeyValuePairParser(); } return static::$parser; }
/** * {@inheritdoc} */ public static function getInstance() { // setup an instance if needed if (!static::$parser) { if (class_exists('Michelf\\MarkdownExtra')) { static::$parser = new \Michelf\MarkdownExtra(); } else { throw new \RuntimeException('FOU-021: Unable to create a Markdown instance. Did you install the "michelf\\php-markdown" composer package?'); } } return static::$parser; }
public static function parse($text) { if (!isset(static::$parser)) { static::$parser = static::getParser(); } if (isset(static::$beforeParse)) { $text = \call_user_func(static::$beforeParse, $text); } $xml = static::$parser->parse($text); if (isset(static::$afterParse)) { $xml = \call_user_func(static::$afterParse, $xml); } return $xml; }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); static::$parser = new CityMapParser(); }
/** * Create a new rule from a string. * * @param string $string * @throws Exception\ParseException * @return Rule */ public static function fromString($string) { if (static::$parser === null) { static::$parser = new Parser(); } if (!preg_match('(nplurals=(?P<nplurals>\\d+))', $string, $match)) { throw new Exception\ParseException(sprintf('Unknown or invalid parser rule: %s', $string)); } $numPlurals = (int) $match['nplurals']; if (!preg_match('(plural=(?P<plural>[^;\\n]+))', $string, $match)) { throw new Exception\ParseException(sprintf('Unknown or invalid parser rule: %s', $string)); } $tree = static::$parser->parse($match['plural']); $ast = static::createAst($tree); return new static($numPlurals, $ast); }
/** * Reset the cached parser and renderer * * @return void */ public static function reset() { static::$parser = null; static::$renderer = null; }
/** * Set search query parser factory instance. * * @param \Sofa\Eloquence\Contracts\Searchable\ParserFactory $factory */ public static function setParserFactory(ParserFactory $factory) { static::$parser = $factory; }
public static function _reset(Test $test) { self::$calls = ['getParser' => 0, 'getRenderer' => 0]; $mock = $test->getMock('stdClass', ['parse', 'render', 'setParameters']); $mock->expects($test->never())->method('parse'); $mock->expects($test->never())->method('render'); $mock->expects($test->never())->method('setParameters'); static::$parser = null; static::$_parser = $mock; static::$renderer = null; static::$_renderer = $mock; static::$beforeParse = null; static::$afterParse = null; static::$beforeRender = null; static::$afterRender = null; static::$beforeUnparse = null; static::$afterUnparse = null; }
/** * Gets the Parser implementation. * * @return Parser\ParserInterface * * @since 2.0.0 */ private static function getParser() { if (is_null(static::$parser)) { static::$parser = new Parser\DateTimeParser(); } return static::$parser; }
/** * Seriously? You want to do your own parsing thang? Ok, set a callback here. * * @param mixed $callback any valid callback. * @return object */ public static function setParser($callback) { static::$parser = $callback; return static::chain(); }
/** * @return DocParser */ protected static function getParser() { if (static::$parser === null) { $environment = Environment::createCommonMarkEnvironment(); $environment->addExtension(new TableExtension()); static::$parser = new DocParser($environment); } return static::$parser; }
/** * Sets the parser instance to use * * @param \Crossjoin\Browscap\Parser\AbstractParser $parser */ public static function setParser(Parser\AbstractParser $parser) { static::$parser = $parser; }
/** * setParser * * @param \Symfony\Component\Yaml\Parser $parser * * @return YamlFormat Return self to support chaining. */ public static function setParser($parser) { static::$parser = $parser; }
/** * Initialize and access a Pdp\Parser object * * @return Pdp\Parser */ protected function getHostnameParser() { if (!static::$parser instanceof Pdp\Parser) { static::$parser = $this->newHostnameParser(); } return static::$parser; }