@@ -39,20 +39,20 @@ class CacheCommandsParser
3939 */
4040 public function parseCacheIndex (TokenList $ tokenList ): CacheIndexCommand
4141 {
42- $ tokenList ->consumeKeywords (Keyword::CACHE , Keyword::INDEX );
42+ $ tokenList ->expectKeywords (Keyword::CACHE , Keyword::INDEX );
4343
4444 $ tableIndexLists = [];
4545 do {
46- $ table = new QualifiedName (...$ tokenList ->consumeQualifiedName ());
46+ $ table = new QualifiedName (...$ tokenList ->expectQualifiedName ());
4747 $ indexes = $ this ->parseIndexes ($ tokenList );
4848
4949 $ tableIndexLists [] = new TableIndexList ($ table , $ indexes );
50- } while ($ tokenList ->mayConsumeComma ());
50+ } while ($ tokenList ->hasComma ());
5151
5252 $ partitions = $ this ->parsePartitions ($ tokenList );
5353
54- $ tokenList ->consumeKeyword (Keyword::IN );
55- $ keyCache = $ tokenList ->consumeName ();
54+ $ tokenList ->expectKeyword (Keyword::IN );
55+ $ keyCache = $ tokenList ->expectName ();
5656 $ tokenList ->expectEnd ();
5757
5858 return new CacheIndexCommand ($ keyCache , $ tableIndexLists , $ partitions );
@@ -73,17 +73,17 @@ public function parseCacheIndex(TokenList $tokenList): CacheIndexCommand
7373 */
7474 public function parseLoadIndexIntoCache (TokenList $ tokenList ): LoadIndexIntoCacheCommand
7575 {
76- $ tokenList ->consumeKeywords (Keyword::LOAD , Keyword::INDEX , Keyword::INTO , Keyword::CACHE );
76+ $ tokenList ->expectKeywords (Keyword::LOAD , Keyword::INDEX , Keyword::INTO , Keyword::CACHE );
7777
7878 $ tableIndexLists = [];
7979 do {
80- $ table = new QualifiedName (...$ tokenList ->consumeQualifiedName ());
80+ $ table = new QualifiedName (...$ tokenList ->expectQualifiedName ());
8181 $ partitions = $ this ->parsePartitions ($ tokenList );
8282 $ indexes = $ this ->parseIndexes ($ tokenList );
83- $ ignoreLeaves = ( bool ) $ tokenList ->mayConsumeKeywords (Keyword::IGNORE , Keyword::LEAVES );
83+ $ ignoreLeaves = $ tokenList ->hasKeywords (Keyword::IGNORE , Keyword::LEAVES );
8484
8585 $ tableIndexLists [] = new TableIndexList ($ table , $ indexes , $ partitions , $ ignoreLeaves );
86- } while ($ tokenList ->mayConsumeComma ());
86+ } while ($ tokenList ->hasComma ());
8787
8888 return new LoadIndexIntoCacheCommand ($ tableIndexLists );
8989 }
@@ -94,13 +94,13 @@ public function parseLoadIndexIntoCache(TokenList $tokenList): LoadIndexIntoCach
9494 private function parseIndexes (TokenList $ tokenList ): ?array
9595 {
9696 $ indexes = null ;
97- if ($ tokenList ->mayConsumeAnyKeyword (Keyword::INDEX , Keyword::KEY )) {
98- $ tokenList ->consume (TokenType::LEFT_PARENTHESIS );
97+ if ($ tokenList ->hasAnyKeyword (Keyword::INDEX , Keyword::KEY )) {
98+ $ tokenList ->expect (TokenType::LEFT_PARENTHESIS );
9999 $ indexes = [];
100100 do {
101- $ indexes [] = $ tokenList ->consumeName ();
102- } while ($ tokenList ->mayConsumeComma ());
103- $ tokenList ->consume (TokenType::RIGHT_PARENTHESIS );
101+ $ indexes [] = $ tokenList ->expectName ();
102+ } while ($ tokenList ->hasComma ());
103+ $ tokenList ->expect (TokenType::RIGHT_PARENTHESIS );
104104 }
105105
106106 return $ indexes ;
@@ -111,20 +111,20 @@ private function parseIndexes(TokenList $tokenList): ?array
111111 */
112112 private function parsePartitions (TokenList $ tokenList )
113113 {
114- if (!$ tokenList ->mayConsumeKeyword (Keyword::PARTITION )) {
114+ if (!$ tokenList ->hasKeyword (Keyword::PARTITION )) {
115115 return null ;
116116 }
117117
118- $ tokenList ->consume (TokenType::LEFT_PARENTHESIS );
119- if ($ tokenList ->mayConsumeKeyword (Keyword::ALL )) {
118+ $ tokenList ->expect (TokenType::LEFT_PARENTHESIS );
119+ if ($ tokenList ->hasKeyword (Keyword::ALL )) {
120120 $ partitions = true ;
121121 } else {
122122 $ partitions = [];
123123 do {
124- $ partitions [] = $ tokenList ->consumeName ();
125- } while ($ tokenList ->mayConsumeComma ());
124+ $ partitions [] = $ tokenList ->expectName ();
125+ } while ($ tokenList ->hasComma ());
126126 }
127- $ tokenList ->consume (TokenType::RIGHT_PARENTHESIS );
127+ $ tokenList ->expect (TokenType::RIGHT_PARENTHESIS );
128128
129129 return $ partitions ;
130130 }
0 commit comments