芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/rentandbuyrealty.com/pay/vendor/hoa/compiler/Llk/Sampler/Sampler.php
_compiler = $compiler; $this->_tokens = $compiler->getTokens(); $this->_rules = $compiler->getRules(); $this->_tokenSampler = $tokenSampler; $this->_rootRuleName = $compiler->getRootRule(); return; } /** * Get compiler. * * @return \Hoa\Compiler\Llk\Parser */ public function getCompiler() { return $this->_compiler; } /** * Get the AST of the current namespace skip token. * * @return \Hoa\Compiler\Llk\TreeNode */ protected function getSkipTokenAST() { if (!isset($this->_skipTokenAST[$this->_currentNamespace])) { $token = new Compiler\Llk\Rule\Token( -1, 'skip', null, -1 ); $token->setRepresentation( $this->_tokens[$this->_currentNamespace]['skip'] ); $this->_skipTokenAST[$this->_currentNamespace] = $token->getAST(); } return $this->_skipTokenAST[$this->_currentNamespace]; } /** * Complete a token (namespace and representation). * It returns the next namespace. * * @param \Hoa\Compiler\Llk\Rule\Token $token Token. * @return string */ protected function completeToken(Compiler\Llk\Rule\Token $token) { if (null !== $token->getRepresentation()) { return $this->_currentNamespace; } $name = $token->getTokenName(); $token->setNamespace($this->_currentNamespace); $toNamespace = $this->_currentNamespace; if (isset($this->_tokens[$this->_currentNamespace][$name])) { $token->setRepresentation( $this->_tokens[$this->_currentNamespace][$name] ); } else { foreach ($this->_tokens[$this->_currentNamespace] as $_name => $regex) { if (false === strpos($_name, ':')) { continue; } list($_name, $toNamespace) = explode(':', $_name, 2); if ($_name === $name) { break; } } $token->setRepresentation($regex); } return $toNamespace; } /** * Set current token namespace. * * @param string $namespace Token namespace. * @return string */ protected function setCurrentNamespace($namespace) { $old = $this->_currentNamespace; $this->_currentNamespace = $namespace; return $old; } /** * Generate a token value. * Complete and set next token namespace. * * @param \Hoa\Compiler\Llk\Rule\Token $token Token. * @return string */ protected function generateToken(Compiler\Llk\Rule\Token $token) { $toNamespace = $this->completeToken($token); $this->setCurrentNamespace($toNamespace); $out = $this->_tokenSampler->visit($token->getAST()); if (isset($this->_tokens[$this->_currentNamespace]['skip'])) { $out .= $this->_tokenSampler->visit($this->getSkipTokenAST()); } return $out; } } /** * Flex entity. */ Consistency::flexEntity('Hoa\Compiler\Llk\Sampler\Sampler');