Esempio n. 1
0
 /**
  * @param ASTFunctionCall $functionCall
  *
  * @return mixed
  * @throws Exception\UQLInterpreterException
  */
 private function callFunction(ASTFunctionCall $functionCall)
 {
     try {
         return $this->extensionContainer->callFunction($functionCall->getFunctionName(), $functionCall->getArguments());
     } catch (\Exception $e) {
         throw new UQLInterpreterException("The execution of function '" . $functionCall->getFunctionName() . "' failed. Please check the arguments are valid. (" . $e->getMessage() . ")");
     }
 }
Esempio n. 2
0
 /**
  * Tries to match the following tokens to an <assertion>.
  *
  * @throws Exception\UQLSyntaxError
  * @return bool|ASTAssertion
  */
 public function matchAssertion()
 {
     $identifier = $this->nextToken();
     if ($identifier['token'] != 'T_IDENTIFIER') {
         // If a stream doesn't start with an identifier, it's not an <assertion>.
         $this->rewindToken();
         return false;
     }
     $operator = $this->matchOperator();
     if ($operator === false) {
         $this->nextToken();
         // MatchOperator rewinds
         $this->throwUnexpectedTokenSyntaxError(['OPERATOR'], 'Comparison operator expected after identifier');
     }
     $array = $this->matchArray();
     if ($array) {
         if ($operator['token'] !== 'T_OP_IN') {
             throw new UQLSyntaxError("Arrays are only valid after operator IN");
         }
         return new ASTAssertion($identifier['match'], $operator['token'], $array);
     }
     $literal = $this->nextToken();
     if ($literal['token'] == 'T_FUNCTION_CALL') {
         return new ASTAssertion($identifier['match'], $operator['token'], ASTFunctionCall::createFromExpression($literal['match']));
     }
     if (strpos($literal['token'], 'T_LITERAL') !== 0) {
         $this->throwUnexpectedTokenSyntaxError(['ARRAY_START', 'LITERAL'], 'Array, value or function call expected after comparison operator');
     }
     $literal = $this->transformLiteral($literal);
     return new ASTAssertion($identifier['match'], $operator['token'], $literal['match']);
 }