2017-07-25 13:53:38 -07:00
|
|
|
package org.nwapw.abacus.tree;
|
|
|
|
|
2017-07-27 09:33:01 -07:00
|
|
|
import org.nwapw.abacus.function.OperatorAssociativity;
|
2017-07-25 13:53:38 -07:00
|
|
|
import org.nwapw.abacus.lexing.Lexer;
|
|
|
|
import org.nwapw.abacus.lexing.pattern.Match;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
2017-07-26 10:10:37 -07:00
|
|
|
/**
|
|
|
|
* An abstract class that represents an expression tree node.
|
|
|
|
*/
|
2017-07-25 13:53:38 -07:00
|
|
|
public abstract class TreeNode {
|
|
|
|
|
2017-07-27 14:06:57 -07:00
|
|
|
/**
|
|
|
|
* The function that reduces a tree to a single vale.
|
|
|
|
* @param reducer the reducer used to reduce the tree.
|
|
|
|
* @param <T> the type the reducer produces.
|
|
|
|
* @return the result of the reduction, or null on error.
|
|
|
|
*/
|
2017-07-26 10:58:27 -07:00
|
|
|
public abstract <T> T reduce(Reducer<T> reducer);
|
|
|
|
|
2017-07-25 13:53:38 -07:00
|
|
|
}
|