use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr in project scout.rt by eclipse.
the class SqlFormatter method formatBracketExpr.
private void formatBracketExpr(BracketExpr stm, FormatContext ctx) {
boolean multiline = isMultiline(stm);
for (IToken t : stm.getChildren()) {
if (t instanceof OpenBracketToken) {
formatDefault(t, ctx);
if (multiline) {
ctx.println();
ctx.in();
}
} else if (t instanceof CloseBracketToken) {
if (multiline) {
ctx.out();
}
formatDefault(t, ctx);
} else if (t instanceof Statement) {
formatStatement((Statement) t, ctx);
} else if (t instanceof SingleStatement) {
formatSingleStatement((SingleStatement) t, ctx);
} else if (t instanceof ListExpr) {
formatListExpr((ListExpr) t, multiline, ctx);
} else {
formatDefault(t, ctx);
}
}
}
use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr in project scout.rt by eclipse.
the class SqlParser method parseListExpr.
private ListExpr parseListExpr(List<IToken> list, ParseContext ctx) {
// OrExpr (ListSeparator OrExpr)*
ParseStep lock = ctx.checkAndAdd("ListExpr", list);
if (lock == null) {
return null;
}
try {
OrExpr oe = parseOrExpr(list, ctx);
if (oe == null) {
return null;
}
ListExpr le = new ListExpr();
le.addChild(oe);
ListSeparator ls = null;
while ((ls = removeToken(list, ListSeparator.class)) != null && (oe = parseOrExpr(list, ctx)) != null) {
le.addChild(ls);
le.addChild(oe);
}
// restore incomplete
if (ls != null) {
list.add(0, ls);
}
return le;
} finally {
ctx.remove(lock);
}
}
use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr in project scout.rt by eclipse.
the class SqlFormatter method formatPart.
private void formatPart(Part stm, FormatContext ctx) {
boolean hasList = false;
for (IToken t : stm.getChildren()) {
if (t instanceof PartToken) {
formatDefault(t, ctx);
} else if (t instanceof Part) {
ctx.in();
formatPart((Part) t, ctx);
ctx.out();
} else if (t instanceof ListExpr) {
hasList = true;
ctx.in();
formatListExpr((ListExpr) t, true, ctx);
ctx.out();
} else {
formatDefault(t, ctx);
}
}
if (!hasList) {
ctx.in();
ctx.print(" ");
ctx.out();
}
}
use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr in project scout.rt by eclipse.
the class SqlParser method parsePart.
private Part parsePart(List<IToken> list, ParseContext ctx, boolean rootPart) {
// PartToken ListExpr
ParseStep lock = ctx.checkAndAdd("Part", list);
if (lock == null) {
return null;
}
try {
PartToken pt;
ListExpr le;
if ((pt = removeToken(list, PartToken.class)) != null && (!rootPart || isRootPartToken(pt))) {
// ok
le = parseListExpr(list, ctx);
} else {
// restore incomplete
if (pt != null) {
list.add(0, pt);
}
return null;
}
Part p = new Part();
p.addChild(pt);
if (le != null) {
p.addChild(le);
}
return p;
} finally {
ctx.remove(lock);
}
}
Aggregations