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

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


        {
            GdlRelation relation = (GdlRelation) gdl;
            String name = relation.getName().toString();
            if(name.equals("init"))
            {
                if(relation.arity()!=1)
                    throw new RuntimeException("Can't init more than one thing as far as I know.");
                GdlTerm template = relation.get(0);
                if(template instanceof GdlConstant)
                {
                    List<GdlTerm> body = new ArrayList<GdlTerm>();
View Full Code Here


        Set<Domain> rval = new HashSet<Domain>();

        if(gdl instanceof GdlRelation)
        {
            GdlRelation relation = (GdlRelation) gdl;
            for(int i=0; i<relation.arity(); i++)
            {
                Location parent = new Location();
                parent.name = relation.getName();
                parent.idx = i;
                rval.addAll(findAllInstancesOf(var, relation.get(i), parent));
View Full Code Here

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

                for(int i=0; i<relation.arity(); i++)
                    rval+="<fact>"+renderGdlToXML(relation.get(i))+"</fact>";
                return rval;
            } else {
                rval+="<relation>"+relation.getName()+"</relation>";
                for(int i=0; i<relation.arity(); i++)
                    rval+="<argument>"+renderGdlToXML(relation.get(i))+"</argument>";
                return rval;
            }
        } else {
            System.err.println("gdlToXML Error: could not handle "+gdl.toString());
View Full Code Here

    newDescription = new ArrayList<Gdl>();
    boolean removeBaseSentences = false;
    for (Gdl gdl : description) {
      if (gdl instanceof GdlRelation) {
        GdlRelation relation = (GdlRelation) gdl;
        if (relation.getName() == BASE && relation.arity() != 1) {
          removeBaseSentences = true;
          break;
        }
      }
    }
View Full Code Here

        } else if(gdl instanceof GdlProposition) {
            return gdl;
        } else if(gdl instanceof GdlRelation) {
            GdlRelation rel = (GdlRelation)gdl;
            List<GdlTerm> rval = new ArrayList<GdlTerm>();
            for(int i=0; i<rel.arity(); i++)
            {
                rval.add((GdlTerm) replaceVariableInternal(rel.get(i), toSubstitute, theReplacement));
            }
            return GdlPool.getRelation(rel.getName(), rval);
        } else if(gdl instanceof GdlRule) {
View Full Code Here

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

        if(gdl instanceof GdlRelation)
        {
            GdlRelation relation = (GdlRelation) gdl;

            List<GdlTerm> body = new ArrayList<GdlTerm>();
            for(int i=0; i<relation.arity(); i++)
            {
                body.add((GdlTerm)getInstantiationAux(relation.get(i), varInstantiation));
            }
            return GdlPool.getRelation(relation.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.