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