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

it.twenfir.antlr.ast.AstVisitor Maven / Gradle / Ivy

There is a newer version: 0.1.3
Show newest version
package it.twenfir.antlr.ast;

/**
 * Base interface for visitors.
 * Provides an interface to compute aggregate values over AST's. Specific visitors should extends
 * this interface and declare a visit override method for each node type in their
 * AST's.
 * 
 * @param  the type of the value returned by this visitor
 */
public interface AstVisitor {

	/**
	 * Default result of visiting a leaf node.
	 * 
	 * @return the default result of a visit
	 */
	ValueT defaultValue();

	/**
	 * Default method to aggregate visit results, e.g. over a node's children.
	 * 
	 * @param accumulator the running result of previous visits
	 * @param value       a value to add, e.g. the result of the last visit
	 * @return            the combination of aggregator and value
	 */
	ValueT aggregate(ValueT accumulator, ValueT value);

	/**
	 * Generic visit to the current node.
	 * @param node the node to visit
	 * @return     the result of the visit
	 */
	ValueT visit(AstNode node);

	/**
	 * Generic visit over a node's children.
	 * 
	 * @param node the node whose children should be visited
	 * @return     the aggregated result of visiting the node's children
	 */
	ValueT visitChildren(AstNode node);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy