Пример #1
0
 protected function processEnd(Context $context, Language $language, Result $result, TokenIterator $tokens)
 {
     $this->setStart($result->getStart());
     if ($this->_start->postProcess) {
         $source = substr($tokens->getSource(), $this->_start->pos - $tokens->getOffset(), $this->_start->getLength());
         $tokens = $this->_start->inject->tokenize($source, $result->getTokens(), $this->_start->pos, Language::EMBEDDED_BY_PARENT);
         $result->exchangeArray($this->_start->inject->parse($tokens)->getTokens());
     }
     # closing unclosed tokens
     foreach (array_reverse($context->stack, true) as $id => $name) {
         $end = new Token($name, ['pos' => $this->pos]);
         $tokens[$id]->setEnd($end);
         $result->append($end);
     }
     $result->append($this);
     return false;
 }
Пример #2
0
 protected function processEnd(Context $context, Language $language, Result $result, TokenIterator $tokens)
 {
     foreach (array_filter($context->stack, function ($name) {
         return in_array($name, $this->closes);
     }) as $hash => $name) {
         $end = new Token($name, ['pos' => $this->pos]);
         $tokens[$hash]->setEnd($end);
         $result->append($end);
         unset($context->stack[$hash]);
     }
     return true;
 }
Пример #3
0
 protected function processEnd(Context $context, Language $language, Result $result, TokenIterator $tokens)
 {
     if ($this->_start) {
         $context->pop($this->_start);
     } else {
         if (($start = $context->find($this->name)) !== false) {
             $this->setStart($tokens[$start]);
             unset($context->stack[$start]);
         }
     }
     if (!$this->_start instanceof MetaToken) {
         $result->append($this);
     }
     return true;
 }