当前位置: 首页>>代码示例>>PHP>>正文


PHP ezcTemplateCursor::pregMatch方法代码示例

本文整理汇总了PHP中ezcTemplateCursor::pregMatch方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcTemplateCursor::pregMatch方法的具体用法?PHP ezcTemplateCursor::pregMatch怎么用?PHP ezcTemplateCursor::pregMatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ezcTemplateCursor的用法示例。


在下文中一共展示了ezcTemplateCursor::pregMatch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseCurrent

 /**
  * Parses the float types by looking for float expression.
  *
  * @param ezcTemplateCursor $cursor
  * @return bool
  */
 protected function parseCurrent(ezcTemplateCursor $cursor)
 {
     if (!$cursor->atEnd()) {
         $matches = $cursor->pregMatch("#^(?:[0-9]+(([eE][+-]?[0-9]+)|((\\.[0-9]+)([eE][+-]?[0-9]+)?)))#");
         if ($matches !== false) {
             $float = new ezcTemplateLiteralTstNode($this->parser->source, $this->startCursor, $cursor);
             $float->value = (double) $matches;
             $this->value = $float->value;
             $this->element = $float;
             $this->appendElement($float);
             return true;
         }
     }
     return false;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:21,代码来源:float.php

示例2: parseCurrent

 /**
  * Parses the integer types by looking for numerical characters.
  *
  * @param ezcTemplateCursor $cursor
  * @return bool
  */
 protected function parseCurrent(ezcTemplateCursor $cursor)
 {
     if (!$cursor->atEnd()) {
         $matches = $cursor->pregMatch("#^-?[0-9]+#");
         if ($matches !== false) {
             $integer = new ezcTemplateLiteralTstNode($this->parser->source, $this->startCursor, $cursor);
             $integer->value = (int) $matches;
             $this->value = $integer->value;
             $this->element = $integer;
             $this->appendElement($integer);
             return true;
         }
     }
     return false;
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:21,代码来源:integer.php

示例3: parseCurrent

 /**
  * Parses the identifier types by looking for allowed characters.
  *
  * @param ezcTemplateCursor $cursor
  * @return bool
  */
 protected function parseCurrent(ezcTemplateCursor $cursor)
 {
     if (!$cursor->atEnd()) {
         $matches = $cursor->pregMatch("#^[a-zA-Z_][a-zA-Z0-9_]*#");
         if ($matches !== false) {
             $identifier = new ezcTemplateIdentifierTstNode($this->parser->source, $this->startCursor, $cursor);
             $identifier->value = (string) $matches;
             $this->identifierName = $identifier->value;
             $this->element = $identifier;
             $this->appendElement($identifier);
             return true;
         }
     }
     return false;
 }
开发者ID:zetacomponents,项目名称:template,代码行数:21,代码来源:identifier.php

示例4: parseCurrent

 /**
  * Parses the array types by looking for 'array(...)' and then using the
  * generic expression parser (ezcTemplateExpressionSourceToTstParser) to fetch the
  * keys and values.
  *
  * @param ezcTemplateCursor $cursor
  * @return bool
  */
 protected function parseCurrent(ezcTemplateCursor $cursor)
 {
     // skip whitespace and comments
     if (!$this->findNextElement()) {
         return false;
     }
     $name = $cursor->pregMatch("#^array[^\\w]#i", false);
     if ($name === false) {
         return false;
     }
     $lower = strtolower($name);
     if ($name !== $lower) {
         $this->findNonLowercase();
         throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $this->currentCursor, ezcTemplateSourceToTstErrorMessages::MSG_ARRAY_NOT_LOWERCASE);
     }
     $cursor->advance(5);
     // skip whitespace and comments
     $this->findNextElement();
     if (!$cursor->match('(')) {
         throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $this->currentCursor, ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_ROUND_BRACKET_OPEN);
     }
     $currentArray = array();
     $currentKeys = array();
     $expectItem = true;
     $elementNumber = 0;
     while (true) {
         // skip whitespace and comments
         if (!$this->findNextElement()) {
             throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $this->currentCursor, ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_ROUND_BRACKET_CLOSE);
         }
         if ($cursor->current() == ')') {
             $cursor->advance();
             $array = new ezcTemplateLiteralArrayTstNode($this->parser->source, $this->startCursor, $cursor);
             $array->keys = $currentKeys;
             $array->value = $currentArray;
             $this->element = $array;
             $this->appendElement($array);
             return true;
         }
         if (!$expectItem) {
             throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $this->currentCursor, ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_ROUND_BRACKET_CLOSE_OR_COMMA);
         }
         // Check for type
         if (!$expectItem || !$this->parseRequiredType('Expression')) {
             throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $this->currentCursor, ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_LITERAL);
         }
         $this->findNextElement();
         if ($cursor->match('=>')) {
             // Found the array key. Store it, and continue with the search for the value.
             $currentKeys[$elementNumber] = $this->lastParser->rootOperator;
             $this->findNextElement();
             // We have the key => value syntax so we need to find the value
             if (!$this->parseRequiredType('Expression')) {
                 throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $this->currentCursor, ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_LITERAL);
             }
             // Store the value.
             $currentArray[$elementNumber] = $this->lastParser->rootOperator;
             $elementNumber++;
         } else {
             // Store the value.
             $currentArray[$elementNumber] = $this->lastParser->rootOperator;
             $elementNumber++;
         }
         if ($this->lastParser->rootOperator instanceof ezcTemplateModifyingOperatorTstNode) {
             throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $this->currentCursor, ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED);
         }
         $this->findNextElement();
         // We allow a comma after the key/value even if there are no more
         // entries. This is compatible with PHP syntax.
         if ($cursor->match(',')) {
             $this->findNextElement();
             $expectItem = true;
         } else {
             $expectItem = false;
         }
     }
 }
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:85,代码来源:array.php

