Commit aa0792b1 authored by guilhermeblanco's avatar guilhermeblanco

[2.0] InputParameter removed from Literal, since it's not actually a literal...

[2.0] InputParameter removed from Literal, since it's not actually a literal value. Changed grammar rules to accomodate this decouple
parent 733556b6
...@@ -1117,7 +1117,7 @@ class Parser ...@@ -1117,7 +1117,7 @@ class Parser
/** /**
* UpdateItem ::= [IdentificationVariable "."] {StateField | SingleValuedAssociationField} "=" NewValue * UpdateItem ::= IdentificationVariable "." {StateField | SingleValuedAssociationField} "=" NewValue
* *
* @return \Doctrine\ORM\Query\AST\UpdateItem * @return \Doctrine\ORM\Query\AST\UpdateItem
*/ */
...@@ -1127,8 +1127,7 @@ class Parser ...@@ -1127,8 +1127,7 @@ class Parser
$identVariable = null; $identVariable = null;
if ($peek['value'] == '.') { if ($peek['value'] == '.') {
$this->match(Lexer::T_IDENTIFIER); $identVariable = $this->IdentificationVariable();
$identVariable = $this->_lexer->token['value'];
$this->match('.'); $this->match('.');
} else { } else {
throw QueryException::missingAliasQualifier(); throw QueryException::missingAliasQualifier();
...@@ -1219,9 +1218,6 @@ class Parser ...@@ -1219,9 +1218,6 @@ class Parser
* NewValue ::= SimpleArithmeticExpression | "NULL" * NewValue ::= SimpleArithmeticExpression | "NULL"
* *
* SimpleArithmeticExpression covers all *Primary grammar rules and also SimplEntityExpression * SimpleArithmeticExpression covers all *Primary grammar rules and also SimplEntityExpression
*
* @todo Find why removal of InputParameter check causes ClassTableInheritanceTest to fail with
* wrong parameter count (Should be processed in Literal, part of SimpleArithmeticExpression)
*/ */
public function NewValue() public function NewValue()
{ {
...@@ -1619,7 +1615,7 @@ class Parser ...@@ -1619,7 +1615,7 @@ class Parser
* InExpression | NullComparisonExpression | ExistsExpression | * InExpression | NullComparisonExpression | ExistsExpression |
* EmptyCollectionComparisonExpression | CollectionMemberExpression * EmptyCollectionComparisonExpression | CollectionMemberExpression
* *
* @todo Missing EmptyCollectionComparisonExpression implementation * @todo Posy 2.0 release. Missing EmptyCollectionComparisonExpression implementation
*/ */
public function SimpleConditionalExpression() public function SimpleConditionalExpression()
{ {
...@@ -1715,18 +1711,13 @@ class Parser ...@@ -1715,18 +1711,13 @@ class Parser
/** /**
* Literal ::= string | char | integer | float | boolean | InputParameter * Literal ::= string | char | integer | float | boolean
* *
* @todo Rip out InputParameter. Thats not a literal. * @return string
*/ */
public function Literal() public function Literal()
{ {
switch ($this->_lexer->lookahead['type']) { switch ($this->_lexer->lookahead['type']) {
case Lexer::T_INPUT_PARAMETER:
$this->match($this->_lexer->lookahead['value']);
return new AST\InputParameter($this->_lexer->token['value']);
case Lexer::T_STRING: case Lexer::T_STRING:
case Lexer::T_INTEGER: case Lexer::T_INTEGER:
case Lexer::T_FLOAT: case Lexer::T_FLOAT:
...@@ -1739,6 +1730,33 @@ class Parser ...@@ -1739,6 +1730,33 @@ class Parser
} }
} }
/**
* InParameter ::= Literal | InputParameter
*
* @return string | \Doctrine\ORM\Query\AST\InputParameter
*/
public function InParameter()
{
if ($this->_lexer->lookahead['type'] == Lexer::T_INPUT_PARAMETER) {
return $this->InputParameter();
}
return $this->Literal();
}
/**
* InputParameter ::= PositionalParameter | NamedParameter
*
* @return \Doctrine\ORM\Query\AST\InputParameter
*/
public function InputParameter()
{
$this->match($this->_lexer->lookahead['value']);
return new AST\InputParameter($this->_lexer->token['value']);
}
/** /**
* ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")" * ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")"
...@@ -1864,16 +1882,12 @@ class Parser ...@@ -1864,16 +1882,12 @@ class Parser
return $this->IdentificationVariable(); return $this->IdentificationVariable();
case Lexer::T_INPUT_PARAMETER: case Lexer::T_INPUT_PARAMETER:
$this->match($this->_lexer->lookahead['value']); return $this->InputParameter();
return new AST\InputParameter($this->_lexer->token['value']);
case Lexer::T_STRING: case Lexer::T_STRING:
case Lexer::T_INTEGER: case Lexer::T_INTEGER:
case Lexer::T_FLOAT: case Lexer::T_FLOAT:
$this->match($this->_lexer->lookahead['value']); return $this->Literal();
return $this->_lexer->token['value'];
default: default:
$peek = $this->_lexer->glimpse(); $peek = $this->_lexer->glimpse();
...@@ -1935,9 +1949,7 @@ class Parser ...@@ -1935,9 +1949,7 @@ class Parser
return $this->_lexer->token['value']; return $this->_lexer->token['value'];
} else if ($this->_lexer->lookahead['type'] === Lexer::T_INPUT_PARAMETER) { } else if ($this->_lexer->lookahead['type'] === Lexer::T_INPUT_PARAMETER) {
$this->match(Lexer::T_INPUT_PARAMETER); return $this->InputParameter();
return new AST\InputParameter($this->_lexer->token['value']);
} else if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) { } else if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
return $this->AggregateExpression(); return $this->AggregateExpression();
} }
...@@ -1970,8 +1982,7 @@ class Parser ...@@ -1970,8 +1982,7 @@ class Parser
public function SimpleEntityExpression() public function SimpleEntityExpression()
{ {
if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) {
$this->match(Lexer::T_INPUT_PARAMETER); return $this->InputParameter();
return new AST\InputParameter($this->_lexer->token['value']);
} }
return $this->IdentificationVariable(); return $this->IdentificationVariable();
...@@ -2109,7 +2120,7 @@ class Parser ...@@ -2109,7 +2120,7 @@ class Parser
} }
/** /**
* InExpression ::= StateFieldPathExpression ["NOT"] "IN" "(" (Literal {"," Literal}* | Subselect) ")" * InExpression ::= StateFieldPathExpression ["NOT"] "IN" "(" (InParameter {"," InParameter}* | Subselect) ")"
* *
* @return \Doctrine\ORM\Query\AST\InExpression * @return \Doctrine\ORM\Query\AST\InExpression
*/ */
...@@ -2129,11 +2140,11 @@ class Parser ...@@ -2129,11 +2140,11 @@ class Parser
$inExpression->setSubselect($this->Subselect()); $inExpression->setSubselect($this->Subselect());
} else { } else {
$literals = array(); $literals = array();
$literals[] = $this->Literal(); $literals[] = $this->InParameter();
while ($this->_lexer->isNextToken(',')) { while ($this->_lexer->isNextToken(',')) {
$this->match(','); $this->match(',');
$literals[] = $this->Literal(); $literals[] = $this->InParameter();
} }
$inExpression->setLiterals($literals); $inExpression->setLiterals($literals);
......
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