138 $tokenizer->skipWhiteSpace();
140 if ($tokenizer->testUpperText(
'IF'))
142 $tokenizer->skipWhiteSpace();
144 if ($tokenizer->testUpperText(
'NOT'))
146 $tokenizer->skipWhiteSpace();
149 if ($tokenizer->testUpperText(
'EXISTS'))
151 $tokenizer->skipWhiteSpace();
155 $table =
new Table($tokenizer->getCurrentToken()->text);
157 $tokenizer->nextToken();
158 $tokenizer->skipWhiteSpace();
160 if ($tokenizer->testText(
'('))
162 $tokenizer->skipWhiteSpace();
164 $token = $tokenizer->getCurrentToken();
165 $level = $token->level;
169 $tokenizer->testUpperText(
'INDEX')
170 || $tokenizer->testUpperText(
'KEY')
173 $tokenizer->skipWhiteSpace();
174 $table->createIndex($tokenizer,
false);
176 elseif ($tokenizer->testUpperText(
'UNIQUE'))
178 $tokenizer->skipWhiteSpace();
179 if ($tokenizer->testUpperText(
'KEY'))
181 $tokenizer->skipWhiteSpace();
183 elseif ($tokenizer->testUpperText(
'INDEX'))
185 $tokenizer->skipWhiteSpace();
187 $table->createIndex($tokenizer,
true);
189 elseif ($tokenizer->testUpperText(
'FULLTEXT'))
191 $tokenizer->skipWhiteSpace();
192 if ($tokenizer->testUpperText(
'KEY'))
194 $tokenizer->skipWhiteSpace();
196 elseif ($tokenizer->testUpperText(
'INDEX'))
198 $tokenizer->skipWhiteSpace();
200 $table->createIndex($tokenizer,
false,
true);
202 elseif ($tokenizer->testUpperText(
'PRIMARY'))
204 $tokenizer->skipWhiteSpace();
205 if (!$tokenizer->testUpperText(
'KEY'))
213 $table->createConstraint($tokenizer,
false);
215 elseif ($tokenizer->testUpperText(
'CONSTRAINT'))
217 $tokenizer->skipWhiteSpace();
218 $constraintName = $tokenizer->getCurrentToken()->text;
220 $tokenizer->nextToken();
221 $tokenizer->skipWhiteSpace();
223 if ($tokenizer->testUpperText(
'PRIMARY') || $tokenizer->testUpperText(
'UNIQUE'))
226 $table->createConstraint($tokenizer, $constraintName);
228 elseif ($tokenizer->testUpperText(
'FOREIGN'))
231 $table->createConstraint($tokenizer, $constraintName);
235 throw new NotSupportedException(
"'PRIMARY KEY' expected. line:" . $tokenizer->getCurrentToken()->line);
238 elseif ($tokenizer->testUpperText(
')'))
244 $table->createColumn($tokenizer);
247 $tokenizer->skipWhiteSpace();
249 $token = $tokenizer->getCurrentToken();
251 if ($token->level == $level && $token->text ===
',')
253 $token = $tokenizer->nextToken();
255 elseif ($token->level < $level && $token->text ===
')')
257 $tokenizer->nextToken();
262 throw new NotSupportedException(
"',' or ')' expected got (" . $token->text .
'). line:' . $token->line);
265 $tokenizer->skipWhiteSpace();
267 while (!$tokenizer->
endOfInput() && $token->level >= $level);
272 $suffix .= $tokenizer->getCurrentToken()->text;
273 $tokenizer->nextToken();
277 $table->setBody($suffix);