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

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


    if(literal instanceof GdlSentence) {
      sentences.add((GdlSentence) literal);
    } else if(literal instanceof GdlNot) {
      getSentencesInLiteral(((GdlNot) literal).getBody(), sentences);
    } else if(literal instanceof GdlOr) {
      GdlOr or = (GdlOr) literal;
      for(int i = 0; i < or.arity(); i++) {
        getSentencesInLiteral(or.get(i), sentences);
      }
    }
  }
View Full Code Here


    if(literal instanceof GdlNot) {
      GdlNot not = (GdlNot) literal;
      if(!(not.getBody() instanceof GdlSentence))
        throw new ValidatorException("The negation " + not + " contains a literal " + not.getBody() + " that is not a sentence. Only a single sentence is allowed inside a negation.");
    } else if(literal instanceof GdlOr) {
      GdlOr or = (GdlOr) literal;
      for(int i = 0; i < or.arity(); i++) {
        testLiteralForImproperNegation(or.get(i));
      }
    }
  }
View Full Code Here

      }
      return !satisfiesSentence(assignment, (GdlSentence) body, sentencesSoFar);
    } else if (literal instanceof GdlDistinct) {
      return satisfiesDistinct(assignment, (GdlDistinct) literal);
    } else if (literal instanceof GdlOr) {
      GdlOr or = (GdlOr) literal;
      for (int i = 0; i < or.arity(); i++) {
        GdlLiteral innerLiteral = or.get(i);
        if (satisfies(assignment, innerLiteral, sentencesSoFar)) {
          return true;
        }
      }
      return false;
View Full Code Here

        } else {
          acyclicRelations.add(relation);
        }
      } else if(literal instanceof GdlOr) {
        //We'll look one layer deep for the cyclic kind
        GdlOr or = (GdlOr) literal;
        for(int i = 0; i < or.arity(); i++) {
          GdlLiteral internal = or.get(i);
          if(internal instanceof GdlRelation) {
            GdlRelation relation = (GdlRelation) internal;
            if(ancestorsGraph.get(relation.getName()).contains(head)) {
              cyclicRelations.add(relation);
            } //Don't add acyclic relations, as we can't count on them
View Full Code Here

      dependencies.add(((GdlSentence) literal).getName());
    } else if(literal instanceof GdlNot) {
      addLiteralAsDependent(((GdlNot) literal).getBody(), dependencies, negativeEdges);
      addLiteralAsDependent(((GdlNot) literal).getBody(), negativeEdges, negativeEdges);
    } else if(literal instanceof GdlOr) {
      GdlOr or = (GdlOr) literal;
      for(int i = 0; i < or.arity(); i++) {
        addLiteralAsDependent(or.get(i), dependencies, negativeEdges);
      }
    }
  }
View Full Code Here

      GdlLiteral internal = ((GdlNot) literal).getBody();
      if(internal instanceof GdlRelation) {
        getVariablesInBody(((GdlRelation) internal).getBody(), unsupportedVariables);
      }
    } else if(literal instanceof GdlOr) {
      GdlOr or = (GdlOr) literal;
      for(int i = 0; i < or.arity(); i++) {
        getUnsupportedVariablesInLiteral(or.get(i), unsupportedVariables);
      }
    } else if(literal instanceof GdlDistinct) {
      GdlDistinct distinct = (GdlDistinct) literal;
      List<GdlTerm> pair = new ArrayList<GdlTerm>(2); //Easy way to parse functions
      pair.add(distinct.getArg1());
View Full Code Here

  private static void getSupportedVariablesInLiteral(GdlLiteral literal,
      Collection<GdlVariable> variables) {
    if(literal instanceof GdlRelation) {
      getVariablesInBody(((GdlRelation) literal).getBody(), variables);
    } else if(literal instanceof GdlOr) {
      GdlOr or = (GdlOr) literal;
      if(or.arity() == 0)
        return;
      LinkedList<GdlVariable> vars = new LinkedList<GdlVariable>();
      getSupportedVariablesInLiteral(or.get(0), vars);
      for(int i = 1; i < or.arity(); i++) {
        Set<GdlVariable> newVars = new HashSet<GdlVariable>();
        getSupportedVariablesInLiteral(or.get(i), newVars);
        vars.retainAll(newVars);
      }
      variables.addAll(vars);
    }
  }
View Full Code Here

      sentences.add((GdlSentence) literal);
    } else if(literal instanceof GdlNot) {
      GdlNot not = (GdlNot) literal;
      addSentencesInLiteral(not.getBody(), sentences);
    } else if(literal instanceof GdlOr) {
      GdlOr or = (GdlOr) literal;
      for(int i = 0; i < or.arity(); i++)
        addSentencesInLiteral(or.get(i), sentences);
    } else if(!(literal instanceof GdlDistinct)) {
      throw new RuntimeException("Unexpected GdlLiteral type encountered: " + literal.getClass().getSimpleName());
    }
  }
View Full Code Here

            GdlNot not = (GdlNot)gdl;
            processGdl(not.getBody(), null);
        }
        else if(gdl instanceof GdlOr)
        {
            GdlOr or = (GdlOr)gdl;
            for(int i=0; i<or.arity(); i++)
                processGdl(or.get(i), null);
        }
        else if(gdl instanceof GdlProposition)
        {
            //IGNORE
        }
View Full Code Here

//          GdlNot not = (GdlNot)gdl;
            //Negative context, ignore it for now
        }
        else if(gdl instanceof GdlOr) //TODO: check that this is right, I think it may not be
        {
            GdlOr or = (GdlOr)gdl;
            for(int i=0; i<or.arity(); i++)
                rval.addAll(findAllInstancesOf(var, or.get(i), null));
        }
        else if(gdl instanceof GdlProposition)
        {
//          GdlProposition prop = (GdlProposition)gdl;
            //I think these can safely be ignored, they have no body
View Full Code Here

TOP

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

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.