### Question:
DefinitionParser { public static org.kframework.definition.Definition from(String definitionText) { String mainModuleName = defaultMainModuleName(definitionText); return from(definitionText, mainModuleName, defaultMainSyntaxModuleName(mainModuleName), defaultSource(), defaultLookupDirectories()); }  static List<File> defaultLookupDirectories(); static org.kframework.definition.Definition from(String definitionText); static org.kframework.definition.Definition from(String definitionText, String mainModuleName); static org.kframework.definition.Definition from(String definitionText, String mainModuleName, List<File> lookupDirectories); static org.kframework.definition.Definition from(String definitionText, String mainModuleName, String mainSyntaxModuleName); static org.kframework.definition.Definition from(String definitionText, String mainModuleName, Source source); static org.kframework.definition.Definition from(String definitionText, String mainModuleName, Source source, List<File> lookupDirectories); static org.kframework.definition.Definition from(String definitionText, String mainModuleName, String mainSyntaxModuleName, Source source, List<File> lookupDirectories);  }### Answer:
@Test public void testEmpty() throws Exception { Definition actual = DefinitionParser.from("require \"domains.k\" module X endmodule"); Module expected = Module("X", Set()); }
@Test public void testOnlySyntax() throws Exception { org.kframework.definition.Definition actual = DefinitionParser.from( "require \"domains.k\"" + "\n" + "module X" + "\n" + "syntax Foo ::= \"bar\"" + "\n" + "endmodule"); Module expected = Module("X", Set( Production(Sort("Foo"), Seq(Terminal("bar")), Att().add(Att.klabel(), "bar")) )); }
@Test public void testWithRuleBody() throws Exception { org.kframework.definition.Definition actual = DefinitionParser.from( "require \"domains.k\"" + "\n" + "module X" + "\n" + "syntax Foo ::= \"bar\"" + "\n" + "rule bar => bar" + "\n" + "endmodule"); Module expected = Module("X", Set( Production(Sort("Foo"), Seq(Terminal("bar")), Att().add(Att.klabel(), "bar")) )); }
@Test public void testNonexistantRequires() throws Exception { try { DefinitionParser.from( "require \"nonexistant-file.k\"" + "\n" + "module X" + "\n" + "syntax Foo ::= \"bar\"" + "\n" + "rule bar => bar" + "\n" + "endmodule"); fail("Parser not failing to find 'nonexistant-file.k'."); } catch (KEMException e) { assertEquals(e.getMessage().split("\\n")[0], "[Error] Critical: Could not find file: nonexistant-file.k"); } }