use of org.eclipse.rdf4j.query.parser.serql.ast.ASTNodeElem in project rdf4j by eclipse.
the class AnonymousVarGenerator method createNodeElem.
private ASTNodeElem createNodeElem() {
ASTNodeElem nodeElem = new ASTNodeElem(SyntaxTreeBuilderTreeConstants.JJTNODEELEM);
ASTVar var = createAnonymousVar();
var.jjtSetParent(nodeElem);
nodeElem.jjtAppendChild(var);
return nodeElem;
}
use of org.eclipse.rdf4j.query.parser.serql.ast.ASTNodeElem in project rdf4j by eclipse.
the class AnonymousVarGenerator method visit.
@Override
public Object visit(ASTNode node, Object data) throws VisitorException {
if (node.jjtGetNumChildren() == 0) {
ASTNodeElem nodeElem = createNodeElem();
nodeElem.jjtSetParent(node);
node.jjtAppendChild(nodeElem);
}
return super.visit(node, data);
}
use of org.eclipse.rdf4j.query.parser.serql.ast.ASTNodeElem in project rdf4j by eclipse.
the class AnonymousVarGenerator method visit.
@Override
public Object visit(ASTReifiedStat node, Object data) throws VisitorException {
if (node.jjtGetChild(0) instanceof ASTEdge) {
// subject node is missing
ASTNodeElem nodeElem = createNodeElem();
nodeElem.jjtSetParent(node);
node.jjtInsertChild(nodeElem, 0);
}
if (node.jjtGetNumChildren() <= 2) {
// object node is missing
ASTNodeElem nodeElem = createNodeElem();
nodeElem.jjtSetParent(node);
node.jjtAppendChild(nodeElem);
}
if (node.getID() == null) {
node.setID(createAnonymousVar());
}
return super.visit(node, data);
}
use of org.eclipse.rdf4j.query.parser.serql.ast.ASTNodeElem in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public List<Var> visit(ASTNode node, Object data) throws VisitorException {
List<Var> nodeVars = new ArrayList<Var>();
for (ASTNodeElem nodeElem : node.getNodeElemList()) {
Var nodeVar = (Var) nodeElem.jjtAccept(this, null);
nodeVars.add(nodeVar);
}
// Create any implicit unequalities
for (int i = 0; i < nodeVars.size() - 1; i++) {
Var var1 = nodeVars.get(i);
for (int j = i + 1; j < nodeVars.size(); j++) {
Var var2 = nodeVars.get(j);
// for the unequality to make any sense:
if (!var1.hasValue() || !var2.hasValue()) {
graphPattern.addConstraint(new Not(new SameTerm(var1, var2)));
}
}
}
return nodeVars;
}
Aggregations