StatementParser { static Parser<Statement> returnStatement(Parser<Expression> expr) { return between(term("return"), expr.optional(), term(";")).map(ReturnStatement::new); }    }
@Test public void testReturnStatement() { Parser<Statement> parser = StatementParser.returnStatement(ExpressionParser.IDENTIFIER); TerminalParserTest.assertResult(parser, "return;", ReturnStatement.class, "return;"); TerminalParserTest.assertResult(parser, "return foo;", ReturnStatement.class, "return foo;"); }