@@ -96,9 +96,11 @@ public function parse($sql2)
96
96
while ($ this ->scanner ->lookupNextToken () !== '' ) {
97
97
switch (strtoupper ($ this ->scanner ->lookupNextToken ())) {
98
98
case 'SELECT ' :
99
+ $ this ->scanner ->expectToken ('SELECT ' );
99
100
$ columnData = $ this ->scanColumns ();
100
101
break ;
101
102
case 'FROM ' :
103
+ $ this ->scanner ->expectToken ('FROM ' );
102
104
$ source = $ this ->parseSource ();
103
105
break ;
104
106
case 'WHERE ' :
@@ -111,7 +113,7 @@ public function parse($sql2)
111
113
$ orderings = $ this ->parseOrderings ();
112
114
break ;
113
115
default :
114
- throw new InvalidQueryException ('Expected end of query, got ' . $ this ->scanner ->lookupNextToken () . ' in ' . $ this ->sql2 );
116
+ throw new InvalidQueryException ('Error parsing query, unknown query part " ' . $ this ->scanner ->lookupNextToken () . '" in: ' . $ this ->sql2 );
115
117
}
116
118
}
117
119
@@ -134,8 +136,6 @@ public function parse($sql2)
134
136
*/
135
137
protected function parseSource ()
136
138
{
137
- $ this ->scanner ->expectToken ('FROM ' );
138
-
139
139
$ selector = $ this ->parseSelector ();
140
140
141
141
$ next = $ this ->scanner ->lookupNextToken ();
@@ -528,7 +528,7 @@ protected function parseFullTextSearch()
528
528
529
529
list ($ selectorName , $ propertyName ) = $ this ->parseIdentifier ();
530
530
$ this ->scanner ->expectToken (', ' );
531
- $ expression = $ this ->parseLiteral ()-> getLiteralValue ();
531
+ $ expression = $ this ->parseLiteralValue ();
532
532
$ this ->scanner ->expectToken (') ' );
533
533
534
534
return $ this ->factory ->fullTextSearch ($ selectorName , $ propertyName , $ expression );
@@ -600,7 +600,7 @@ protected function parseDescendantNode()
600
600
*/
601
601
protected function parsePath ()
602
602
{
603
- $ path = $ this ->parseLiteral ()-> getLiteralValue ();
603
+ $ path = $ this ->parseLiteralValue ();
604
604
if (substr ($ path , 0 , 1 ) === '[ ' && substr ($ path , -1 ) === '] ' ) {
605
605
$ path = substr ($ path , 1 , -1 );
606
606
}
@@ -622,7 +622,7 @@ protected function parseStaticOperand()
622
622
return $ this ->factory ->bindVariable (substr ($ this ->scanner ->fetchNextToken (), 1 ));
623
623
}
624
624
625
- return $ this ->parseLiteral ( );
625
+ return $ this ->factory -> literal ( $ this -> parseLiteralValue () );
626
626
}
627
627
628
628
/**
@@ -749,7 +749,7 @@ protected function parseCastLiteral($token)
749
749
}
750
750
751
751
if (substr ($ token , -1 ) !== $ quoteString ) {
752
- throw new InvalidQueryException ("Syntax error: unterminated quoted string $ token in ' {$ this ->sql2 }' " );
752
+ throw new InvalidQueryException ("Syntax error: unterminated quoted string ' $ token' in ' {$ this ->sql2 }' " );
753
753
}
754
754
$ token = substr ($ token , 1 , -1 );
755
755
$ token = str_replace ('\\' .$ quoteString , $ quoteString , $ token );
@@ -782,7 +782,7 @@ protected function parseCastLiteral($token)
782
782
*
783
783
* @return LiteralInterface
784
784
*/
785
- protected function parseLiteral ()
785
+ protected function parseLiteralValue ()
786
786
{
787
787
$ token = $ this ->scanner ->fetchNextToken ();
788
788
if ($ this ->scanner ->tokenIs ($ token , 'CAST ' )) {
@@ -826,7 +826,7 @@ protected function parseLiteral()
826
826
$ token = false ;
827
827
}
828
828
829
- return $ this -> factory -> literal ( $ token) ;
829
+ return $ token ;
830
830
}
831
831
832
832
/**
@@ -930,8 +930,6 @@ protected function parseOrdering()
930
930
*/
931
931
protected function scanColumns ()
932
932
{
933
- $ this ->scanner ->expectToken ('SELECT ' );
934
-
935
933
// Wildcard
936
934
if ($ this ->scanner ->lookupNextToken () === '* ' ) {
937
935
$ this ->scanner ->fetchNextToken ();
0 commit comments