@@ -148,6 +148,7 @@ public function process($tokens) {
148148
149149 case 'BIT ' :
150150 case 'TINYBIT ' :
151+ case 'TINYINT ' :
151152 case 'SMALLINT ' :
152153 case 'MEDIUMINT ' :
153154 case 'INT ' :
@@ -195,11 +196,16 @@ public function process($tokens) {
195196 $ prevCategory = $ upper ;
196197 continue 2 ;
197198
199+ case 'YEAR ' :
200+ $ expr [] = array ('expr_type ' => ExpressionType::DATA_TYPE , 'base_expr ' => $ trim , 'length ' => false );
201+ $ currCategory = 'SINGLE_PARAM_PARENTHESIS ' ;
202+ $ prevCategory = $ upper ;
203+ continue 2 ;
204+
198205 case 'DATE ' :
199206 case 'TIME ' :
200207 case 'TIMESTAMP ' :
201208 case 'DATETIME ' :
202- case 'YEAR ' :
203209 case 'TINYBLOB ' :
204210 case 'BLOB ' :
205211 case 'MEDIUMBLOB ' :
@@ -218,7 +224,6 @@ public function process($tokens) {
218224 continue 2 ;
219225
220226 case 'ENUM ' :
221- case 'SET ' :
222227 $ currCategory = 'MULTIPLE_PARAM_PARENTHESIS ' ;
223228 $ prevCategory = 'TEXT ' ;
224229 $ expr [] = array ('expr_type ' => ExpressionType::RESERVED , 'base_expr ' => $ trim , 'sub_tree ' => false );
@@ -239,40 +244,24 @@ public function process($tokens) {
239244 continue 2 ;
240245
241246 case 'CHARACTER ' :
242- if ($ prevCategory === 'TEXT ' ) {
243- $ parsed = array ('expr_type ' => ExpressionType::DATA_TYPE , 'base_expr ' => $ trim );
244- $ expr [] = array ('expr_type ' => ExpressionType::CHARSET , 'base_expr ' => substr ($ base_expr , 0 , -1 ),
245- 'sub_tree ' => $ parsed );
246- $ base_expr = $ token ;
247- $ currCategory = 'CHARSET ' ;
248- continue 2 ;
249- }
250- // else ?
251- break ;
247+ $ currCategory = 'CHARSET ' ;
248+ $ options ['sub_tree ' ][] = array ('expr_type ' => ExpressionType::RESERVED , 'base_expr ' => $ trim );
249+ continue 2 ;
252250
253251 case 'SET ' :
254- if ($ currCategory === 'CHARSET ' ) {
255- // TODO: is it necessary to set special properties like the name or collation?
256- $ parsed = array ('expr_type ' => ExpressionType::RESERVED , 'base_expr ' => $ trim );
257- $ last = array_pop ($ expr );
258- $ last ['sub_tree ' ][] = $ parsed ;
259- $ expr [] = $ last ;
260- continue 2 ;
261- }
262- // else ?
263- break ;
252+ if ($ currCategory == 'CHARSET ' ) {
253+ $ options ['sub_tree ' ][] = array ('expr_type ' => ExpressionType::RESERVED , 'base_expr ' => $ trim );
254+ } else {
255+ $ currCategory = 'MULTIPLE_PARAM_PARENTHESIS ' ;
256+ $ prevCategory = 'TEXT ' ;
257+ $ expr [] = array ('expr_type ' => ExpressionType::RESERVED , 'base_expr ' => $ trim , 'sub_tree ' => false );
258+ }
259+ continue 2 ;
264260
265261 case 'COLLATE ' :
266- if ($ prevCategory === 'TEXT ' ) {
267- $ parsed = array ('expr_type ' => ExpressionType::RESERVED , 'base_expr ' => $ trim );
268- $ expr [] = array ('expr_type ' => ExpressionType::COLLATE , 'base_expr ' => substr ($ base_expr , 0 , -1 ),
269- 'sub_tree ' => $ parsed );
270- $ base_expr = $ token ;
271- $ currCategory = 'COLLATION ' ;
272- continue 2 ;
273- }
274- // else ?
275- break ;
262+ $ currCategory = $ upper ;
263+ $ options ['sub_tree ' ][] = array ('expr_type ' => ExpressionType::RESERVED , 'base_expr ' => $ trim );
264+ continue 2 ;
276265
277266 case 'NOT ' :
278267 case 'NULL ' :
@@ -362,25 +351,17 @@ public function process($tokens) {
362351
363352 case 'COLLATE ' :
364353 // this is the collation name
365- $ parsed = array ('expr_type ' => ExpressionType::CONSTANT , 'base_expr ' => $ trim );
366- $ last = array_pop ($ expr );
367- $ last ['sub_tree ' ][] = $ parsed ;
368- $ t = $ base_expr ;
369- $ base_expr = $ last ['base_expr ' ] . $ base_expr ;
370- $ last ['base_expr ' ] = $ t ;
354+ $ options ['sub_tree ' ][] = array ('expr_type ' => ExpressionType::COLLATE , 'base_expr ' => $ trim );
355+ $ options ['collate ' ] = $ trim ;
371356 $ currCategory = $ prevCategory ;
372357 break ;
373358
374359 case 'CHARSET ' :
375360 // this is the character set name
376- $ parsed = array ('expr_type ' => ExpressionType::CONSTANT , 'base_expr ' => $ trim );
377- $ last = array_pop ($ expr );
378- $ last ['sub_tree ' ][] = $ parsed ;
379- $ t = $ base_expr ;
380- $ base_expr = $ last ['base_expr ' ] . $ base_expr ;
381- $ last ['base_expr ' ] = $ t ;
361+ $ options ['sub_tree ' ][] = array ('expr_type ' => ExpressionType::CHARSET , 'base_expr ' => $ trim );
362+ $ options ['charset ' ] = $ trim ;
382363 $ currCategory = $ prevCategory ;
383- break ;
364+ break ;
384365
385366 case 'SINGLE_PARAM_PARENTHESIS ' :
386367 $ parsed = $ this ->removeParenthesisFromStart ($ trim );
0 commit comments