Exemplo n.º 1
0
 /**
  * FunctionDeclaration ::= FunctionsReturningStrings | FunctionsReturningNumerics | FunctionsReturningDatetime
  */
 public function FunctionDeclaration()
 {
     $token = $this->_lexer->lookahead;
     $funcName = strtolower($token['value']);
     // Check for built-in functions first!
     if (isset(self::$_STRING_FUNCTIONS[$funcName])) {
         return $this->FunctionsReturningStrings();
     } else {
         if (isset(self::$_NUMERIC_FUNCTIONS[$funcName])) {
             return $this->FunctionsReturningNumerics();
         } else {
             if (isset(self::$_DATETIME_FUNCTIONS[$funcName])) {
                 return $this->FunctionsReturningDatetime();
             }
         }
     }
     // Check for custom functions afterwards
     $config = $this->_em->getConfiguration();
     if (($func = $config->getCustomStringFunction($funcName)) !== null) {
         self::$_STRING_FUNCTIONS[$funcName] = $func;
         return $this->FunctionsReturningStrings();
     } else {
         if (($func = $config->getCustomNumericFunction($funcName)) !== null) {
             self::$_NUMERIC_FUNCTIONS[$funcName] = $func;
             return $this->FunctionsReturningNumerics();
         } else {
             if (($func = $config->getCustomDatetimeFunction($funcName)) !== null) {
                 self::$_DATETIME_FUNCTIONS[$funcName] = $func;
                 return $this->FunctionsReturningDatetime();
             }
         }
     }
     $this->syntaxError('known function', $token);
 }
Exemplo n.º 2
0
 public function CustomFunctionsReturningStrings()
 {
     $funcName = $this->_lexer->lookahead['value'];
     // getCustomStringFunction is case-insensitive
     $funcClass = $this->_em->getConfiguration()->getCustomStringFunction($funcName);
     $function = new $funcClass($funcName);
     $function->parse($this);
     return $function;
 }