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

Examples of org.ggp.base.util.gdl.grammar.GdlFunction


  }
  private static void addFunctionsInBody(List<GdlTerm> body,
      List<GdlFunction> functions) {
    for(GdlTerm term : body) {
      if(term instanceof GdlFunction) {
        GdlFunction function = (GdlFunction) term;
        functions.add(function);
        addFunctionsInBody(function.getBody(), functions);
      }
    }
  }
View Full Code Here


      if(term instanceof GdlConstant) {
        tuple.add(term);
      } else if(term instanceof GdlVariable) {
        tuple.add(term);
      } else if(term instanceof GdlFunction){
        GdlFunction function = (GdlFunction) term;
        addBodyToTuple(function.getBody(), tuple);
      } else {
        throw new RuntimeException("Unforeseen Gdl tupe in SentenceModel.addBodyToTuple()");
      }
    }
  }
View Full Code Here

      if(term instanceof GdlConstant) {
        tuple.add((GdlConstant) term);
      } else if(term instanceof GdlVariable) {
        throw new RuntimeException("Asking for a ground tuple of a non-ground sentence");
      } else if(term instanceof GdlFunction){
        GdlFunction function = (GdlFunction) term;
        addBodyToGroundTuple(function.getBody(), tuple);
      } else {
        throw new RuntimeException("Unforeseen Gdl tupe in SentenceModel.addBodyToTuple()");
      }
    }
  }
View Full Code Here

          assignment.put((GdlVariable)leftTerm, (GdlConstant)rightTerm);
        }
      } else if(leftTerm instanceof GdlFunction) {
        if(!(rightTerm instanceof GdlFunction))
          return false;
        GdlFunction leftFunction = (GdlFunction) leftTerm;
        GdlFunction rightFunction = (GdlFunction) rightTerm;
        if(!leftFunction.getName().equals(rightFunction.getName()))
          return false;
        if(!fillAssignmentBody(assignment, leftFunction.getBody(), rightFunction.getBody()))
          return false;
      }
    }
    return true;
  }
View Full Code Here

                throw new RuntimeException("Incorrectly constructed base props");

            if(merge.size()<i)
                merge.add(new HashSet<GdlConstant>());

            GdlFunction f = (GdlFunction)t;
            Set<GdlConstant> dom = merge.get(i-1);
            for(GdlTerm t2 : f.getBody())
            {
                if(!(t2 instanceof GdlConstant))
                    throw new RuntimeException("Incorrectly constructed base props: something other than a constant");
                dom.add((GdlConstant)t2);
            }
View Full Code Here

        {
            universe.add((GdlConstant)gdl);
        }
        else if(gdl instanceof GdlFunction)
        {
            GdlFunction func = (GdlFunction)gdl;
            for(Gdl gdl2 : func.getBody())
                processGdl(gdl2, func.getName());
        }
        else if(gdl instanceof GdlDistinct)
        {
            GdlDistinct distinct = (GdlDistinct)gdl;
            processGdl(distinct.getArg1(), null);
View Full Code Here

                    baseRelations.add(toAdd);
                    System.err.println("Weird init of variable");
                }
                else if(template instanceof GdlFunction)
                {
                    GdlFunction func = (GdlFunction)template;
                    instantiateBaseProps(func.toSentence());
                }
            }
        }
        else if(gdl instanceof GdlRule)
        {
View Full Code Here

            GdlTerm arg = template.get(i);
            if(arg instanceof GdlConstant)
            {
                List<GdlTerm> domBody = new ArrayList<GdlTerm>();
                domBody.add(arg);
                GdlFunction dom = GdlPool.getFunction(GdlPool.getConstant("val"), domBody);
                body.add(dom);
            }
            else if(arg instanceof GdlVariable)
            {
                List<GdlTerm> domBody = new ArrayList<GdlTerm>();
                Location loc = new Location();
                loc.idx = i;
                loc.name = template.getName();
                Domain varDom = domains.get(loc);
                if(varDom == null)
                    throw new RuntimeException("Unexpected domain: "+loc+" encountered.");
                domBody.addAll(varDom.values);
                GdlFunction dom = GdlPool.getFunction(GdlPool.getConstant("val"), domBody);
                body.add(dom);
            }
            else if(arg instanceof GdlFunction)
            {
                throw new RuntimeException("Don't know how to deal with functions within next/init.");
View Full Code Here

            GdlConstant constant = (GdlConstant)term;
            dom.values.add(constant);
        }
        else if(term instanceof GdlFunction)
        {
            GdlFunction func = (GdlFunction)term;
            int i=0;
            for(GdlTerm t2 : func.getBody())
            {
                addDomain2(t2, func.getName(), i, RHS);
                i++;
            }
        }
        else if(term instanceof GdlVariable)
        {
View Full Code Here

//          GdlConstant constant = (GdlConstant)gdl;
            //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));
            }
        }
        else if(gdl instanceof GdlVariable)
        {   //This is the interesting one
            GdlVariable variable = (GdlVariable)gdl;
View Full Code Here

TOP

Related Classes of org.ggp.base.util.gdl.grammar.GdlFunction

Copyright © 2018 www.massapicom. 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.