use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Statement in project scout.rt by eclipse.
the class SqlParser method parseSingleStatement.
/**
* return {@link SingleStatement} or {@link BracketExpr}
*/
private IToken parseSingleStatement(List<IToken> list, ParseContext ctx) {
ParseStep lock = ctx.checkAndAdd("SingleStatement", list);
if (lock == null) {
return null;
}
try {
// brackets
ArrayList<IToken> backup = new ArrayList<IToken>(list);
BracketExpr be = parseBracketExpr(list, ctx);
if (be != null) {
BracketExpr tmp = be;
while (tmp != null) {
// open, token, close
IToken ch = tmp.getChildren().get(1);
if (ch instanceof BracketExpr) {
tmp = (BracketExpr) ch;
} else if (ch instanceof Statement) {
return be;
} else if (ch instanceof SingleStatement) {
return be;
} else {
tmp = null;
}
}
// restore
list.clear();
list.addAll(backup);
return null;
}
//
// Part+
Part p;
SingleStatement ss = new SingleStatement();
if ((p = parsePart(list, ctx, true)) != null) {
// ok
ss.addChild(p);
} else {
return null;
}
while ((p = parsePart(list, ctx, false)) != null) {
ss.addChild(p);
}
if (ss.getChildren().size() == 0) {
return null;
}
return ss;
} finally {
ctx.remove(lock);
}
}
Aggregations