Search in sources :

Example 1 with MathOp

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);
    }
}
Also used : IToken(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.IToken) MathOp(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MathOp) MathExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MathExpr)

Example 2 with MathOp

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(" ");
        }
    }
}
Also used : IToken(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.IToken) MathOp(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MathOp)

Example 3 with MathOp

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);
    }
}
Also used : IToken(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.IToken) MathOp(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MathOp) MinusExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MinusExpr)

Aggregations

IToken (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.IToken)3 MathOp (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MathOp)3 MathExpr (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MathExpr)1 MinusExpr (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MinusExpr)1