Search in sources :

Example 1 with OrExpr

use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OrExpr 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);
    }
}
Also used : ListSeparator(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListSeparator) ListExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr) OrExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OrExpr)

Example 2 with OrExpr

use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OrExpr in project scout.rt by eclipse.

the class SqlParser method parseOrExpr.

private OrExpr parseOrExpr(List<IToken> list, ParseContext ctx) {
    // AndExpr (BinaryOp['OR'] AndExpr)*
    ParseStep lock = ctx.checkAndAdd("OrExpr", list);
    if (lock == null) {
        return null;
    }
    try {
        AndExpr ae = parseAndExpr(list, ctx);
        if (ae == null) {
            return null;
        }
        OrExpr oe = new OrExpr();
        oe.addChild(ae);
        OrOp oo;
        while ((oo = removeToken(list, OrOp.class)) != null && (ae = parseAndExpr(list, ctx)) != null) {
            oe.addChild(oo);
            oe.addChild(ae);
        }
        // remaining?
        if (oo != null) {
            oo.addComment(new Comment("/*syntax warning*/"));
            oe.addChild(oo);
        }
        return oe;
    } finally {
        ctx.remove(lock);
    }
}
Also used : AndExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.AndExpr) OrOp(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OrOp) Comment(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Comment) OrExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OrExpr)

Aggregations

OrExpr (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OrExpr)2 AndExpr (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.AndExpr)1 Comment (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Comment)1 ListExpr (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr)1 ListSeparator (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListSeparator)1 OrOp (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OrOp)1