Package org.ggp.base.util.gdl.grammar

Examples of org.ggp.base.util.gdl.grammar.GdlFunction.arity()


            //Just a constant
        }
        else if(gdl instanceof GdlFunction)
        {
            GdlFunction func = (GdlFunction)gdl;
            for(int i=0; i<func.arity(); i++)
            {
                Location parent = new Location();
                parent.name = func.getName();
                parent.idx = i;
                rval.addAll(findAllInstancesOf(var, func.get(i), parent));
View Full Code Here


                return "<fact>"+renderGdlToXML(f.get(0))+"</fact>";
            }
            else
            {
                rval += "<relation>"+f.getName()+"</relation>";
                for(int i=0; i<f.arity(); i++)
                    rval += "<argument>"+renderGdlToXML(f.get(i))+"</argument>";
                return rval;
            }
        } else if (gdl instanceof GdlRelation) {
            GdlRelation relation = (GdlRelation) gdl;
View Full Code Here

    if(term instanceof GdlConstant || term instanceof GdlVariable)
      return term;
    if(term instanceof GdlFunction) {
      GdlFunction function = (GdlFunction) term;
      //The whole point of the function
      if(function.arity() == 0)
        return function.getName();
      List<GdlTerm> cleanedBody = new ArrayList<GdlTerm>();
      for(GdlTerm functionTerm : function.getBody())
        cleanedBody.add(cleanParentheses(functionTerm));
      return GdlPool.getFunction(function.getName(), cleanedBody);
View Full Code Here

        } else if(gdl instanceof GdlConstant) {
            return gdl;
        } else if(gdl instanceof GdlFunction) {
            GdlFunction func = (GdlFunction)gdl;
            List<GdlTerm> rval = new ArrayList<GdlTerm>();
            for(int i=0; i<func.arity(); i++)
            {
                rval.add((GdlTerm) replaceVariableInternal(func.get(i), toSubstitute, theReplacement));
            }
            return GdlPool.getFunction(func.getName(), rval);
        } else if(gdl instanceof GdlVariable) {
View Full Code Here

      else
        return gdl;
    } else if (gdl instanceof GdlFunction) {
      GdlFunction function = (GdlFunction) gdl;
      GdlConstant name = function.getName();
      List<GdlTerm> newBody = new ArrayList<GdlTerm>(function.arity());
      for (GdlTerm term : function.getBody()) {
        newBody.add(replaceVariables(term, assignment));
      }
      return GdlPool.getFunction(name, newBody);
    } else if (gdl instanceof GdlDistinct) {
View Full Code Here

      } else if (term instanceof GdlFunction) {
        GdlFunction function = (GdlFunction) term;
        NameAndArity sentenceName = new NameAndArity(function);
        if (!possibleFunctions.containsKey(sentenceName)) {
          changesMade = true;
          possibleFunctions.put(sentenceName, getNTermModels(function.arity()));
        }
        changesMade |= addBodyToModel(possibleFunctions.get(sentenceName), function.getBody(), varsToModelsMap);
      } else if (term instanceof GdlVariable) {
        changesMade = mergeIn(varsToModelsMap.get(term));
      } else {
View Full Code Here

        }
        else if(gdl instanceof GdlFunction)
        {
            GdlFunction func = (GdlFunction)gdl;
            List<GdlTerm> body = new ArrayList<GdlTerm>();
            for(int i=0; i<func.arity(); i++)
            {
                body.add((GdlTerm)getInstantiationAux(func.get(i), varInstantiation));
            }
            return GdlPool.getFunction(func.getName(), body);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.