/** * Examines all top-level functors within a clause, including any head and body, and determines which functor has * the highest number of arguments. * * @param clause The clause to determine the highest number of arguments within. * * @return The highest number of arguments within any top-level functor in the clause. */ private int findMaxArgumentsInClause(Clause clause) { int result = 0; Functor head = clause.getHead(); if (head != null) { result = head.getArity(); } Functor[] body = clause.getBody(); if (body != null) { for (int i = 0; i < body.length; i++) { int arity = body[i].getArity(); result = (arity > result) ? arity : result; } } return result; }
/** * Creates a traversable state for the specified label term. * * @param labelTerm The label term to create a traversable state for. */ public LabelState(Functor labelTerm) { this.labelTerm = labelTerm; labelPath = new String[] { ((StringLiteral) labelTerm.getArgument(0)).stringValue() }; isLeaf = labelTerm.getArity() <= 1; }
/** * Creates a traversable state for the specified label term. * * @param labelTerm The label term to create a traversable state for. * @param labelPath The label path of the parent state, that this state extends with a child label. */ private LabelState(Functor labelTerm, String[] labelPath) { this.labelTerm = labelTerm; this.labelPath = Arrays.copyOf(labelPath, labelPath.length + 1); this.getLabelPath()[labelPath.length] = ((StringLiteral) labelTerm.getArgument(0)).stringValue(); isLeaf = labelTerm.getArity() <= 1; }
/** * {@inheritDoc} * * <p/>Checks if the label term has more than one argument, and for each child label argument creates an * operator leadning to a new state for that child label. */ public Iterator<Operator<LabelState>> validOperators(boolean reverse) { // Check if the label has any child labels. if (!isLeaf) { List<Operator<LabelState>> childLabels = new LinkedList<Operator<LabelState>>(); for (int i = 1; i < labelTerm.getArity(); i++) { childLabels.add(new OperatorImpl<LabelState>( new LabelState((Functor) labelTerm.getArgument(i), labelPath))); } return childLabels.iterator(); } else { return new EmptyIterator<Operator<LabelState>>(); } }
if (functor.getArity() == 0)
for (; reg < expression.getArity(); reg++)
int arity = leftFunctor.getArity();
int arity = leftFunctor.getArity();