Search in sources :

Example 1 with Name

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

the class SqlParser method parseAtom.

private Atom parseAtom(List<IToken> list, ParseContext ctx) {
    // (BracketExpr Outer | Statement | OrExpr | FunExpr | Name | Text | BinaryOp['*']) (OuterJoinToken)? (Name["AS"])? (Name[alias])?
    ParseStep lock = ctx.checkAndAdd("Atom", list);
    if (lock == null) {
        return null;
    }
    try {
        IToken t = null;
        if ((t = parseBracketExpr(list, ctx)) != null) {
        // ok
        } else if ((t = parseStatement(list, ctx)) != null) {
        // ok
        } else if ((t = parseOrExpr(list, ctx)) != null) {
        // ok
        } else if ((t = parseFunExpr(list, ctx)) != null) {
        // ok
        } else if ((t = removeToken(list, Name.class)) != null) {
        // ok
        } else if ((t = removeToken(list, Text.class)) != null) {
        // ok
        } else if ((t = removeToken(list, MathOp.class, "*")) != null) {
        // ok
        } else {
            return null;
        }
        // found a match
        Atom a = new Atom();
        a.addChild(t);
        if ((t = removeToken(list, OuterJoinToken.class)) != null) {
            a.addChild(t);
        }
        if ((t = removeToken(list, Name.class)) != null) {
            a.addChild(t);
        }
        return a;
    } finally {
        ctx.remove(lock);
    }
}
Also used : IToken(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.IToken) OuterJoinToken(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OuterJoinToken) MathOp(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MathOp) Atom(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Atom) Name(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Name)

Example 2 with Name

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

the class SqlParser method parseFunExpr.

private FunExpr parseFunExpr(List<IToken> list, ParseContext ctx) {
    // Name BracketExpr
    ParseStep lock = ctx.checkAndAdd("FunExpr", list);
    if (lock == null) {
        return null;
    }
    try {
        Name nm = null;
        BracketExpr be = null;
        if ((nm = removeToken(list, Name.class)) != null && (be = parseBracketExpr(list, ctx)) != null) {
        // ok
        } else {
            // restore incomplete
            if (nm != null) {
                list.add(0, nm);
            }
            return null;
        }
        FunExpr e = new FunExpr();
        e.addChild(nm);
        e.addChild(be);
        return e;
    } finally {
        ctx.remove(lock);
    }
}
Also used : BracketExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.BracketExpr) FunExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.FunExpr) Name(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Name)

Aggregations

Name (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Name)2 Atom (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Atom)1 BracketExpr (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.BracketExpr)1 FunExpr (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.FunExpr)1 IToken (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.IToken)1 MathOp (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.MathOp)1 OuterJoinToken (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OuterJoinToken)1