use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MathOp in project scout.rt by eclipse.
the class SqlParser method parseMathExpr.
private MathExpr parseMathExpr(List<IToken> list, ParseContext ctx) {
// _simpleExpr (BinaryOp _simpleExpr)*
ParseStep lock = ctx.checkAndAdd("MathExpr", list);
if (lock == null) {
return null;
}
try {
IToken se = parseSimpleExpr(list, ctx);
if (se == null) {
return null;
}
MathExpr me = new MathExpr();
me.addChild(se);
MathOp mo;
while ((mo = removeToken(list, MathOp.class)) != null && (se = parseSimpleExpr(list, ctx)) != null) {
me.addChild(mo);
me.addChild(se);
}
// restore incomplete
if (mo != null) {
list.add(0, mo);
}
return me;
} finally {
ctx.remove(lock);
}
}
use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MathOp in project scout.rt by eclipse.
the class SqlFormatter method formatMathExpr.
private void formatMathExpr(MathExpr stm, FormatContext ctx) {
for (IToken t : stm.getChildren()) {
if (!(t instanceof MathOp)) {
formatSimpleExpr(t, ctx);
} else {
ctx.print(" ");
formatDefault(t, ctx);
ctx.print(" ");
}
}
}
use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MathOp in project scout.rt by eclipse.
the class SqlParser method parseMinusExpr.
private MinusExpr parseMinusExpr(List<IToken> list, ParseContext ctx) {
// BinaryOp['-'] Atom
ParseStep lock = ctx.checkAndAdd("MinusExpr", list);
if (lock == null) {
return null;
}
try {
MathOp mo = null;
IToken a = null;
if ((mo = removeToken(list, MathOp.class, "-")) != null && (a = parseAtom(list, ctx)) != null) {
// ok
} else {
// restore incomplete
if (mo != null) {
list.add(0, mo);
}
return null;
}
MinusExpr e = new MinusExpr();
e.addChild(mo);
e.addChild(a);
return e;
} finally {
ctx.remove(lock);
}
}
Aggregations