DeclarationParser { static Parser<Declaration> interfaceDef(Parser<Modifier> mod, Parser<Member> member) { return Parsers.sequence( mod.many(), term("interface").next(Terminals.Identifier.PARSER), TYPE_PARAMETERS.optional(), term("extends").next(TypeLiteralParser.ELEMENT_TYPE_LITERAL.sepBy1(term(","))).optional(), body(member), InterfaceDef::new); }  static Parser<Program> program(); static Program parse(String source); static Program parse(URL url);  }
@Test public void testInterfaceDef() { Parser<Declaration> parser = DeclarationParser.interfaceDef(StatementParser.SYSTEM_MODIFIER, FIELD); TerminalParserTest.assertResult(parser, "public native interface Foo {}", InterfaceDef.class, "public native interface Foo {}"); TerminalParserTest.assertResult(parser, "interface Foo<T> {}", InterfaceDef.class, "interface Foo<T> {}"); TerminalParserTest.assertResult(parser, "interface Foo<T extends Foo<T>, K> {}", InterfaceDef.class, "interface Foo<T extends Foo<T>, K> {}"); TerminalParserTest.assertResult(parser, "interface Foo<T extends Foo<T>> extends List<?> {}", InterfaceDef.class, "interface Foo<T extends Foo<T>> extends List<?> {}"); TerminalParserTest.assertFailure(parser, "interface Foo implements List {}", 1, 15, "implements encountered."); TerminalParserTest.assertResult(parser, "interface Foo<T extends Foo<T>> extends List<?>, Iterable<T> {}", InterfaceDef.class, "interface Foo<T extends Foo<T>> extends List<?>, Iterable<T> {}"); TerminalParserTest.assertResult(parser, "interface Foo<T extends Foo<T>> {public static String S = foo;}", InterfaceDef.class, "interface Foo<T extends Foo<T>> {public static String S = foo;}"); TerminalParserTest.assertResult(parser, "interface Foo<T extends Foo<T>> {int i; int j;}", InterfaceDef.class, "interface Foo<T extends Foo<T>> {int i; int j;}"); }