DeclarationParser { static Parser<Member> constructorDef(Parser<Modifier> mod, Parser<Statement> stmt) { return Parsers.sequence( mod.many(), Terminals.Identifier.PARSER, term("(").next(StatementParser.parameter(mod).sepBy(term(","))).followedBy(term(")")), term("throws").next(TypeLiteralParser.ELEMENT_TYPE_LITERAL.sepBy1(term(","))).optional(), StatementParser.blockStatement(stmt), ConstructorDef::new); }  static Parser<Program> program(); static Program parse(String source); static Program parse(URL url);  }
@Test public void testConstructorDef() { Parser<Member> parser = DeclarationParser.constructorDef( StatementParser.SYSTEM_MODIFIER, StatementParser.BREAK); TerminalParserTest.assertResult(parser, "public Foo(){}", ConstructorDef.class, "public Foo() {}"); TerminalParserTest.assertResult(parser, "Foo() throws E{break;}", ConstructorDef.class, "Foo() throws E {break;}"); TerminalParserTest.assertResult(parser, "Foo(int i) {}", ConstructorDef.class, "Foo(int i) {}"); TerminalParserTest.assertResult(parser, "Foo(final int i, List<Foo> l) {}", ConstructorDef.class, "Foo(final int i, List<Foo> l) {}"); }