示例5: parseParameter

 /**
  * Parse a parameter
  *
  * @param ezcTemplateCursor $cursor
  * @return bool
  */
 protected function parseParameter($cursor)
 {
     // Without this, the expression parser keeps on reading.
     if ($cursor->match(')', false)) {
         return false;
     }
     $this->readingParameter = true;
     $startCursor = clone $cursor;
     $namedParameter = $cursor->pregMatch("#^[a-zA-Z_][a-zA-Z0-9_]*#");
     if ($namedParameter !== false) {
         $this->findNextElement();
         if (!$cursor->match("=")) {
             $namedParameter = false;
         }
     }
     if ($namedParameter === false) {
         $cursor->copy($startCursor);
     }
     // Check for expression, the parser will call self::atEnd() to check for end of expression.
     $expressionStartCursor = clone $cursor;
     $expressionParser = new ezcTemplateExpressionSourceToTstParser($this->parser, $this, null);
     $expressionParser->allowIdentifier = true;
     if (!$this->parseRequiredType($expressionParser) || $this->lastParser->currentOperator === null) {
         return false;
     }
     $rootOperator = $this->lastParser->currentOperator;
     if ($rootOperator instanceof ezcTemplateOperatorTstNode) {
         $rootOperator = $rootOperator->getRoot();
     }
     if ($rootOperator instanceof ezcTemplateModifyingOperatorTstNode) {
         throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $this->currentCursor, sprintf(ezcTemplateSourceToTstErrorMessages::MSG_PARAMETER_CANNOT_BE_MODIFYING_BLOCK, $this->parameterCount));
     }
     if ($namedParameter !== false) {
         if (isset($this->functionCall->parameters[$namedParameter])) {
             throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $this->currentCursor, sprintf(ezcTemplateSourceToTstErrorMessages::MSG_NAMED_PARAMETER_ALREADY_ASSIGNED, $namedParameter));
         }
         $this->functionCall->parameters[$namedParameter] = $rootOperator;
     } else {
         $this->functionCall->appendParameter($rootOperator);
     }
     $this->readingParameter = false;
     return true;
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:49,代码来源:function_call.php


注:本文中的ezcTemplateCursor::pregMatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。