use of com.alibaba.cobar.parser.ast.stmt.ddl.DDLDropTableStatement in project cobar by alibaba.
the class MySQLDDLParser method dropTable.
/**
* <code>TABLE</code> has been consumed
*/
private DDLDropTableStatement dropTable(boolean temp) throws SQLSyntaxErrorException {
boolean ifExists = false;
if (lexer.token() == KW_IF) {
lexer.nextToken();
match(KW_EXISTS);
ifExists = true;
}
Identifier tb = identifier();
List<Identifier> list;
if (lexer.token() != PUNC_COMMA) {
list = new ArrayList<Identifier>(1);
list.add(tb);
} else {
list = new LinkedList<Identifier>();
list.add(tb);
for (; lexer.token() == PUNC_COMMA; ) {
lexer.nextToken();
tb = identifier();
list.add(tb);
}
}
DDLDropTableStatement.Mode mode = DDLDropTableStatement.Mode.UNDEF;
switch(lexer.token()) {
case KW_RESTRICT:
lexer.nextToken();
mode = DDLDropTableStatement.Mode.RESTRICT;
break;
case KW_CASCADE:
lexer.nextToken();
mode = DDLDropTableStatement.Mode.CASCADE;
break;
}
return new DDLDropTableStatement(list, temp, ifExists, mode);
}
Aggregations