當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ezcTemplateCursor::gotoEnd方法代碼示例

本文整理匯總了PHP中ezcTemplateCursor::gotoEnd方法的典型用法代碼示例。如果您正苦於以下問題:PHP ezcTemplateCursor::gotoEnd方法的具體用法?PHP ezcTemplateCursor::gotoEnd怎麽用?PHP ezcTemplateCursor::gotoEnd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ezcTemplateCursor的用法示例。


在下文中一共展示了ezcTemplateCursor::gotoEnd方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parseCurrent

 /**
  * Parses the comment by looking for the end marker \n.
  *
  * @param ezcTemplateCursor $cursor
  * @return bool
  */
 protected function parseCurrent(ezcTemplateCursor $cursor)
 {
     $cutOff = false;
     if (!$cursor->atEnd()) {
         $cursor->advance(2);
         $matches = $cursor->pregMatchComplete("#^([^}\r\n]*)(?:(?:})|(\r|\r\n|\n))#");
         if ($matches) {
             // reached end of comment
             $cutOff = false;
             if (isset($matches[2])) {
                 $cursor->advance($matches[2][1] + strlen($matches[2][0]));
                 // Do not include the newline itself in the comment.
                 $cutOff = -1;
             } else {
                 $cursor->advance($matches[1][1] + strlen($matches[1][0]));
             }
         } else {
             $cursor->gotoEnd();
         }
         $commentBlock = new ezcTemplateEolCommentTstNode($this->parser->source, $this->startCursor, clone $cursor);
         if ($cutOff) {
             $commentBlock->commentText = substr($commentBlock->text(), 2, $cutOff);
         } else {
             $commentBlock->commentText = substr($commentBlock->text(), 2);
         }
         $this->appendElement($commentBlock);
         return true;
     }
     return false;
 }
開發者ID:zetacomponents,項目名稱:template,代碼行數:36,代碼來源:eol_comment.php

示例2: parseCurrent

 /**
  * Parses the code by looking for start of expression blocks and then
  * passing control to the block parser (ezcTemplateBlockSourceToTstParser). The
  * text which is not covered by the block parser will be added as
  * text elements.
  *
  * @param ezcTemplateCursor $cursor
  * @return bool
  */
 protected function parseCurrent(ezcTemplateCursor $cursor)
 {
     $this->program = new ezcTemplateProgramTstNode($this->parser->source, $this->startCursor, $cursor);
     $this->lastBlock = $this->program;
     while (!$cursor->atEnd()) {
         // Find the first block
         $bracePosition = $cursor->findPosition("{", true);
         if ($bracePosition === false) {
             $cursor->gotoEnd();
             // This will cause handleSuccessfulResult() to be called
             return true;
         }
         // Reached a block {...}
         $cursor->gotoPosition($bracePosition);
         $blockCursor = clone $cursor;
         $cursor->advance(1);
         if ($this->lastCursor->length($blockCursor) > 0) {
             $textElement = new ezcTemplateTextBlockTstNode($this->parser->source, clone $this->lastCursor, clone $blockCursor);
             $this->handleElements(array($textElement));
             unset($textElement);
         }
         $this->startCursor->copy($blockCursor);
         $this->lastCursor->copy($cursor);
         if (!$this->parseRequiredType('Block', $this->startCursor, false)) {
             return false;
         }
         $this->startCursor->copy($cursor);
         $elements = $this->lastParser->elements;
         // Sanity checking to make sure element list does not contain duplicates,
         // this avoids having infinite recursions
         $count = count($elements);
         if ($count > 0) {
             $offset = 0;
             while ($offset < $count) {
                 $element = $elements[$offset];
                 for ($i = $offset + 1; $i < $count; ++$i) {
                     if ($element === $elements[$i]) {
                         throw new ezcTemplateInternalException("Received element list with duplicate objects from parser " . get_class($this->lastParser));
                     }
                 }
                 ++$offset;
             }
         }
         $this->handleElements($elements);
     }
     // This will cause handleSuccessfulResult() to be called
     return true;
 }
開發者ID:zetacomponents,項目名稱:template,代碼行數:57,代碼來源:program.php


注:本文中的ezcTemplateCursor::gotoEnd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。