public function parse(\Doctrine\ORM\Query\Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); // Add the concat separator to the values array. $this->values[] = $parser->ArithmeticExpression(); // Add the rest of the strings to the values array. CONCAT_WS must // be used with at least 2 strings not including the separator. $lexer = $parser->getLexer(); while (count($this->values) < 3 || $lexer->lookahead['type'] == Lexer::T_COMMA) { $parser->match(Lexer::T_COMMA); $peek = $lexer->glimpse(); $this->values[] = $peek['value'] == '(' ? $parser->FunctionDeclaration() : $parser->ArithmeticExpression(); } while ($lexer->lookahead['type'] == Lexer::T_IDENTIFIER) { switch (strtolower($lexer->lookahead['value'])) { case 'notempty': $parser->match(Lexer::T_IDENTIFIER); $this->notEmpty = true; break; default: // Identifier not recognized (causes exception). $parser->match(Lexer::T_CLOSE_PARENTHESIS); break; } } $parser->match(Lexer::T_CLOSE_PARENTHESIS); }
/** * Parse function * * @param \Doctrine\ORM\Query\Parser $parser Parser * * @return void */ public function parse(\Doctrine\ORM\Query\Parser $parser) { $parser->match(\Doctrine\ORM\Query\Lexer::T_IDENTIFIER); $parser->match(\Doctrine\ORM\Query\Lexer::T_OPEN_PARENTHESIS); try { $this->ifThen = $parser->FunctionDeclaration(); } catch (\Doctrine\ORM\Query\QueryException $e) { $this->ifThen = $parser->ScalarExpression(); } $parser->match(\Doctrine\ORM\Query\Lexer::T_COMMA); try { $this->ifElse = $parser->FunctionDeclaration(); } catch (\Doctrine\ORM\Query\QueryException $e) { $this->ifElse = $parser->ScalarExpression(); } $parser->match(\Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS); }
public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); $this->values[] = $parser->ArithmeticExpression(); $lexer = $parser->getLexer(); while (count($this->values) < 3 || $lexer->lookahead['type'] == Lexer::T_COMMA) { $parser->match(Lexer::T_COMMA); $peek = $lexer->glimpse(); $this->values[] = $peek['value'] == '(' ? $parser->FunctionDeclaration() : $parser->ArithmeticExpression(); } while ($lexer->lookahead['type'] == Lexer::T_IDENTIFIER) { switch (strtolower($lexer->lookahead['value'])) { case 'notempty': $parser->match(Lexer::T_IDENTIFIER); $this->notEmpty = true; break; default: $parser->match(Lexer::T_CLOSE_PARENTHESIS); break; } } $parser->match(Lexer::T_CLOSE_PARENTHESIS); }