static void testLocationOpInPredicate() { String query = "Edge(int a:0..100, (int b)). \n" + "Attr(int a,int b).\n" + "Attr(a,b) :- Edge(a,b).\n"; Parser p = new Parser(); TestAnalysis an; try { p.parse(query); an = new TestAnalysis(p); an.setDistributed(); an.run(); Assert.die("should not reach here"); } catch (ParseException e) { /* expected */ } query = "Edge(int a:0..100, (int b)). \n" + "Attr(int a,int b).\n" + "Attr(a, b) :- Edge(a, b).\n"; p = new Parser(); try { p.parse(query); an = new TestAnalysis(p); an.setDistributed(); an.run(); Assert.die("should not reach here"); } catch (ParseException e) { /* expected */ } }
public Set<Variable> getBodyVariables() { Set<Variable> vars = new LinkedHashSet<Variable>(); for (Object o : getBody()) { if (o instanceof Predicate) { addVariablesForPredicate((Predicate) o, vars); } else if (o instanceof Expr) { addVariablesForExpr((Expr) o, vars); } else if (o instanceof Function) { addVariablesForFunc((Function) o, vars); } else { Assert.die("Unexpected type, o[" + o.getClass().getSimpleName() + "]"); } } return vars; }
static void testVarResolution2() { String simpleQuery = "Edge(int s,(int t)).\n" + "Foaf(int a,int b).\n" + "Foo(int a,int b).\n" + "Foaf(n1,n3) :- Foo(n1,n2), Edge(n2,n3), n4= n5*(n2+1).\n"; Parser p = new Parser(simpleQuery); p.parse(); Analysis an = new Analysis(p); try { an.run(); Assert.die("should not reach here!"); } catch (Exception e) { /* pass */ } }
static void testIterColumn() { String query = "Foo(int a:iter, ApproxCount b). \n" + "Bar(int a, int b:iter). \n"; Parser p = new Parser(); p.parse(query); Analysis an = new Analysis(p); an.run(); query = "Foo(int a:iter, int b). \n" + "Bar(int a, int b:iter). \n" + "Foo(0,b) :- b=10. " + "Foo(1,b) :- Foo(0, c), b=c+1.\n"; p = new Parser(); p.parse(query); an = new Analysis(p); an.run(); query = "Baz(int a, String b, (int i:iterator)).\n"; p = new Parser(); try { p.parse(query); Assert.die("Expecting parse exception for nested iterator column"); } catch (ParseException e) { } query = "Foo(int a:iter, int b). \n" + "Bar(int a, int b:iter). \n" + "Foo(1,b) :- Foo(0, c), b=c+1.\n"; p = new Parser(); p.parse(query); an = new Analysis(p); an.run(); query = "Foo(2,b) :- Foo(1, c), b=c+1.\n"; p.parse(query); an = new Analysis(p); an.run(); List<Rule> rules = an.getRules(); query = "Foo(3,b) :- Foo(2, c), b=c+1.\n"; p.parse(query); an = new Analysis(p); an.run(); rules = an.getRules(); }