Package org.ggp.base.util.gdl

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


        //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

                    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

    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

  }

  // 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

  }

  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

Related Classes of org.ggp.base.util.gdl.GdlVisitor

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.