/** * Get dictionary generator * * @return \Magento\Setup\Module\I18n\Dictionary\Generator */ public static function getDictionaryGenerator() { if (null === self::$_dictionaryGenerator) { $filesCollector = new FilesCollector(); $phraseCollector = new Parser\Adapter\Php\Tokenizer\PhraseCollector(new Parser\Adapter\Php\Tokenizer()); $adapters = [ 'php' => new Parser\Adapter\Php($phraseCollector), 'html' => new Parser\Adapter\Html(), 'js' => new Parser\Adapter\Js(), 'xml' => new Parser\Adapter\Xml(), ]; $parser = new Parser\Parser($filesCollector, self::_getFactory()); $parserContextual = new Parser\Contextual($filesCollector, self::_getFactory(), self::_getContext()); foreach ($adapters as $type => $adapter) { $parser->addAdapter($type, $adapter); $parserContextual->addAdapter($type, $adapter); } self::$_dictionaryGenerator = new Dictionary\Generator( $parser, $parserContextual, self::_getFactory(), new Dictionary\Options\ResolverFactory() ); } return self::$_dictionaryGenerator; }
/** * @param string $tplName * @param string $source * @return string target codes */ public function compile($tplName, $source) { $lexer = new Lexer(); $tokenStream = $lexer->lex($source, $tplName); $parser = new Parser\Parser(); $nodeTree = $parser->parse($tokenStream); return $nodeTree->compile(); }
/** * Parses the given regular expression and returns its structure * * @param string $regex The regular expression to parse * * @return Pattern\Regex * * @static */ public static function parse($regex) { $parser = new Parser\Parser($regex); return $parser->parse(); }
$context = $tokens[$i][1]; $i += 2; while ($i < $count && $tokens[$i - 1][0] == T_NS_SEPARATOR) { $context .= '\\' . $tokens[$i][1]; $i += 2; } continue; } if (($tokens[$i - 2][0] == T_CLASS || $tokens[$i - 2][0] == T_INTERFACE) && $tokens[$i - 1][0] == T_WHITESPACE && $tokens[$i][0] == T_STRING) { $class_name = $tokens[$i][1]; $classArray[$context . '\\' . $class_name] = $relativeToOutput; } } } $info = new Program\createAutoloadFileProgramInfo(); $parser = new Parser\Parser($info); $usage = new Parser\UsageFormat(); $result = $parser->parse($_SERVER['argv'], 1); if (!$result()) { if ($result->displayHelp()) { echo $info->usage($usage); exit(0); } foreach ($result->getMessages() as $m) { echo ' - ' . $m . "\n"; } $usage->format = Parser\UsageFormat::SHORT_TEXT; echo $info->usage($usage); exit(1); } if ($result->displayHelp()) {