DeclarationParser { static Parser<Declaration> annotationDef(Parser<Modifier> mod, Parser<Member> member) { return Parsers.sequence( mod.many(), phrase("@ interface").next(Terminals.Identifier.PARSER), body(member), AnnotationDef::new); }  static Parser<Program> program(); static Program parse(String source); static Program parse(URL url);  }
@Test public void testAnnotationDef() { Parser<Declaration> parser = DeclarationParser.annotationDef(StatementParser.modifier(IDENTIFIER), FIELD); TerminalParserTest.assertResult(parser, "@interface Foo{}", AnnotationDef.class, "@interface Foo {}"); TerminalParserTest.assertResult(parser, "@Target({METHOD, FIELD}) @RetentionPolicy(RUNTIME) @interface Foo{}", AnnotationDef.class, "@Target({METHOD, FIELD}) @RetentionPolicy(RUNTIME) @interface Foo {}"); TerminalParserTest.assertResult(parser, "@interface Foo{int i;int j;}", AnnotationDef.class, "@interface Foo {int i; int j;}"); }