Search in sources :

Example 1 with ASTNodeElem

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;
}
Also used : ASTVar(org.eclipse.rdf4j.query.parser.serql.ast.ASTVar) ASTNodeElem(org.eclipse.rdf4j.query.parser.serql.ast.ASTNodeElem)

Example 2 with ASTNodeElem

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);
}
Also used : ASTNodeElem(org.eclipse.rdf4j.query.parser.serql.ast.ASTNodeElem)

Example 3 with ASTNodeElem

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);
}
Also used : ASTEdge(org.eclipse.rdf4j.query.parser.serql.ast.ASTEdge) ASTNodeElem(org.eclipse.rdf4j.query.parser.serql.ast.ASTNodeElem)

Example 4 with ASTNodeElem

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;
}
Also used : ASTNot(org.eclipse.rdf4j.query.parser.serql.ast.ASTNot) Not(org.eclipse.rdf4j.query.algebra.Not) ASTVar(org.eclipse.rdf4j.query.parser.serql.ast.ASTVar) Var(org.eclipse.rdf4j.query.algebra.Var) ASTSameTerm(org.eclipse.rdf4j.query.parser.serql.ast.ASTSameTerm) SameTerm(org.eclipse.rdf4j.query.algebra.SameTerm) ArrayList(java.util.ArrayList) ASTNodeElem(org.eclipse.rdf4j.query.parser.serql.ast.ASTNodeElem)

Aggregations

ASTNodeElem (org.eclipse.rdf4j.query.parser.serql.ast.ASTNodeElem)4 ASTVar (org.eclipse.rdf4j.query.parser.serql.ast.ASTVar)2 ArrayList (java.util.ArrayList)1 Not (org.eclipse.rdf4j.query.algebra.Not)1 SameTerm (org.eclipse.rdf4j.query.algebra.SameTerm)1 Var (org.eclipse.rdf4j.query.algebra.Var)1 ASTEdge (org.eclipse.rdf4j.query.parser.serql.ast.ASTEdge)1 ASTNot (org.eclipse.rdf4j.query.parser.serql.ast.ASTNot)1 ASTSameTerm (org.eclipse.rdf4j.query.parser.serql.ast.ASTSameTerm)1