All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aima.core.logic.propositional.parsing.AbstractPLVisitor Maven / Gradle / Ivy

Go to download

AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.

The newest version!
package aima.core.logic.propositional.parsing;

import aima.core.logic.propositional.parsing.ast.ComplexSentence;
import aima.core.logic.propositional.parsing.ast.Sentence;
import aima.core.logic.propositional.parsing.ast.PropositionSymbol;

/**
 * Abstract implementation of the PLVisitor interface that provides default
 * behavior for each of the methods.
 * 
 * @author Ravi Mohan
 * @author Ciaran O'Reilly
 * 
 * @param 
 *            the argument type to be passed to the visitor methods.
 */
public abstract class AbstractPLVisitor implements PLVisitor {

	@Override
	public Sentence visitPropositionSymbol(PropositionSymbol s, A arg) {
		// default behavior is to treat propositional symbols as atomic
		// and leave unchanged.
		return s;
	}

	@Override
	public Sentence visitUnarySentence(ComplexSentence s, A arg) {
		// a new Complex Sentence with the same connective but possibly
		// with its simpler sentence replaced by the visitor.
		return new ComplexSentence(s.getConnective(), s.getSimplerSentence(0)
				.accept(this, arg));
	}

	@Override
	public Sentence visitBinarySentence(ComplexSentence s, A arg) {
		// a new Complex Sentence with the same connective but possibly
		// with its simpler sentences replaced by the visitor.
		return new ComplexSentence(s.getConnective(), s.getSimplerSentence(0)
				.accept(this, arg), s.getSimplerSentence(1).accept(this, arg));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy