ExpressionParser { static final Parser<Expression> castOrExpression(Parser<Expression> expr) { Parser<Expression> explicitCast = Parsers.sequence(paren(TypeLiteralParser.TYPE_LITERAL), expr, CastExpression::new); return explicitCast.or(paren(expr)); }  static Parser<Expression> expression(
      Parser<DefBody> classBody, Parser<Statement> statement); static Parser<Expression> arrayInitializer(Parser<Expression> expr);  }
@Test public void testCastOrExpression() { Parser<Expression> parser = ExpressionParser.castOrExpression(ExpressionParser.IDENTIFIER); TerminalParserTest.assertResult(parser, "(foo)", Identifier.class, "foo"); TerminalParserTest.assertResult(parser, "(foo) bar", CastExpression.class, "((foo) bar)"); TerminalParserTest.assertResult(parser, "(foo<int>) bar", CastExpression.class, "((foo<int>) bar)"); TerminalParserTest.assertFailure(parser, "(foo<int>) ", 1, 12); }