DlgpParser extends AbstractCloseableIterator<Object> implements Parser<Object> { public static Rule parseRule(String s) throws ParseException { try { return (Rule) parse(s); } catch (ClassCastException e) { throw new DlgpParseException("Wrong object type.", e); } } DlgpParser(Reader reader);  DlgpParser();  DlgpParser(File file);  DlgpParser(String s);  DlgpParser(InputStream in); @Override boolean hasNext(); @Override Object next(); @Override void close(); static EffectiveConjunctiveQuery parseEffectiveQuery(String s); static ConjunctiveQuery parseQuery(String s); static Atom parseAtom(String s); static Rule parseRule(String s); static NegativeConstraint parseNegativeConstraint(String s); static CloseableIterator<Atom> parseAtomSet(String s);  }
@Test public void parseRule() throws ParseException { Rule r = DlgpParser.parseRule("p(X,Y) :- q(X,Z)."); Atom body = r.getBody().iterator().next(); Assert.assertTrue(body.getTerm(0).isVariable()); Assert.assertTrue(body.getTerm(1).isVariable()); Atom head = r.getHead().iterator().next(); Assert.assertTrue(head.getTerm(0).isVariable()); Assert.assertTrue(head.getTerm(1).isVariable()); }
@Test(expected = ParseException.class) public void parseRuleWrongObject() throws ParseException { DlgpParser.parseRule("p(a)."); }
@Test public void labelTest() throws ParseException { String label = "_- 0aZéàß"; Rule r1 = DlgpParser.parseRule("[" + label + "] q(X) :- r(X)."); Assert.assertEquals(label, r1.getLabel()); }