package gve.calc.formula;
import java.awt.*;
public abstract class Operator extends Part {
public abstract String getName();
public abstract int getPri();
public static boolean isOperatorName(String name) {
return InfixBinaryOp.isOperatorName(name)
|| PrefixUnaryOp.isOperatorName(name);
}
public static String operatorPrefix(String name) {
String result = InfixBinaryOp.operatorPrefix(name);
String attempt = PrefixUnaryOp.operatorPrefix(name);
if (result == null) result = attempt;
else if (attempt!=null && attempt.length()>result.length())
result = attempt;
attempt = PostfixUnaryOp.operatorPrefix(name);
if (result == null) result = attempt;
else if (attempt!=null && attempt.length()>result.length())
result = attempt;
return result;
}
public String toString() {
return getClass().getName()+"["+getName()+"]";
}
/* Remove operator, replace by an Identifier with the given string */
abstract Identifier dismantle(String str,Formula f);
/* Remove operator, replace by an Identifier with the name of the
* operator */
Identifier dismantle(Formula f) {
return dismantle(getName(),f);
}
// REMOVE THIS (backward compat quick-fix)
public Part evaluate(Evaluator ev) { return null; }
}