ExpressionParser { static Parser<Expression> condition(Parser<Expression> expr, Parser<Relation> rel) { Parser<Expression> atom = Parsers.or( compare(expr), in(expr), notIn(expr), exists(rel), notExists(rel), inRelation(expr, rel), notInRelation(expr, rel)); return logical(atom); }    }
@Test public void testCondition() { Parser<Expression> parser = ExpressionParser.condition(NUMBER, RelationParser.TABLE); TerminalParserTest.assertParser(parser, "1 = 2", new BinaryExpression(number(1), Op.EQ, number(2))); TerminalParserTest.assertParser(parser, "1 is null", new BinaryExpression(number(1), Op.IS, NullExpression.instance)); TerminalParserTest.assertParser(parser, "1 is not null", new BinaryExpression(number(1), Op.NOT, NullExpression.instance)); TerminalParserTest.assertParser(parser, "1 like 2", new LikeExpression(number(1), true, number(2), null)); TerminalParserTest.assertParser(parser, "(1 < 2 or not exists t)", new BinaryExpression( new BinaryExpression(number(1), Op.LT, number(2)), Op.OR, new UnaryExpression(Op.NOT, new UnaryRelationalExpression(table("t"), Op.EXISTS)) ) ); }