DlgpParser extends AbstractCloseableIterator<Object> implements Parser<Object> { public static ConjunctiveQuery parseQuery(String s) throws ParseException { try { return (ConjunctiveQuery) 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 parseQuery() throws ParseException { ConjunctiveQuery q = DlgpParser.parseQuery("?(X) :- p(a,X)."); Assert.assertEquals(X, q.getAnswerVariables().get(0)); Atom a = q.getAtomSet().iterator().next(); Assert.assertEquals(A, a.getTerm(0)); Assert.assertEquals(X, a.getTerm(1)); }
@Test(expected = ParseException.class) public void parseQueryWithNewVarInAns() throws ParseException { DlgpParser.parseQuery("?(X,Y) :- p(a,X)."); }
@Test(expected = ParseException.class) public void parseQueryWrongObject() throws ParseException { DlgpParser.parseQuery("p(a)."); }