コード例 #1
0
ファイル: SequenceExpression.php プロジェクト: Samshal/xsl
 /**
  * @param Lexer $lexer
  * @return bool
  */
 public function supports(Lexer $lexer)
 {
     if ($lexer->current() !== '(') {
         return false;
     }
     if ($lexer->key() > 0) {
         $whiteSpaceOrOpeningParenthesis = new MatchingIterator($lexer, '/\\s|\\(/', MatchingIterator::DIRECTION_DOWN);
         for ($i = 0, $j = 2; $i < $j; $i++) {
             if ($whiteSpaceOrOpeningParenthesis->valid() === false) {
                 return false;
             }
             if ($whiteSpaceOrOpeningParenthesis->key() < $lexer->key() - $i) {
                 return false;
             }
             $whiteSpaceOrOpeningParenthesis->next();
         }
     }
     $key = $lexer->key() + 1;
     $commaFound = false;
     while ($nextToken = $lexer->peek($key)) {
         if ($nextToken === '(') {
             return false;
         }
         if ($nextToken === ',') {
             $commaFound = true;
         }
         if ($nextToken === ')') {
             return $commaFound;
         }
         $key++;
     }
     return false;
 }
コード例 #2
0
ファイル: FunctionExpression.php プロジェクト: genkgo/xsl
 /**
  * @param Lexer $lexer
  * @param DOMNode $currentElement
  * @return string[]
  */
 private function createFunctionTokens(Lexer $lexer, DOMNode $currentElement)
 {
     $token = $lexer->current();
     $documentElement = $currentElement->ownerDocument->documentElement;
     $namespaces = FetchNamespacesFromNode::fetch($documentElement);
     $functionName = $this->convertTokenToFunctionName($token, $namespaces);
     if ($this->functions->has($functionName)) {
         $function = $this->functions->get($functionName);
         if ($function instanceof ReplaceFunctionInterface) {
             return $function->replace($lexer, $currentElement);
         }
     }
     return [$token];
 }
コード例 #3
0
ファイル: ForLoopExpression.php プロジェクト: Samshal/xsl
 /**
  * @param Lexer $lexer
  * @return bool
  */
 public function supports(Lexer $lexer)
 {
     return $lexer->current() === 'to' && preg_match('/\\s/', $lexer->peek($lexer->key() - 1)) === 1;
 }