Examples of GdlVisitor


Examples of org.ggp.base.util.gdl.GdlVisitor

    }
  }

  private static void verifyNonZeroArities(List<GdlRelation> relations,
      List<GdlRule> rules) throws ValidatorException {
    GdlVisitor arityCheckingVisitor = new GdlVisitor() {
      @Override
      public void visitFunction(GdlFunction function) {
        if (function.arity() == 0) {
          throw new RuntimeException(function + " is written as a zero-arity function; " +
              "it should be written as a constant instead. " +
View Full Code Here

Examples of org.ggp.base.util.gdl.GdlVisitor

        //The model may only have sentence forms for sentences that can actually be
        //true. It may be missing sentence forms that are used in the rules only,
        //with no actual corresponding sentences. We want to make sure these are
        //included.
        final Set<SentenceForm> forms = Sets.newHashSet(model.getSentenceForms());
        GdlVisitors.visitAll(model.getDescription(), new GdlVisitor() {
            @Override
            public void visitSentence(GdlSentence sentence) {
                forms.add(SimpleSentenceForm.create(sentence));
            }
        });
View Full Code Here

Examples of org.ggp.base.util.gdl.GdlVisitor

                    return true;
                }
                GdlRule rule = (GdlRule) input;
                // Used just as a boolean we can change from the inner class
                final AtomicBoolean shouldRemove = new AtomicBoolean(false);
                GdlVisitors.visitAll(rule, new GdlVisitor() {
                    @Override
                    public void visitSentence(GdlSentence sentence) {
                        SentenceForm form = model.getSentenceForm(sentence);
                        if (!model.getSentenceForms().contains(form)) {
                            shouldRemove.set(true);
View Full Code Here

Examples of org.ggp.base.util.gdl.GdlVisitor

    private static abstract class UnusedVariableGenerator {
        public GdlFunction replaceVariablesAndConstants(GdlFunction function) {
            Map<GdlVariable, GdlVariable> assignment = Maps.newHashMap();

            final Set<GdlTerm> termsToReplace = Sets.newHashSet();
            GdlVisitors.visitAll(function, new GdlVisitor() {
                @Override
                public void visitConstant(GdlConstant constant) {
                    termsToReplace.add(constant);
                }
                @Override
View Full Code Here

Examples of org.ggp.base.util.gdl.GdlVisitor

  }

  // Unlike getPositiveConjuncts, this also returns sentences inside NOT literals.
  private static List<GdlSentence> getAllSentencesInBody(List<GdlLiteral> body) {
    final List<GdlSentence> sentences = Lists.newArrayList();
    GdlVisitors.visitAll(body, new GdlVisitor() {
      @Override
      public void visitSentence(GdlSentence sentence) {
        sentences.add(sentence);
      }
    });
View Full Code Here

Examples of org.ggp.base.util.gdl.GdlVisitor

  }

  private static Set<SentenceForm> getSentenceFormsInBody(
      GdlLiteral bodyLiteral, final ImmutableSet<SentenceForm> sentenceForms) {
    final Set<SentenceForm> forms = new HashSet<SentenceForm>();
    GdlVisitors.visitAll(bodyLiteral, new GdlVisitor() {
      @Override
      public void visitSentence(GdlSentence sentence) {
        for (SentenceForm form : sentenceForms) {
          if (form.matches(sentence)) {
            forms.add(form);
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.