当前位置: 首页>>代码示例>>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;未经允许,请勿转载。