StatementParser { static Parser<Statement> whileStatement(Parser<Expression> expr, Parser<Statement> stmt) { return Parsers.sequence( between(phrase("while ("), expr, term(")")), stmt, WhileStatement::new); }    }
@Test public void testWhileStatement() { Parser<Statement> parser = StatementParser.whileStatement(ExpressionParser.IDENTIFIER, SIMPLE_STATEMENT); TerminalParserTest.assertResult(parser, "while(foo) bar;", WhileStatement.class, "while (foo) bar;"); }