/** * Switches the $token to a ComposedToken * @param stream $stream */ public function composeToken($stream) { $this->token = $this->lexer->getCreatedComposedTokener($stream, $this->getToken()); $this->token->setParser($this); return $this->token; }
/** * This is the core iteration of process() method * @param Lexer $lexer * @return int The returning position-offset for next iteration (will be incremented by 1) */ protected function iteration(Lexer $lexer) { $offset = 0; // stop processing when simple closing sequence found if ($this->identifyCloseTag()) { $this->close(); return $offset; } // create a token on current position for checking if there's a sub-token $substream = $this->getSubStream($this->getCursor()); $tokeners = $lexer->getCreatedTokeners($substream); $dataTker = $lexer->getCreatedDataTokener($substream); $token = Lexer::tokenize($tokeners, $dataTker); // check if a sub-token found if (!$token->isDataStream()) { // getting a new instance of used Parser $dataBefore = $this->getSubStream(0, $this->getCursor()); $this->subparser = $this->getParser()->getNewInstance($substream)->parse($token->setParent($this), $dataBefore); // incrementing the position of processing to the end of the sub-token's closing tag $offset = $this->subparser->getToken()->getLength(); $this->setCursor($offset); $this->close(true); // next iteration increments position to continue the processing } return $offset; }