@@ -96,9 +96,11 @@ public function parse($sql2)
9696 while ($ this ->scanner ->lookupNextToken () !== '' ) {
9797 switch (strtoupper ($ this ->scanner ->lookupNextToken ())) {
9898 case 'SELECT ' :
99+ $ this ->scanner ->expectToken ('SELECT ' );
99100 $ columnData = $ this ->scanColumns ();
100101 break ;
101102 case 'FROM ' :
103+ $ this ->scanner ->expectToken ('FROM ' );
102104 $ source = $ this ->parseSource ();
103105 break ;
104106 case 'WHERE ' :
@@ -111,7 +113,7 @@ public function parse($sql2)
111113 $ orderings = $ this ->parseOrderings ();
112114 break ;
113115 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 );
115117 }
116118 }
117119
@@ -134,8 +136,6 @@ public function parse($sql2)
134136 */
135137 protected function parseSource ()
136138 {
137- $ this ->scanner ->expectToken ('FROM ' );
138-
139139 $ selector = $ this ->parseSelector ();
140140
141141 $ next = $ this ->scanner ->lookupNextToken ();
@@ -528,7 +528,7 @@ protected function parseFullTextSearch()
528528
529529 list ($ selectorName , $ propertyName ) = $ this ->parseIdentifier ();
530530 $ this ->scanner ->expectToken (', ' );
531- $ expression = $ this ->parseLiteral ()-> getLiteralValue ();
531+ $ expression = $ this ->parseLiteralValue ();
532532 $ this ->scanner ->expectToken (') ' );
533533
534534 return $ this ->factory ->fullTextSearch ($ selectorName , $ propertyName , $ expression );
@@ -600,7 +600,7 @@ protected function parseDescendantNode()
600600 */
601601 protected function parsePath ()
602602 {
603- $ path = $ this ->parseLiteral ()-> getLiteralValue ();
603+ $ path = $ this ->parseLiteralValue ();
604604 if (substr ($ path , 0 , 1 ) === '[ ' && substr ($ path , -1 ) === '] ' ) {
605605 $ path = substr ($ path , 1 , -1 );
606606 }
@@ -622,7 +622,7 @@ protected function parseStaticOperand()
622622 return $ this ->factory ->bindVariable (substr ($ this ->scanner ->fetchNextToken (), 1 ));
623623 }
624624
625- return $ this ->parseLiteral ( );
625+ return $ this ->factory -> literal ( $ this -> parseLiteralValue () );
626626 }
627627
628628 /**
@@ -749,7 +749,7 @@ protected function parseCastLiteral($token)
749749 }
750750
751751 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 }' " );
753753 }
754754 $ token = substr ($ token , 1 , -1 );
755755 $ token = str_replace ('\\' .$ quoteString , $ quoteString , $ token );
@@ -782,7 +782,7 @@ protected function parseCastLiteral($token)
782782 *
783783 * @return LiteralInterface
784784 */
785- protected function parseLiteral ()
785+ protected function parseLiteralValue ()
786786 {
787787 $ token = $ this ->scanner ->fetchNextToken ();
788788 if ($ this ->scanner ->tokenIs ($ token , 'CAST ' )) {
@@ -826,7 +826,7 @@ protected function parseLiteral()
826826 $ token = false ;
827827 }
828828
829- return $ this -> factory -> literal ( $ token) ;
829+ return $ token ;
830830 }
831831
832832 /**
@@ -930,8 +930,6 @@ protected function parseOrdering()
930930 */
931931 protected function scanColumns ()
932932 {
933- $ this ->scanner ->expectToken ('SELECT ' );
934-
935933 // Wildcard
936934 if ($ this ->scanner ->lookupNextToken () === '* ' ) {
937935 $ this ->scanner ->fetchNextToken ();
0 commit comments