ExpressionParser { static Parser<Expression> like(Parser<Expression> expr) { return Parsers.sequence( expr, Parsers.or(term("like").retn(true), phrase("not like").retn(false)), expr, term("escape").next(expr).optional(), LikeExpression::new); }    }
@Test public void testLike() { Parser<Expression> parser = ExpressionParser.like(NUMBER); TerminalParserTest.assertParser(parser, "1 like 2", new LikeExpression(number(1), true, number(2), null)); TerminalParserTest.assertParser(parser, "1 not like 2", new LikeExpression(number(1), false, number(2), null)); TerminalParserTest.assertParser(parser, "1 like 2 escape 3", new LikeExpression(number(1), true, number(2), number(3))); TerminalParserTest.assertParser(parser, "1 not like 2 escape 3", new LikeExpression(number(1), false, number(2), number(3))); }