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

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


        GdlVariable var = (GdlVariable) term;
        if (varsToModelsMap.containsKey(var)) {
          varsToModelsMap.get(var).mergeIn(termModel);
        }
      } else if (term instanceof GdlFunction) {
        GdlFunction function = (GdlFunction) term;
        List<TermModel> functionBodyModel = termModel.getFunctionBodyModel(function);
        if (functionBodyModel != null) {
          addVariablesToMap(function.getBody(), functionBodyModel, varsToModelsMap);
        }
      }
    }
  }
View Full Code Here


    public boolean addTerm(GdlTerm term, Map<GdlVariable, TermModel> varsToModelsMap) {
      boolean changesMade = false;
      if (term instanceof GdlConstant) {
        changesMade = possibleConstants.add((GdlConstant) term);
      } 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 {
        throw new RuntimeException("Unrecognized term type " + term.getClass() + " for term " + term);
      }
View Full Code Here

          return false;
        }
        assignment.put(var, (GdlConstant)refTerm);
      } else if(headTerm instanceof GdlFunction) {
        //Recurse on the body
        GdlFunction headFunction = (GdlFunction) headTerm;
        GdlFunction refFunction = (GdlFunction) refTerm;
        if(!setVariablesInHead(headFunction.getBody(), refFunction.getBody(), assignment))
          return false;
      }
    }
    return true;
  }
View Full Code Here

        return false;
      } else if (term instanceof GdlFunction) {
        if (!functions.containsKey(i)) {
          return false;
        }
        GdlFunction function = (GdlFunction) term;
        SimpleSentenceForm functionForm = functions.get(i);
        if (!functionForm.matches(function)) {
          return false;
        }
      }
View Full Code Here

        return false;
      } else if (term instanceof GdlFunction) {
        if (!functions.containsKey(i)) {
          return false;
        }
        GdlFunction innerFunction = (GdlFunction) term;
        SimpleSentenceForm functionForm = functions.get(i);
        if (!functionForm.matches(innerFunction)) {
          return false;
        }
      }
View Full Code Here

        if ( base.arity() == index )
        {
            GdlConstant name = (GdlConstant) base.get(0);
            List<GdlTerm> body = new ArrayList<GdlTerm>(workingSet);

            GdlFunction function = GdlPool.getFunction(name, body);
            results.add(GdlPool.getRule(GdlPool.getRelation(GdlPool.getConstant("true"), new GdlTerm[] { function })));
        }
        else
        {
            for ( GdlTerm term : ((GdlFunction) base.get(index)).getBody() )
View Full Code Here

        {
            return gdl;
        }
        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);
        }
        else if(gdl instanceof GdlVariable)
        {
            GdlVariable variable = (GdlVariable)gdl;
            return varInstantiation.get(variable);
View Full Code Here

            return rval;
        }
        else if(term instanceof GdlVariable)
            throw new RuntimeException("Called getConstantList on something containing a variable.");

        GdlFunction func = (GdlFunction)term;
        for(GdlTerm t : func.getBody())
            rval.addAll(getConstantList(t));

        return rval;
    }
View Full Code Here

        {
            rval.add(term);
            return rval;
        }

        GdlFunction func = (GdlFunction)term;
        for(GdlTerm t : func.getBody())
            rval.addAll(getConstantAndVariableList(t));

        return rval;
    }
View Full Code Here

        if(term instanceof GdlConstant)
            return fillerVar;
        else if(term instanceof GdlVariable)
            return fillerVar;

        GdlFunction func = (GdlFunction)term;
        List<GdlTerm> newBody = new ArrayList<GdlTerm>();
        for(GdlTerm t : func.getBody())
            newBody.add(findGenericForm(t));
        GdlConstant name = func.getName();
        if(name==legalConst)
            name=doesConst;
        else if(name==nextConst)
            name=trueConst;
        else if(name==initConst)
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.