Commit cd50fc38 authored by guilhermeblanco's avatar guilhermeblanco

[2.0] Implemented EmptyCollectionComparisonExpression. Need to write SQL transformation yet.

parent 462a27ee
......@@ -55,41 +55,42 @@ class Lexer
const T_DESC = 112;
const T_DISTINCT = 113;
const T_DOT = 114;
const T_ESCAPE = 115;
const T_EXISTS = 116;
const T_FROM = 117;
const T_GROUP = 118;
const T_HAVING = 119;
const T_IN = 120;
const T_INDEX = 121;
const T_INNER = 122;
const T_IS = 123;
const T_JOIN = 124;
const T_LEFT = 125;
const T_LIKE = 126;
const T_LIMIT = 127;
const T_MAX = 128;
const T_MIN = 129;
const T_MOD = 130;
const T_NOT = 131;
const T_NULL = 132;
const T_OFFSET = 133;
const T_ON = 134;
const T_OR = 135;
const T_ORDER = 136;
const T_OUTER = 137;
const T_SELECT = 138;
const T_SET = 139;
const T_SIZE = 140;
const T_SOME = 141;
const T_SUM = 142;
const T_UPDATE = 143;
const T_WHERE = 144;
const T_WITH = 145;
const T_TRUE = 146;
const T_FALSE = 147;
const T_MEMBER = 148;
const T_OF = 149;
const T_EMPTY = 115;
const T_ESCAPE = 116;
const T_EXISTS = 117;
const T_FROM = 118;
const T_GROUP = 119;
const T_HAVING = 120;
const T_IN = 121;
const T_INDEX = 122;
const T_INNER = 123;
const T_IS = 124;
const T_JOIN = 125;
const T_LEFT = 126;
const T_LIKE = 127;
const T_LIMIT = 128;
const T_MAX = 129;
const T_MIN = 130;
const T_MOD = 131;
const T_NOT = 132;
const T_NULL = 133;
const T_OFFSET = 134;
const T_ON = 135;
const T_OR = 136;
const T_ORDER = 137;
const T_OUTER = 138;
const T_SELECT = 139;
const T_SET = 140;
const T_SIZE = 141;
const T_SOME = 142;
const T_SUM = 143;
const T_UPDATE = 144;
const T_WHERE = 145;
const T_WITH = 146;
const T_TRUE = 147;
const T_FALSE = 148;
const T_MEMBER = 149;
const T_OF = 150;
private $_keywordsTable;
......@@ -354,6 +355,7 @@ class Lexer
self::T_DESC => "DESC",
self::T_DISTINCT => "DISTINCT",
self::T_DOT => ".",
self::T_EMPTY => "EMPTY",
self::T_ESCAPE => "ESCAPE",
self::T_EXISTS => "EXISTS",
self::T_FALSE => "FALSE",
......
......@@ -1639,7 +1639,7 @@ class Parser
* InExpression | NullComparisonExpression | ExistsExpression |
* EmptyCollectionComparisonExpression | CollectionMemberExpression
*
* @todo Posy 2.0 release. Missing EmptyCollectionComparisonExpression implementation
* @todo Post 2.0 release. Missing EmptyCollectionComparisonExpression implementation
*/
public function SimpleConditionalExpression()
{
......@@ -1669,9 +1669,18 @@ class Parser
if ($peek['type'] === Lexer::T_NOT) {
$peek = $this->_lexer->peek();
}
$this->_lexer->resetPeek();
$token = $peek;
// We need to go even further in case of IS (differenciate between NULL and EMPTY)
$lookahead = $this->_lexer->peek();
// Also peek beyond a NOT if there is one
if ($lookahead['type'] === Lexer::T_NOT) {
$lookahead = $this->_lexer->peek();
}
$this->_lexer->resetPeek();
}
if ($pathExprOrInputParam) {
......@@ -1689,7 +1698,11 @@ class Parser
return $this->InExpression();
case Lexer::T_IS:
return $this->NullComparisonExpression();
if ($lookahead['type'] == Lexer::T_NULL) {
return $this->NullComparisonExpression();
}
return $this->EmptyCollectionComparisonExpression();
case Lexer::T_MEMBER:
return $this->CollectionMemberExpression();
......@@ -1703,6 +1716,28 @@ class Parser
}
/**
* EmptyCollectionComparisonExpression ::= CollectionValuedPathExpression "IS" ["NOT"] "EMPTY"
*
* @return \Doctrine\ORM\Query\AST\EmptyCollectionComparisonExpression
*/
public function EmptyCollectionComparisonExpression()
{
$emptyColletionCompExpr = new AST\EmptyCollectionComparisonExpression(
$this->CollectionValuedPathExpression()
);
$this->match(Lexer::T_IS);
if ($this->_lexer->isNextToken(Lexer::T_NOT)) {
$this->match(Lexer::T_NOT);
$emptyColletionCompExpr->setNot(true);
}
$this->match(Lexer::T_EMPTY);
return $emptyColletionCompExpr;
}
/**
* CollectionMemberExpression ::= EntityExpression ["NOT"] "MEMBER" ["OF"] CollectionValuedPathExpression
*
......@@ -2122,9 +2157,6 @@ class Parser
/**
* ComparisonExpression ::= ArithmeticExpression ComparisonOperator ( QuantifiedExpression | ArithmeticExpression )
*
* @return AST\ComparisonExpression
* @todo Semantical checks whether $leftExpr $operator and $rightExpr are compatible.
*
* @return \Doctrine\ORM\Query\AST\ComparisonExpression
*/
public function ComparisonExpression()
......
This diff is collapsed.
......@@ -249,6 +249,14 @@ interface TreeWalker
* @return string The SQL.
*/
function walkCollectionMemberExpression($collMemberExpr);
/**
* Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL.
*
* @param EmptyCollectionComparisonExpression
* @return string The SQL.
*/
function walkEmptyCollectionComparisonExpression($emptyCollCompExpr);
/**
* Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL.
......
......@@ -247,6 +247,14 @@ abstract class TreeWalkerAdapter implements TreeWalker
*/
public function walkCollectionMemberExpression($collMemberExpr) {}
/**
* Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL.
*
* @param EmptyCollectionComparisonExpression
* @return string The SQL.
*/
public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) {}
/**
* Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment